Methods executed by electronic devices, electronic devices, storage media, and program products

By acquiring samples and constraints, the control vector of the large language model is determined, and its activation vector is updated. This solves the problem that the output of the large language model does not meet user needs and achieves precise control in long text processing.

CN122087040APending Publication Date: 2026-05-26BEIJING SAMSUNG TELECOM R&D CENT +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411709429.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-26
Publication Date
2026-05-26

Smart Images

  • Figure CN122087040A_ABST
    Figure CN122087040A_ABST
Patent Text Reader

Abstract

This disclosure provides a method, electronic device, storage medium, and program product executed by an electronic device, relating to the field of artificial intelligence. The method includes: acquiring text to be processed and at least one sample, wherein each sample includes at least a question and an answer; using a large language model, based on the at least one sample, determining a first control vector for constraints on at least one network in the large language model; processing the text to be processed using the large language model, and during the processing, updating the activation vectors output by the corresponding networks in the large language model using the at least one first control vector; and obtaining a processing result for the text to be processed based on the updated activation vectors. This disclosure enables finer-grained control of the output of the large language model, allowing the processing result to accurately meet the user's constraint requirements. Optionally, the above method executed by the electronic device can be performed using an artificial intelligence model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to the field of natural language processing technology, and more specifically, to a method executed by an electronic device, an electronic device, a storage medium, and a program product. Background Technology

[0002] Large Language Models (LLMs) are deep learning models that can handle common natural language tasks. They typically have very large parameter scales, training data, and computational resources, and are designed to understand and generate human language, serving as an important pathway to Artificial Intelligence (AI).

[0003] With the widespread application of large language models, the demand for them to accurately follow personalized constraints is rapidly increasing. For example, users want large language models to meet personalized constraints when answering questions, such as using different styles like humor, brevity, or detail.

[0004] In existing technologies, long and complex natural language texts are typically used to constrain the output of large language models. However, the capabilities of large language models are limited, and text descriptions of hundreds or even thousands of words make it difficult for large language models to accurately capture constraint information from natural language texts. Summary of the Invention

[0005] The purpose of this disclosure is to solve the problem of how to achieve precise control during reasoning of large language models.

[0006] According to one aspect of the present disclosure, a method performed by an electronic device is provided, the method comprising: Obtain the text to be processed and at least one sample, wherein each sample includes at least a question and an answer; Using a large language model, based on at least one sample, determine the first control vector of the constraints for at least one network in the large language model; The large language model is used to process the text to be processed, and during the processing, the activation vectors of the corresponding network output in the large language model are updated through at least one first control vector. Based on the updated activation vector, the processing result of the text to be processed is obtained.

[0007] According to another aspect of the present disclosure, an electronic device is provided, comprising: a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement the method performed by the electronic device provided in the embodiments of the present disclosure.

[0008] According to another aspect of the present disclosure, a computer-readable storage medium is provided having a computer program stored thereon, which, when executed by a processor, implements the method performed by an electronic device provided in the embodiments of the present disclosure.

[0009] According to another aspect of the present disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements the method performed by an electronic device provided in the embodiments of the present disclosure.

[0010] The present disclosure provides a method, electronic device, storage medium, and program product executed by an electronic device, which acquires text to be processed and at least one sample, wherein each sample includes at least a question and an answer; using a large language model, based on at least one sample, determines a first control vector for constraints on at least one network in the large language model; using the large language model, processes the text to be processed, and during the processing, updates the activation vectors output by the corresponding networks in the large language model through at least one first control vector; based on the updated activation vectors, obtains the processing result of the text to be processed. That is, the present disclosure finds the precise control vectors for constraints on at least one network in the large language model, and uses the precise control vectors to intervene in its internal networks during inference, thereby controlling the output of the large language model at a finer granularity, so that the processing result of the text to be processed can accurately meet the user's constraint requirements. Attached Figure Description

[0011] To more clearly illustrate the technical solutions in the embodiments of this disclosure, the accompanying drawings used in the description of the embodiments of this disclosure will be briefly introduced below.

[0012] Figure 1 A flowchart illustrating a method executed by an electronic device according to an embodiment of this disclosure; Figure 2 This is a schematic diagram of a large language model structure provided in an embodiment of the present disclosure; Figure 3 A schematic diagram of another large language model structure provided in this disclosure embodiment; Figure 4 This is a schematic diagram illustrating how to divide a sample into three types of text to determine a precise control vector, as provided in an embodiment of this disclosure. Figure 5 A schematic diagram illustrating a constraint difference analysis method provided in an embodiment of this disclosure; Figure 6 A schematic diagram of another constraint difference analysis method provided in an embodiment of this disclosure; Figure 7 A schematic diagram of the semantic space of an attention head network provided in an embodiment of this disclosure; Figure 8 A schematic diagram illustrating a method for determining the sensitivity threshold of a network to constraints, provided in an embodiment of this disclosure; Figure 9 A schematic diagram illustrating a method for generating similar text pairs according to an embodiment of this disclosure; Figure 10 This is a schematic diagram of a positive and negative sample construction method provided in an embodiment of the present disclosure; Figure 11 A schematic diagram of a sample filtering method provided in an embodiment of this disclosure; Figure 12 A schematic diagram illustrating a sample library construction method provided in an embodiment of this disclosure; Figure 13 A schematic diagram illustrating a precise control method for a large language model provided in an embodiment of this disclosure; Figure 14 A schematic diagram illustrating a precise control method for a large language model with explicit constraints, provided in an embodiment of this disclosure; Figure 15 A schematic diagram illustrating a precise control method for a large language model without explicit constraints, provided in an embodiment of this disclosure; Figure 16 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this disclosure. Detailed Implementation

[0013] The following description, with reference to the accompanying drawings, is provided to aid in a thorough understanding of the various embodiments of this disclosure as defined by the claims and their equivalents. This description includes various specific details to aid understanding but should be considered exemplary only. Therefore, those skilled in the art will recognize that various changes and modifications can be made to the various embodiments described herein without departing from the scope and spirit of this disclosure. Furthermore, for clarity and brevity, descriptions of well-known functions and structures may be omitted.

[0014] The terms and wording used in the following description and claims are not limited to their dictionary meanings, but are merely used by the inventors to enable a clear and consistent understanding of this disclosure. Therefore, it will be apparent to those skilled in the art that the following description of various embodiments of this disclosure is for illustrative purposes only and not for limiting the purpose of this disclosure as defined in the appended claims and their equivalents.

[0015] It should be understood that the singular forms of “a,” “an,” and “the” can also include plural references unless the context clearly indicates otherwise. Thus, for example, the reference to “component surface” includes referring to one or more such surfaces. When we say that an element is “connected” or “coupled” to another element, the element can be directly connected or coupled to the other element, or it can mean that the element and the other element are connected through an intermediate element. Furthermore, the use of “connected” or “coupled” herein can include wireless connections or wireless couplings.

[0016] The terms “comprising” or “may include” refer to the presence of a corresponding disclosed function, operation, or component that may be used in the various embodiments of this disclosure, rather than limiting the presence of one or more additional functions, operations, or features. Furthermore, the terms “comprising” or “having” may be interpreted as indicating certain characteristics, numbers, steps, operations, constituent elements, components, or combinations thereof, but should not be construed as excluding the possibility of the presence of one or more other characteristics, numbers, steps, operations, constituent elements, components, or combinations thereof.

[0017] The term "or" as used in the various embodiments of this disclosure includes any of the listed terms and all combinations thereof. For example, "A or B" may include A, may include B, or may include both A and B. When describing multiple (two or more) items, if the relationship between the multiple items is not explicitly defined, the multiple items may refer to one, more, or all of the multiple items. For example, the description "parameter A includes A1, A2, A3" can be implemented as parameter A includes A1 or A2 or A3, or it can be implemented as parameter A includes at least two of the three items A1, A2, and A3.

[0018] Unless otherwise defined, all terms used in this disclosure (including technical or scientific terms) have the same meaning as understood by those skilled in the art. Common terms as defined in dictionaries are to be interpreted as having a meaning consistent with their context in the relevant technical field and should not be interpreted ideally or overly formally, unless expressly defined in this disclosure.

[0019] At least some of the functions of the device or electronic device provided in this disclosure embodiment can be implemented by an AI model, such as implementing at least one module of a plurality of modules of the device or electronic device by an AI model. AI-related functions can be executed by non-volatile memory, volatile memory, and a processor.

[0020] The processor may include one or more processors. In this case, the one or more processors may be general-purpose processors, such as central processing unit (CPU), application processor (AP), etc., or pure graphics processing unit, such as graphics processing unit (GPU), visual processing unit (VPU), and / or AI-specific processors, such as neural processing unit (NPU).

[0021] The one or more processors control the processing of input data based on predefined operating rules or artificial intelligence (AI) models stored in non-volatile and volatile memory. These predefined operating rules or AI models are provided through training or learning.

[0022] Here, "providing through learning" refers to obtaining predefined operating rules or an AI model with desired characteristics by applying a learning algorithm to multiple learning datasets. This learning can be performed within the device or electronic device itself, in which the AI ​​is executed according to the embodiment, and / or can be implemented via a separate server / system.

[0023] AI models can contain multiple neural network layers. Each layer has multiple weight values, and each layer performs neural network computations by calculating the input data of that layer (such as the computation results of the previous layer and / or the input data of the AI ​​model) and the multiple weight values ​​of the current layer. Examples of neural networks include, but are not limited to, convolutional neural networks (CNNs), deep neural networks (DNNs), recurrent neural networks (RNNs), restricted Boltzmann machines (RBMs), deep belief networks (DBNs), bidirectional recurrent deep neural networks (BRDNNs), generative adversarial networks (GANs), and deep Q-networks.

[0024] A learning algorithm is a method of training a predetermined target device (e.g., a robot) using multiple learning data sets to enable, allow, or control the target device to make determinations or predictions. Examples of such learning algorithms include, but are not limited to, supervised learning, unsupervised learning, semi-supervised learning, or reinforcement learning.

[0025] The methods provided in this disclosure may relate to one or more fields in the technical fields of speech, language, image, video, or data intelligence.

[0026] Optionally, in the context of speech or language, according to this disclosure, in a method executed by an electronic device, a method for recognizing user speech and interpreting user intent may receive a speech signal as an analog signal via a acquisition device (e.g., a microphone) and convert the speech portion into computer-readable text using an Automatic Speech Recognition (ASR) model. The user's utterance intent can be obtained by interpreting the converted text using a Natural Language Understanding (NLU) model. The ASR model or NLU model can be an artificial intelligence (AI) model. The AI ​​model can be processed by a dedicated AI processor designed in a hardware architecture specified for processing the AI ​​model. The AI ​​model can be acquired through training. Here, "acquired through training" means obtaining a predefined operating rule or AI model configured to perform desired features (or purposes) by training a basic AI model with multiple training data using a training algorithm. Language understanding is a technique for recognizing and applying / processing human language / text, including, for example, natural language processing, machine translation, dialogue systems, question answering, or speech recognition / synthesis.

[0027] Optionally, in the context of images or videos, according to this disclosure, in methods executed in electronic devices, the method for recognizing text in an image can obtain output data recognizing the image or text in the image by using image data as input data for an artificial intelligence model. The artificial intelligence model can be obtained through training. Here, "obtained through training" means obtaining a predefined operating rule or artificial intelligence model configured to perform desired features (or purposes) by training a basic artificial intelligence model with multiple training data using a training algorithm. The methods of this disclosure can relate to the field of visual understanding in artificial intelligence technology, which is a technology for recognizing and processing things like human vision, and includes, for example, object recognition, object tracking, image retrieval, human recognition, scene recognition, 3D reconstruction / localization, or image enhancement.

[0028] Optionally, in the context of data intelligence processing, according to this disclosure, in methods executed in electronic devices, methods for reasoning or predicting large language model control information and outputs can use artificial intelligence models to recommend / execute using text data. The processor of the electronic device can perform preprocessing operations on the data to transform it into a form suitable for use as input to an artificial intelligence model. The artificial intelligence model can be obtained through training. Here, "obtained through training" means obtaining predefined operating rules or an artificial intelligence model configured to perform desired features (or purposes) by training a basic artificial intelligence model with multiple training data using a training algorithm. Reasoning and prediction are techniques for logical reasoning and prediction based on determined information, including, for example, knowledge-based reasoning, optimization prediction, preference-based planning, or recommendation.

[0029] This disclosure presents a method, electronic device, storage medium, and program product executed by an electronic device, which can also be understood as a precise control scheme for a large language model. This scheme can enable the output of the large language model during inference to accurately meet the user's constraint requirements.

[0030] The following description of several optional embodiments illustrates the technical solutions of this disclosure and the technical effects produced by these solutions. It should be noted that the following embodiments can be referenced, learned from, or combined with each other. Identical terms, similar features, and similar implementation steps in different embodiments will not be repeated.

[0031] This disclosure provides a method executed by an electronic device, such as... Figure 1 As shown, the method includes: Step S110: Obtain the text to be processed and at least one sample, wherein each sample includes at least a question and an answer; In this embodiment of the disclosure, the text to be processed refers to the task instruction provided by the user to be processed by the large language model. Optionally, the text to be processed may include specific task content or task description input by the user, such as a question asked by the user to the large language model (also known as an inquiry). Optionally, the text to be processed may include information related to the processing effect desired by the user, such as explicit constraints to limit the output of the large language model to meet the constraints, or examples of processing effects desired by the user, so that the large language model can imitate the effect of the examples to output a response (also known as a reply). This embodiment of the disclosure does not specifically limit the content of the text to be processed.

[0032] In this embodiment of the disclosure, at least one sample may be provided by the user, such as the example above; or, at least one sample may be constructed in real time based on the text to be processed; or, at least one sample may be pre-constructed and selected based on the text to be processed, etc. This embodiment of the disclosure does not specifically limit the source of at least one sample.

[0033] In this embodiment of the disclosure, each sample of at least one sample may include any question and a corresponding answer. Optionally, some or all of the samples may include constraints. Optionally, the constraints included in the samples may be the same as the constraints in the text to be processed, in order to achieve better control accuracy of the large language model.

[0034] Step S120: Using a large language model, based on at least one sample, determine the first control vector of the constraints for at least one network in the large language model; In the embodiments disclosed herein, those skilled in the art can set the large language model used according to the actual situation, and the embodiments disclosed herein do not impose any limitations.

[0035] In this embodiment of the disclosure, at least one sample is input into a large language model to accurately find the control vector of the constraints. Here, the constraints can be explicit constraints, such as clearly defined constraints; or they can be implicit constraints, such as constraints implied by user-provided samples, both of which can achieve precise control of the large language model.

[0036] In this embodiment, the determined first control vector is for at least one network in the large language model, such as all sub-networks in the large language model, or a network of a specific type, or a network at a specific location, etc. Those skilled in the art can set it according to the actual situation, and this embodiment does not limit it. In particular, by influencing the output mode of at least one network in the large language model through the first control vector, more precise control of the large language model can be achieved at a finer granular level.

[0037] Step S130: Use a large language model to process the text to be processed, and during the processing, update the activation vector of the corresponding network output in the large language model through at least one first control vector; In practical applications, the text to be processed is input into the large language model, and the various networks of the large language model will output activation vectors for transmission to achieve task processing.

[0038] Therefore, in order to enable the large language model to have an accurate understanding of the constraints and to continuously control the output during the processing, in this embodiment of the disclosure, the first control vector determined in step S120 is equivalent to an additional constraint control layer added to the corresponding network, which is used to update the activation vector of the network output to affect the output of the network, thereby achieving precise control of the network.

[0039] Step S140: Based on the updated activation vector, obtain the processing result of the text to be processed.

[0040] In this embodiment of the disclosure, the updated activation vector is equivalent to an activation vector with precise constraints. Based on this, the processing result of the text to be processed can accurately meet the user's constraint requirements.

[0041] Therefore, the method executed by an electronic device provided in this disclosure finds precise control vectors for constraints on at least one network in a large language model, and uses these precise control vectors to intervene in its internal networks during inference, thereby controlling the output of the large language model at a finer granularity, so that the processing result of the text to be processed can accurately meet the user's constraint requirements.

[0042] Furthermore, the method performed by the electronic device provided in this embodiment can accurately understand the constraints even when the length of the text to be processed provided by the user is long. Moreover, through fine control of at least one network in the large language model, the influence of the constraints on the generated content can be kept from being weakened, so that the output of the large language model always approaches (does not deviate from) the constraints, thereby obtaining a satisfactory answer from the user.

[0043] In this disclosure, several structural examples of large language models are provided: Example 1: such as Figure 2 As shown, a Large Language Model (LLM) can include at least one hidden layer, such as 32 layers. Each hidden layer includes at least one attention head network, such as 8. Different attention head networks extract different features; for example, low-level attention head networks extract grammatical and syntactic information, while high-level attention head networks extract deeper semantic information such as semantics and style. The text to be processed is input into the LLM, and the final activation vector output by the LLM is processed... softmax This will give you the processing result of the text to be processed. It can also be used for subsequent tasks.

[0044] Example 2: Based on Example 1, such as Figure 3 As shown, each attention head network includes a key (K) network, a query (Q) network, and a value (V) network. Figure 3 The output in the expression is the activation vector output by the attention head network.

[0045] In this embodiment of the disclosure, the above-mentioned at least one network in the large language model may refer to at least one of one or more attention head networks, key networks, query networks, value networks, and the last network. That is, in step S130, the activation vector output by the corresponding network in the large language model is updated through at least one first control vector, including at least one of the following situations. (1) Update the activation vector output by the corresponding attention head network using the first control vector corresponding to at least one attention head network; For example, the first control vector can be determined and updated for each attention head in each hidden layer, or the first control vector can be determined and updated for some attention heads in all hidden layers, or all attention heads in some hidden layers, or some attention heads in some hidden layers. Those skilled in the art can set the attention head network that needs to be precisely controlled according to the actual situation, and the embodiments disclosed herein are not limited thereto.

[0046] (2) Update the activation vector output by the corresponding key network using the first control vector corresponding to at least one key network; This step is optional. Similarly, those skilled in the art can configure the key network that requires precise control according to actual conditions, and the embodiments disclosed herein are not limited thereto.

[0047] (3) Update the activation vector output by the corresponding query network using the first control vector corresponding to at least one query network; This step is optional. Similarly, those skilled in the art can configure the query network that requires precise control according to actual circumstances, and this disclosure does not limit the scope of the embodiments.

[0048] (4) Update the activation vector output by the corresponding value network using the first control vector corresponding to at least one value network; This step is optional. Similarly, those skilled in the art can configure the query network that requires precise control according to actual circumstances, and this disclosure does not limit the scope of the embodiments.

[0049] Since the QKV network in the attention head network is a relatively sophisticated and basic neural network, it is more likely to be sensitive to constraints.

[0050] In one example, for a given hidden layer, the constraint control layer updates the activation vectors of all attention heads in the current layer (corresponding to...). Figure 3 (average weight), and its internal Q, K and V (e.g. Figure 3 The activation vector shown is not limited to this.

[0051] (5) The activation vector output by the last network (which can also be understood as the activation vector output by the large language model, and may be referred to as the final activation vector below for ease of description) is updated using the first control vector corresponding to the last network of the large language model.

[0052] Those skilled in the art can set whether the final activation vector needs to be precisely controlled according to the actual situation, and the embodiments disclosed herein do not impose any limitations.

[0053] As described above, users typically encounter two scenarios when using large language models. One scenario involves explicit constraints, such as "output in a humorous style" or "output content should be around 50 characters long." The other scenario involves users who don't know how to describe the constraints, only having some examples. For instance, in a summarizing task, users may only have high-quality summarizing examples but don't know how to explicitly describe the constraints to achieve the desired effect. Similarly, in a tone shifting task, users may feel that a sentence describing the target object fits the current context but are unsure of the specific style of the current text. To address these two scenarios, this disclosure provides optional implementation methods for step S120, specifically: Step SA: If the text to be processed includes constraints, determine the first control vector of the constraints on at least one network in the large language model based on the relationship between at least one sample and the constraints. In this embodiment of the disclosure, when there are explicit constraints, a first control vector for the large language model is found that has explicit constraints. This first control vector can also be understood as an explicit control vector.

[0054] Specifically, since the first control vector is information that characterizes how the constraints affect the large language model's answer, the first control vector can be implied in the relationship between at least one sample and the constraints. By calculating the relationship between at least one sample and the constraints, the precise control vector of the current constraints on the large language model can be found.

[0055] Step SB: If the text to be processed includes the target sample but does not include the constraints, determine the first control vector of the constraints for at least one network in the large language model based on the relationship between the text to be processed and the target sample.

[0056] In this embodiment of the disclosure, even when the user does not provide explicit constraints but only provides examples (target samples), the implicit constraints on the first control vector of the large language model can still be found. This first control vector can also be understood as an implicit control vector.

[0057] Similarly, the first control vector for the target sample can be implied in the relationship between it and the text to be processed. Through the relationship between the text to be processed and the target sample, the implicit constraints on the precise control vector of the large language model can be found.

[0058] In this embodiment of the disclosure, an optional implementation method for step SA is provided, which may specifically include: Step SA1: For each sample based on at least one sample, divide the sample into a first text, a second text, and a third text. The first text includes a constraint, a query, and an answer. The second text includes a query and an answer. The third text includes a constraint. Based on the relationship between the activation vectors of the first text, the second text, and the third text output by at least one network, obtain the second control vector of at least one network. In this embodiment of the disclosure, such as Figure 4 As shown, each sample is divided into three types of text (the first text mentioned above (Q&A&C, corresponding to...). Figure 4 Chinese text ①), Second text (Q&A, corresponding to...) Figure 4 Chinese text ②) and third text (C, corresponding to Figure 4 Chinese text ③), respectively input into the large language model, and through the activation vectors of these three types of text ( Figure 4 The example shows the final activation vectors corresponding to the three types of text output by the last network. By understanding the relationship between the constraints, we can find the precise control vector of the current constraints on at least one network in the large language model.

[0059] Understandable Figure 4 The text shown is for illustrative purposes only; the actual content shall prevail. Figure 4 The text examples in this document should not be construed as limiting this disclosure.

[0060] Step SA2: For each of the at least one networks, obtain the first control vector of the network based on the second control vector of the network corresponding to at least one sample.

[0061] In this embodiment of the disclosure, one or more samples may be used. If only one sample is used, the second control vector of at least one network corresponding to that sample can be used as the first control vector of at least one network. If multiple samples are used, the second control vectors of the network corresponding to the multiple samples can be fused for each network in the at least one network, for example, by averaging or weighted averaging, to obtain the first control vector of the network. This embodiment of the disclosure does not specifically limit the fusion method.

[0062] In this embodiment of the disclosure, an optional implementation method is provided for step SA1. Specifically, for each of at least one network, based on the relationship between the activation vectors of the first text, the second text, and the third text output by that network, a second control vector of that network is obtained, which may include: Step SA11: Determine the first difference information between the activation vector of the first text and the activation vector of the second text output by the network; Step SA12: Determine the second difference information between the first difference information and the activation vector of the third text output by the network; Step SA13: Based on the second difference information, obtain the second control vector of the network.

[0063] This method can be called constraint difference analysis, such as Figure 5 As shown, this demonstrates the principle of accurately finding the control vector of constraints through these three types of text. Figure 5 The thick black solid line in the diagram represents the control vector that we are looking for to determine how the constraints affect the model's response.

[0064] As you can see, the first text (text 1) includes the complete constraints, the question and answer, and the control vector (the part with the thick black solid line). The second text (text 2) includes the question and answer but has no constraints. Therefore, subtracting text 2 from text 1 equals the constraints plus the control vector (the part with the thick black solid line). The third text (text 3) includes the constraints. Therefore, subtracting text 2 from text 1 and then subtracting text 3 from text 3 equals the constraints plus the control vector (the part with the thick black solid line) minus the constraints, which equals the control vector (the part with the thick black solid line).

[0065] Combined with a large language model, a sample is divided into three texts, input... Figure 2 Taking the large language model shown as an example, the first... The first layer The activation vector of the first text output by the attention network can be represented as: ;No. The first layer The activation vector of the second text output by the attention network can be represented as: ;No. The first layer The activation vector of the third text output by the attention network can be represented as: . So, for step SA11, the first The first layer The first difference information corresponding to each attention network can be represented as: The first difference information here has two meanings: one is the meaning of the constraint itself in the current attention head network, and the other is the role of the constraint in the entire sample, that is, the control vector of the constraint on the answer.

[0066] For step SA12, the first The first layer The second difference information corresponding to each attention network can be represented as: ,in, The first variable represents the activation vector of the constraint itself in the current attention head network. The second differential information can represent the role of the constraint in the entire sample, that is, the control vector of the constraint on the answer.

[0067] For step SA13, the first The first layer The second control vector corresponding to each attention head network It can be represented as: ——Formula 1.1 in, This means that the current constraint condition applies to the first... The first layer A precise control vector for an attention head network. This can be understood as, if... This indicates that the current constraints are independent of the question and the answer and have no effect on them.

[0068] Similarly, the method for determining the precise control vector of the final activation vector is similar to that of the attention head network, using... Figure 4 Taking a sample as an example, by splitting a sample into three texts, the second control vector of the constraint on the final activation vector can be calculated. The final activation vector of the first text is expressed as... The final activation vector of the second text is represented as The final activation vector of the third text is represented as The second control vector corresponding to the final activation vector can be expressed as: ——Formula 1.2 Similarly, if =0 indicates that the current constraint is independent of the question and the answer and has no effect on them.

[0069] The precise control vectors for other networks in the large language model can be deduced similarly, and will not be repeated here.

[0070] In this embodiment of the disclosure, an optional implementation method is provided for step SB, which may include: if the text to be processed includes a target sample but does not include constraints, determining a first control vector of the constraints for at least one network in the large language model based on the difference between the text to be processed and the target sample.

[0071] In this embodiment of the disclosure, such as Figure 6 As shown, the text to be processed (corresponding to) Figure 6 Ori) and target sample (corresponding to Figure 6 (Target or Tgt in the text) Enter respectively Figure 2The large language model shown uses the activation vectors of these two texts ( Figure 6 The example shown illustrates the final activation vectors corresponding to the two texts output by the last network. The difference between the two can be used to find the precise control vector of the current implicit constraints on at least one network in the large language model.

[0072] Understandable Figure 6 The text shown is for illustrative purposes only; the actual content shall prevail. Figure 6 The text examples in this document should not be construed as limiting this disclosure.

[0073] Specifically, no. The first layer The activation vector of the text to be processed output by the attention network can be represented as: ;No. The first layer The activation vector of the target sample output by the attention head network can be represented as: . So, for step SB, the first... The first layer The first control vector corresponding to each attention head network It can be expressed as: ——Formula 2.1 in, This can represent the impact of implicit constraints in the current network on the original content (text to be processed).

[0074] The first control vector corresponding to the final activation vector output by the large language model It can be expressed as: ——Formula 2.2 in, This can represent the positive control vector of implicit constraints on the entire text.

[0075] The first control vectors for other networks in the large language model can be deduced similarly, and will not be repeated here.

[0076] Therefore, even if the user does not know what the explicit constraints are in similar situations, this solution can still accurately find the control vector through the target sample.

[0077] In this embodiment of the disclosure, for two common scenarios when users use a large language model, optional implementation methods are provided for updating the activation vectors of the corresponding networks in the large language model using at least one first control vector in step S130. Specifically: Step SC: If the text to be processed includes constraints, at least one sample includes at least one positive sample, at least one first control vector includes at least one positive control vector corresponding to at least one positive sample, add the corresponding positive control vector to the activation vector of the corresponding network output, and / or, at least one sample includes at least one negative sample, at least one first control vector includes at least one negative control vector corresponding to at least one negative sample, reduce the corresponding negative control vector to the activation vector of the corresponding network output.

[0078] In practical applications, different positive samples and different negative samples can correspond to different basic questions and answers. Positive samples include answers to the basic question with the same constraints, while negative samples include answers to the basic question without constraints.

[0079] In the embodiments of this disclosure, at least one positive control vector corresponding to at least one positive sample and at least one negative control vector corresponding to at least one negative sample can both be obtained using a method similar to step SA.

[0080] As an example, based on Formula 1.0 above, the positive sample in the first... The first layer The positive control vector corresponding to each attention head network It can be represented as: ——Formula 1.3 Similarly, negative samples in the 1st The first layer The positive control vector corresponding to each attention head network It can be represented as: ——Formula 1.4 The specific processing procedures and meanings can be found in the above introduction, and will not be repeated here.

[0081] In this embodiment of the disclosure, precise control of the large language model can be achieved by referring to at least one positive sample, and a corresponding positive control vector can be added to the activation vector output by the corresponding network. For example, the first positive control vector is used to control the large language model. The first layer The update process of the positive control vector of an attention head network can be represented as follows: ——Formula 3.1 in, Indicates the first The first layer The original activation vectors of the attention head network (the activation vectors corresponding to the text to be processed); Indicates the first The first layer The updated activation vector of the attention head network; This indicates that the current constraint condition is in the [number]th [year]. The first layer The positive control vector is the result of fusing all positive samples from an attention head network (e.g., by averaging).

[0082] In this embodiment of the disclosure, at least one negative sample can also be referenced for precise control of the large language model, reducing the corresponding negative control vector on the activation vector output by the corresponding network. For example, the first... The first layer The update process of the negative control vector of an attention head network can be represented as follows: ——Formula 3.2 in, Indicates the first The first layer The original activation vectors of the attention head network; Indicates the first The first layer The updated activation vector of the attention head network; This indicates that the current constraint condition is in the [number]th [year]. The first layer The negative control vector is the result of fusing all negative samples from an attention head network (e.g., by averaging).

[0083] In this embodiment of the disclosure, at least one positive sample and at least one negative sample can also be referenced simultaneously for precise control of the large language model. A corresponding positive control vector is added to the activation vector output by the corresponding network, and a corresponding negative control vector is reduced. For example, the first... The first layer The update process of the positive and negative control vectors of an attention head network can be represented as follows: ——Formula 3.3 in, Indicates the first The first layer The original activation vectors of the attention head network; Indicates the first The first layer The updated activation vector of the attention head network; This indicates that the current constraint condition is in the [number]th [year]. The first layer The positive control vector obtained by fusing all positive samples of an attention head network (e.g., by averaging the samples); This indicates that the current constraint condition is in the [number]th [year]. The first layer The negative control vector is the result of fusing all negative samples from an attention head network (e.g., by averaging).

[0084] In this embodiment of the disclosure, by Figure 7 An example of the semantic space (typically high-dimensional) distribution of an attention head network is given, including the path by which the attention head network changes the activation function through positive and negative samples in the semantic space. Specifically, for the Large Language Model (LLM)... Layer An attention-based network, the activation vector of negative samples. Compared to the original activation vector One more negative control vector The difference, the activation vector of the positive sample Compared to the original activation vector One more positive control vector The difference is determined by the original activation vector. Add positive control vector Subtract the negative control vector This makes the updated activation function closer to the semantic space of positive samples and farther from the semantic space of negative samples, thus accurately achieving the semantic space that the user truly expects (answer). This also helps avoid generating unexpected answers.

[0085] Similarly, the activation vector update methods for the query network, key network, and value network in the attention head network can be similar to those in the attention head network. The following section will use the first... The first layer Taking the activation vector of the query network in an attention-head network as an example, the update process can be represented as follows: ,or ,or The similar meanings and processing procedures will not be repeated here. The update process of the activation vectors of the key network and the value network can be deduced in the same way, and will not be repeated here either.

[0086] Similarly, the final update process of the activation vector can be represented as: ,or ,or etc., among which, This represents the final activation vector of the original (text to be processed) text. This represents the updated final activation vector. and These represent the positive and negative control vectors of the final activation vector, respectively. Their similar meanings and processing procedures will not be repeated here.

[0087] Step SD: If the text to be processed includes target samples but does not include constraints, at least one first control vector includes at least one positive control vector corresponding to the target sample, and the corresponding positive control vector is added to the activation vector output by the corresponding network.

[0088] In this embodiment of the disclosure, the target sample can be understood as a positive sample, which performs positive and precise control on the large language model by adding a corresponding positive control vector to the activation vector output by the corresponding network. For example, the first... The first layer The update process of the positive control vector of an attention head network can be represented as follows: ——Formula 4.1 in, Indicates the first The first layer The original activation vectors of the attention head network; Indicates the first The first layer The updated activation vector of the attention head network; Indicates the target sample at the th The first layer Each attention head network corresponds to a positive control vector.

[0089] Similarly, the activation vector update methods for the query network, key network, and value network in the attention head network can be similar to those in the attention head network. The following section will use the first... The first layer Taking the activation vector of the query network in an attention-head network as an example, the update process can be represented as follows: The similar meanings and processing procedures will not be repeated here. The update process of the activation vectors of the key network and the value network can be deduced in the same way, and will not be repeated here either.

[0090] Similarly, the final update process of the activation vector can be represented as: ,in, This represents the final activation vector of the original (text to be processed) text. This represents the updated final activation vector. This represents the positive control vector of the final activation vector; similar meanings and processing procedures will not be repeated here.

[0091] In this embodiment of the disclosure, optional implementation methods are provided for steps SC and SD. Specifically, a corresponding positive control vector is added to the activation vector output by the corresponding network. This may include adding a corresponding positive control vector of a first proportion to the activation vector output by the corresponding network.

[0092] Similarly, reducing the corresponding negative control vector on the activation vector of the corresponding network output can specifically include reducing the corresponding negative control vector by a second proportion on the activation vector of the corresponding network output.

[0093] Taking formula 3.3 as an example, the first... The first layer The update process of the positive and negative control vectors of an attention head network can be represented as follows: ——Formula 3.4 in, and These represent the intervention strength of the positive control vector and the negative control vector, respectively, corresponding to the first ratio and the second ratio mentioned above.

[0094] Taking formula 4.1 as an example, the first... The first layer The update process of the positive control vector of an attention head network can be represented as follows: ——Formula 4.2 Similarly, the first The first layer The update process of the activation vector of the query network in an attention head network can be represented as:

[0095] The final activation vector update process can be represented as:

[0096] The above-mentioned formulas can be deduced in the same way, and will not be repeated here.

[0097] in, and The value can be set by those skilled in the art according to the actual situation, such as all values ​​being 0.5, or it can be calculated in real time based on the text to be processed and / or the sample situation. This disclosure embodiment describes... and The value is not specifically limited.

[0098] In this embodiment of the disclosure, an optional implementation method is provided for updating the activation vector of the corresponding network output in the large language model by using at least one first control vector in step S130. Specifically, when the absolute value of the first control vector is greater than the first threshold of the corresponding network, the activation vector of the corresponding network output is updated.

[0099] The first threshold of the corresponding network represents the network's sensitivity to constraints. Since different networks focus on different features, in order to avoid causing additional interference, the activation vector of the network will only be updated when the first control vector is greater than the first threshold corresponding to the network.

[0100] Considering that each network has a different sensitivity to the current constraints, a sensitivity threshold (first threshold) can be calculated for each network.

[0101] Taking formula 3.3 as an example, the first... The first layer The update process of the positive and negative control vectors of an attention head network can be represented as follows: ——Formula 3.5 in, Indicates the first The first layer The first threshold of the attention head network.

[0102] For formula 3.5, the corresponding operation can be executed if either of the two conditions is met. As an example, in... and If all conditions are met, execute. Operation, in When satisfied, execute. The operation, in When satisfied, execute. The operation can also be represented as at least one of the following:

[0103] The relationships between conditions and operations in other networks can be deduced similarly and will not be repeated here.

[0104] Taking formula 4.1 as an example, the first... The first layer The update process of the positive control vector of an attention head network can be represented as follows: ——Formula 4.3 in, Indicates the first The first layer The first threshold of an attention head network is defined as follows: if the absolute value of the first control vector of the attention head network is greater than the first threshold, it indicates that the attention head network is sensitive to the constraints; otherwise, the attention head network that is not sensitive to the constraints can be frozen.

[0105] Similarly, the first The first layer The update process of the activation vector of the query network in an attention head network can be represented as at least one of the following:

[0106] in, Indicates the first The first layer The first threshold of the query network in an attention-oriented network.

[0107] The above-mentioned formulas can be deduced in the same way, and will not be repeated here.

[0108] In this embodiment of the disclosure, an optional implementation method for determining the first threshold is provided, which specifically may include the following steps: Step S210: Obtain at least one similar text pair; In this embodiment of the disclosure, the content and source of at least one similar text pair are not specifically limited.

[0109] Step S220: For at least one similar text pair, use a large language model to process the similar text pair respectively, and in the process, based on the activation function corresponding to the similar text pair output by at least one network in the large language model, obtain the second threshold corresponding to at least one network. Taking a similar text pair as an example, such as Figure 8 As shown, the similar text pairs (corresponding to) Figure 8 The text in Ini and the text in Sim) are entered respectively. Figure 2 The large language model shown can be used to find the sensitivity threshold (second threshold) of at least one network in the large language model to the constraints through the activation vectors of these two texts.

[0110] Understandable Figure 8 The text shown is for illustrative purposes only; the actual content shall prevail. Figure 8 The text examples in this document should not be construed as limiting this disclosure.

[0111] Step S230: For each of the at least one networks, obtain the first threshold of the network based on the second threshold of the network corresponding to at least one similar text pair.

[0112] Optionally, a large number of similar text pairs can be used to calculate the first threshold for each network.

[0113] Optionally, the first threshold of the network is obtained by averaging the second thresholds of at least one similar text pair corresponding to the network.

[0114] In this embodiment of the disclosure, an optional implementation method is provided for step S220. Specifically, obtaining the second threshold of the network based on the activation functions corresponding to the similar text pairs output by any network may include: Step S221: Determine the third difference information between the activation functions corresponding to similar text pairs output by any network; Step S222: Based on the absolute value of the third difference information, obtain the second threshold of the network.

[0115] In this embodiment of the disclosure, a large language model is used to input a similar text pair. Figure 2 Taking the large language model shown as an example, the first... The first layer The activation function of a similar text output by an attention-focused network can be expressed as follows: and .

[0116] Therefore, for step S221, the first The first layer The third difference information corresponding to each attention head network can be represented as: ——Formula 5 For step S242, the first The first layer The second threshold corresponding to each attention head network can be expressed as: .

[0117] In this embodiment of the disclosure, an optional implementation method is provided for step S210, which specifically may include the following steps: Step S211: Obtain at least one text; Step S212: Translate at least one text from the first language to the second language to obtain at least one second language text; Step S213: Translate at least one second-language text back to the first language to obtain at least one similar text.

[0118] This process can also be understood as generating a similar text library. In this embodiment of the disclosure, several similar text pairs are constructed using reverse translation.

[0119] In practical applications, those skilled in the art can set the first and second languages ​​according to the actual situation, and the embodiments disclosed herein are not limited thereto.

[0120] In one example, such as Figure 9 As shown, this illustrates the process of generating English (first language) similar text using an English-Korean translation model. First, the initial text is translated into Korean (second language) using the English-Korean translation model, and then translated back into English using the Korean-English translation model. The newly generated English text and the initial English text form a similar text pair.

[0121] Understandable Figure 9 The text content and language shown are for illustrative purposes only; the actual content and language shall prevail in the actual implementation. Figure 9 The text examples in this document should not be construed as limiting this disclosure.

[0122] In this embodiment of the disclosure, for cases where the text to be processed includes constraints, an optional implementation method for obtaining at least one sample is also provided. Specifically, it may include: constructing a sample library based on at least one of the following methods, and obtaining at least one sample based on the sample library: (1) Using an arbitrarily large language model, based on at least one question and constraint, obtain at least one first answer; based on at least one question, constraint and at least one answer, obtain at least one positive sample; using an arbitrarily large language model, based on at least one question, obtain at least one second answer; based on at least one question and at least one second answer, obtain at least one negative sample. The large language model used when constructing the sample library may be different from the large language model used in any of the above embodiments. For example, a large language model with a large number of parameters and better performance may be used, such as an online large language model. This disclosure does not limit the specific implementation of the embodiment.

[0123] Since the same constraints have the same semantic space impact on different problems, we can prepare several basic questions, such as asking about the weather or explaining being late for an appointment.

[0124] As an example, such as Figure 10 As shown, inputting the constraints and the question together into the online large language model results in a positive response, allowing positive samples to be constructed based on the question, constraints, and positive response. Inputting the question (without constraints) directly into the online large language model results in a negative response, allowing negative samples to be constructed based on the question, constraints, and negative response.

[0125] (2) Obtain at least one original sample provided by the user, use an arbitrary large language model, and filter at least one original sample based on the judgment instruction to obtain at least one sample.

[0126] In this embodiment of the disclosure, users can provide samples. For example, answers that users like are considered positive samples, answers that they dislike are considered negative samples, or satisfactory or unsatisfactory answers collected by users through other methods.

[0127] To prevent users from providing data that does not meet the constraints, or that is illegal or unethical, thus causing chaos in the existing sample database, this embodiment of the disclosure adds a sample filtering module to filter out low-quality samples. The sample filtering module determines whether a sample meets the requirements by writing a judgment instruction (such as a security judgment instruction) and using a large language model. The large language model used for judgment can be the same as or different from the large language model used in any of the above embodiments, and this embodiment of the disclosure does not limit it.

[0128] As an example, such as Figure 11 As shown, the sample data and security judgment instructions provided by the user (used to determine whether the sample meets the constraints, legal and ethical requirements) are input into the online large language model for judgment. If the requirements are met, the sample is added to the sample library. If the requirements are not met, feedback is provided to the user for the sample that fails the judgment.

[0129] Alternatively, both of the above methods can be used to filter samples when constructing the sample library, such as... Figure 12 As shown, samples can be generated by LLM or provided by users. To prevent the addition of unreasonable samples, such as unethical or dangerous sample data, the sample filtering module can be used to filter the samples to obtain the sample library.

[0130] Furthermore, in this embodiment of the present disclosure, after step S140, the text to be processed, the constraints, and the processing result can be treated as a sample to be processed. Using an arbitrary large language model, the sample to be processed is judged based on the judgment instruction. If it meets the requirements, the sample to be processed is added to the sample library.

[0131] In this embodiment of the disclosure, by constructing a sample library, users can adjust the sample library in real time and dynamically control the model output without retraining the model. Furthermore, the model can be deployed on a device, allowing users to build their own personalized sample libraries without affecting other users.

[0132] In this embodiment of the disclosure, the constructed sample library may include samples corresponding to different constraints. After the user inputs the text to be processed, at least one sample with the same constraints can be obtained from the sample library based on the constraints included in the text to be processed, and then the subsequent precise control processing can be performed.

[0133] Based on at least one of the above embodiments, this disclosure provides a complete architecture for a precise control method for large language models, such as... Figure 13As shown, it includes a sample library construction module, a precise control vector module, a constraint control update module within the large language model, and a final activation vector update module. The specific operation steps include: Step S13.1: Use the sample library construction module to construct positive and negative samples for the first occurrence of the constraint; Step S13.2: Using the precise control vector module, for the text to be processed provided by the user, the precise control vector of the constraint conditions is found through constraint difference analysis using positive and negative samples, or the precise control vector of the implicit constraint conditions is found using the target sample and the text to be processed provided by the user. Step S13.3: Using the constraint control update module, with the help of a similar text library, update the activation vector of the attention head network in the large language model based on the precise control vector; Step S13.4: Using the final activation vector update module, with the help of a similar text library, update the final activation vector of the large language model based on the precise control vector; Step S13.5: Based on the updated final activation vector, perform softmax and output the processing result of the text to be processed. .

[0134] The specific processing steps for each step can be found in the descriptions of the embodiments above, and will not be repeated here.

[0135] The large language model precise control method provided in this disclosure finds the precise control vector constraining the output of the large language model through constraint difference analysis, without introducing noise vectors.

[0136] The large language model precise control method provided in this disclosure can accurately avoid outputting unwanted answers to users by introducing negative samples (an effect that cannot be achieved by controlling the large language model using prompt words). For example, users often seek multiple different answers to a question.

[0137] The large language model precision control method provided in this disclosure can introduce activation vector updates of different granularities by updating the finest network and the final activation vector of the large language model, making the update results more effective and reasonable.

[0138] In this embodiment of the disclosure, for situations with explicit constraints, a process example for precise control of a large language model is provided, such as... Figure 14 As shown, the specific process includes: Step S14.1: Retrieve positive and negative samples corresponding to the constraint in the sample library. If no samples are found, construct positive and negative samples using a large language model with several general problems. The construction of positive samples consists of a general problem, constraints, and the output of the large language model. Negative samples consist of a general problem and the model output, without constraint requirements. After passing through the sample filtering module, add them to the sample library. Step S14.2: Calculate the positive and negative control vectors of the constraints through difference analysis; Step S14.3: During inference, update the attention head network of each layer of the large language model, its internal activation vectors, and the final activation vector of the model to obtain the answer output by the large language model; Step S14.4: If the user is satisfied with the answer, add it to the sample library as a positive sample; if the user is not satisfied with the answer, add it to the sample library as a negative sample, so that the next answer is far removed from the content of this output.

[0139] In this embodiment of the disclosure, for situations where there are no explicit constraints, a process example for precise control of a large language model is provided, such as... Figure 15 As shown, the specific process includes: Step S15.1: For user-provided samples (which can be understood as positive samples), the sample validity filtering module determines their validity. If they are invalid, the sample is ignored. Step S15.2: Use difference analysis to calculate the implicit constraint control vector from the user-provided sample.

[0140] Step S15.3: During inference, update the attention head network of each layer of the large language model, its internal activation vectors, and the final activation vector of the model to obtain the answer output by the large language model.

[0141] The large language model precise control scheme provided in this embodiment can accurately find the precise control vector of the large language model by constructing positive and negative samples when the user has explicit constraints, so that the answer meets the constraints; when the user does not have explicit constraints, only samples are provided, and the implicit constraints of the large language model can also be accurately found so that the answer meets the implicit constraints of the samples.

[0142] Through extensive evaluation of the large language model precise control method provided in the embodiments of this disclosure, the inventors of this disclosure discovered that controlling the output of a large language model using prompt words not only fails to meet constraints but also results in most sentences being very short and containing very little information. In contrast, the large language model precise control method provided in the embodiments of this disclosure not only accurately meets the constraints but also contains significantly more information.

[0143] The technical solutions provided in this disclosure can be applied to various electronic devices capable of deploying large language models, including but not limited to mobile terminals and smart terminals, such as smartphones, tablets, laptops, smart wearable devices (e.g., watches, glasses), smart speakers, in-vehicle terminals, personal digital assistants, portable multimedia players, navigation devices, etc., but are not limited thereto. Those skilled in the art will understand that, in addition to components specifically designed for mobile purposes, the constructions according to the embodiments of this disclosure can also be applied to fixed-type terminals, such as digital televisions and desktop computers.

[0144] The technical solutions provided in this disclosure can also be applied to the control of large language models in servers, such as independent physical servers, server clusters or distributed systems composed of multiple physical servers, or cloud servers that provide basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communication, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms.

[0145] Optionally, the large language model control scheme provided in this disclosure can also be completed collaboratively by multiple electronic devices with computing capabilities. For example, different electronic devices may each complete a portion of the steps of the methods provided in this disclosure. As an example, sample library construction may be performed by one electronic device, and large language model control may be performed by another electronic device, etc., but this is not limited to these examples.

[0146] This disclosure also provides an electronic device including a processor, and optionally, a transceiver and / or memory coupled to the processor, the processor being configured to perform the steps of the method provided in any optional embodiment of this disclosure.

[0147] Figure 16 The diagram shows a structural schematic of an electronic device to which an embodiment of the present invention applies, such as... Figure 16 As shown, Figure 16 The illustrated electronic device 4000 includes a processor 4001 and a memory 4003. The processor 4001 and the memory 4003 are connected, for example, via a bus 4002. Optionally, the electronic device 4000 may further include a transceiver 4004, which can be used for data interaction between the electronic device and other electronic devices, such as sending and / or receiving data. It should be noted that in practical applications, the transceiver 4004 is not limited to one type, and the structure of the electronic device 4000 does not constitute a limitation on the embodiments of this disclosure. Optionally, the electronic device may be a first network node, a second network node, or a third network node.

[0148] Processor 4001 may be a CPU (Central Processing Unit), a general-purpose processor, a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field Programmable Gate Array), or other programmable logic devices, transistor logic devices, hardware components, or any combination thereof. It may implement or execute the various exemplary logic blocks, modules, and circuits described in conjunction with this disclosure. Processor 4001 may also be a combination that implements computational functions, such as including one or more microprocessor combinations, a combination of a DSP and a microprocessor, etc.

[0149] Bus 4002 may include a pathway for transmitting information between the aforementioned components. Bus 4002 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. Bus 4002 can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 16 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0150] The memory 4003 may be ROM (Read Only Memory) or other types of static storage devices capable of storing static information and instructions, RAM (Random Access Memory) or other types of dynamic storage devices capable of storing information and instructions, or EEPROM (Electrically Erasable Programmable Read Only Memory), CD-ROM (Compact Disc Read Only Memory) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, other magnetic storage devices, or any other medium capable of carrying or storing computer programs and capable of being read by a computer, without limitation herein.

[0151] The memory 4003 is used to store computer programs that execute embodiments of the present disclosure, and is controlled by the processor 4001 to execute them. The processor 4001 is used to execute the computer programs stored in the memory 4003 to implement the steps shown in the foregoing method embodiments.

[0152] This disclosure provides a computer-readable storage medium storing a computer program, which, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.

[0153] This disclosure also provides a computer program product, including a computer program that, when executed by a processor, can implement the steps and corresponding content of the aforementioned method embodiments.

[0154] The terms “first,” “second,” “third,” “fourth,” “1,” “2,” etc. (if present) in the specification, claims, and accompanying drawings of this disclosure are used to distinguish similar objects and are not necessarily used to describe a particular order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this disclosure described herein can be implemented in a sequence other than that shown in the figures or text.

[0155] It should be understood that although arrows indicate various operation steps in the flowcharts of the embodiments of this disclosure, the order in which these steps are implemented is not limited to the order indicated by the arrows. Unless explicitly stated herein, in some implementation scenarios of the embodiments of this disclosure, the implementation steps in each flowchart can be executed in other orders as required. Furthermore, some or all of the steps in each flowchart may include multiple sub-steps or multiple stages based on the actual implementation scenario. Some or all of these sub-steps or stages can be executed at the same time, and each sub-step or stage can also be executed at different times. In scenarios where execution times differ, the execution order of these sub-steps or stages can be flexibly configured as required, and the embodiments of this disclosure do not limit this.

[0156] The above text and accompanying drawings are provided as examples only to help the reader understand this disclosure. They are not intended and should not be construed as limiting the scope of this disclosure in any way. Although certain embodiments and examples have been provided, it will be apparent to those skilled in the art, based on the content disclosed herein, that changes can be made to the illustrated embodiments and examples, and other similar implementations based on the technical concept of this disclosure can be adopted without departing from the scope of this disclosure, and these modifications and modifications are also within the protection scope of the embodiments of this disclosure.

Claims

1. A method performed by an electronic device, the method comprising: include: Obtain the text to be processed and at least one sample, wherein each sample includes at least a question and an answer; Using a large language model, based on the at least one sample, determine a first control vector for constraints on at least one network in the large language model; The large language model is used to process the text to be processed, and during the processing, the activation vector of the corresponding network output in the large language model is updated by at least one first control vector. Based on the updated activation vector, the processing result of the text to be processed is obtained.

2. The method according to claim 1, characterized in that, Determining the first control vector of constraints on at least one network in the large language model based on the at least one sample includes at least one of the following: If the text to be processed includes constraints, a first control vector for the constraints on at least one network in the large language model is determined based on the relationship between at least one sample and the constraints. If the text to be processed includes a target sample but does not include constraints, a first control vector for the constraints on at least one network in the large language model is determined based on the relationship between the text to be processed and the target sample.

3. The method according to claim 2, characterized in that, The step of determining the first control vector of the constraints on at least one network in the large language model based on the relationship between at least one sample and the constraints includes: For each sample in the at least one sample, the sample is divided into a first text, a second text, and a third text. The first text includes constraints, a question, and an answer. The second text includes a question and an answer. The third text includes constraints. Based on the relationship between the activation vectors of the first text, the second text, and the third text output by the at least one network, a second control vector of the at least one network is obtained. For each of the at least one networks, a first control vector of the network is obtained based on the second control vector of the network corresponding to at least one sample.

4. The method according to claim 1, characterized in that, For each of the at least one network, based on the relationship between the activation vectors of the first text, the second text, and the third text output by that network, a second control vector for that network is obtained, including: Determine the first difference information between the activation vector of the first text and the activation vector of the second text output by the network; Determine the second difference information between the first difference information and the activation vector of the third text output by the network; Based on the second difference information, the second control vector of the network is obtained.

5. The method according to any one of claims 1-4, characterized in that, The activation vectors of the corresponding network outputs in the large language model are updated using at least one first control vector, including at least one of the following: If the text to be processed includes constraints, the at least one sample includes at least one positive sample, the at least one first control vector includes at least one positive control vector corresponding to the at least one positive sample, and the corresponding positive control vector is added to the activation vector output by the corresponding network; and / or, the at least one sample includes at least one negative sample, the at least one first control vector includes at least one negative control vector corresponding to the at least one negative sample, and the corresponding negative control vector is reduced from the activation vector output by the corresponding network. If the text to be processed includes a target sample but does not include constraints, the at least one first control vector includes at least one positive control vector corresponding to the target sample, and the corresponding positive control vector is added to the activation vector output by the corresponding network.

6. The method according to claim 5, characterized in that, Add corresponding positive control vectors to the activation vectors output by the corresponding network, including: Add a corresponding positive control vector of the first proportion to the activation vector output by the corresponding network; And / or, reduce the corresponding negative control vector on the activation vector of the corresponding network output, including: Reduce the corresponding negative control vector by the second proportion on the activation vector output by the corresponding network.

7. The method according to claim 5, characterized in that, The activation vectors of the corresponding network outputs in the large language model are updated using at least one first control vector, including... When the absolute value of the first control vector is greater than the first threshold of the corresponding network, the activation vector output by the corresponding network is updated.

8. The method according to claim 7, characterized in that, Also includes: Obtain at least one similar text pair; For the at least one similar text pair, the large language model is used to process the similar text pairs respectively, and in the process, based on the activation functions corresponding to the similar text pairs output by at least one network in the large language model, a second threshold corresponding to at least one network is obtained; For each of the at least one networks, a first threshold for that network is obtained based on a second threshold corresponding to the at least one similar text pair.

9. The method according to claim 8, characterized in that, Based on the activation functions corresponding to similar text pairs output by any network, the second threshold of the network is obtained, including: Determine the third difference information between the activation functions corresponding to similar text pairs output by any network; The second threshold of the network is obtained based on the absolute value of the third difference information.

10. The method according to claim 8, characterized in that, The step of obtaining at least one similar text pair includes: Get at least one text; Translate the at least one text from a first language to a second language to obtain at least one second language text; Translate the at least one second-language text back into the first language to obtain a similar text to the at least one text.

11. The method according to claim 8, characterized in that, For each of the at least one network, a first threshold for that network is obtained based on a second threshold corresponding to the at least one similar text pair, including: The first threshold of the network is obtained by averaging the second threshold of the network corresponding to the at least one similar text pair.

12. The method according to any one of claims 1-11, characterized in that, The large language model includes at least one hidden layer, each hidden layer includes at least one attention head network, and each attention head network includes a key network, a query network, and a value network. The step of updating the activation vector of the corresponding network output in the large language model through at least one first control vector includes at least one of the following situations; The activation vector output by the corresponding attention head network is updated using the first control vector corresponding to at least one attention head network. The activation vector output by the corresponding key network is updated using the first control vector corresponding to at least one key network. The activation vector output by the corresponding query network is updated using the first control vector corresponding to at least one query network. The activation vector output by the corresponding value network is updated using the first control vector corresponding to at least one value network. The activation vector output by the last network is updated using the first control vector corresponding to the last network of the large language model.

13. The method according to any one of claims 1-12, characterized in that, If the text to be processed includes constraints, the method further includes: A sample library is constructed based on at least one of the following methods, and the at least one sample is obtained based on the sample library: Using an arbitrarily large language model, based on at least one question and constraints, at least one first answer is obtained, and based on the at least one question, constraints and at least one answer, at least one positive sample is obtained; Using an arbitrarily large language model, based on at least one question, obtain at least one second answer, and based on the at least one question and the at least one second answer, obtain at least one negative sample; Obtain at least one original sample provided by the user, and use an arbitrary large language model to filter the at least one original sample based on the judgment instruction to obtain at least one sample.

14. The method according to claim 13, characterized in that, Also includes: After obtaining the processing result of the text to be processed, the text to be processed, the constraints, and the processing result are taken as a sample to be processed. Using an arbitrary large language model, the sample to be processed is judged based on the judgment instruction. If it meets the requirements, the sample to be processed is added to the sample library.

15. An electronic device comprising a memory, a processor, and a computer program stored in the memory, characterized in that, The processor executes the computer program to implement the method according to any one of claims 1-14.

16. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-14.

17. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-14.