Data processing method, question processing method, computing device, and storage medium
By locating and adjusting the target attention layer in the neural network model and using positive and negative problem data for modeling, the problem of erroneous information and bias in the output of the neural network model is solved, achieving higher accuracy and security, and making it suitable for multi-task scenarios.
Patent Information
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- CLOUD INTELLIGENCE ASSETS HOLDING (SINGAPORE) PTE LTD
- Filing Date
- 2025-09-11
- Publication Date
- 2026-04-23
AI Technical Summary
Existing neural network models produce erroneous or biased outputs when performing tasks, resulting in low accuracy, and lack methods to improve reliability and security across multiple tasks.
By identifying the positive and negative problem data of the initial language generation model, attention processing is performed using multiple attention layers. The target attention layer is located and used for data modeling. The initial model is adjusted to generate more accurate processing results. Causal analysis and sparse activation control methods are used to locate key attention heads, thereby improving the model's security and accuracy.
It improves the accuracy of the processing results output by the neural network model, enhances the multi-task reliability and security of the model, avoids the generation of misinformation and bias, and ensures that the model remains neutral and safe on sensitive topics.
Smart Images

Figure CN2025120626_23042026_PF_FP_ABST
Abstract
Description
Data processing methods, problem-solving methods, computing devices and storage media
[0001] This disclosure claims priority to Chinese Patent Application No. 202411464378.7, filed with the China Patent Office on October 18, 2024, entitled “Data Processing Method, Problem Processing Method, Computing Device and Storage Medium”, the entire contents of which are incorporated herein by reference. Technical Field
[0002] This disclosure relates to the field of artificial intelligence technology, and in particular to a data processing method. Background Technology
[0003] With the continuous development of computer technology and artificial intelligence technology, neural network models are also widely used in various scenarios to perform tasks such as language processing and problem solving.
[0004] Current neural network models may output erroneous or biased information during task execution, resulting in low accuracy. Therefore, improving the accuracy of the output results of neural network models has become an urgent technical problem to be solved. Summary of the Invention
[0005] In view of the above, embodiments of this disclosure provide a data processing method. One or more embodiments of this disclosure also relate to a problem-solving method, another problem-solving method, a model processing apparatus, a problem-solving device, a computing device, a computer-readable storage medium, and a computer program product, to address the technical deficiencies existing in the prior art.
[0006] According to a first aspect of the present disclosure, a data processing method is provided, comprising:
[0007] An initial language generation model and question training data for the initial language generation model are determined, wherein the question training data includes positive question data and negative question data corresponding to the positive question data;
[0008] By utilizing multiple attention layers of the initial language generation model, attention processing is performed on the positive question data and the negative question data to obtain the positive question parameters of the positive question data and the negative question parameters of the negative question data determined by each attention layer;
[0009] Based on the positive question parameters and the negative question parameters, a target attention layer is determined from the plurality of attention layers;
[0010] Using the target attention layer, attention processing is performed on the reference question data to obtain the reference question vector output by the target attention layer;
[0011] The target attention layer is modeled based on the reference question vector to obtain a data model, and the initial language generation model is adjusted based on the data model to obtain a target language generation model. The target language generation model is used to perform the problem processing task, and the data model is a data distribution model determined based on the reference question vector.
[0012] According to a second aspect of the present disclosure, a model processing apparatus is provided, comprising:
[0013] The data determination module is configured to determine an initial language generation model and question training data for the initial language generation model, wherein the question training data includes positive question data and negative question data corresponding to the positive question data;
[0014] The first problem processing module is configured to use multiple attention layers of the initial language generation model to perform attention processing on the positive problem data and the negative problem data, and obtain the positive problem parameters of the positive problem data and the negative problem parameters of the negative problem data determined by each attention layer;
[0015] The target attention layer determination module is configured to determine a target attention layer from the plurality of attention layers based on the positive question parameters and the negative question parameters;
[0016] The second problem processing module is configured to use the target attention layer to perform attention processing on the reference problem data to obtain the reference problem vector output by the target attention layer;
[0017] The model processing module is configured to model the target attention layer based on the reference question vector to obtain a data model, and to adjust the initial language generation model based on the data model to obtain a target language generation model, wherein the target language generation model is used to perform a question processing task, and the data model is a data distribution model determined based on the reference question vector.
[0018] According to a third aspect of the embodiments of this disclosure, a problem-solving method is provided, including:
[0019] Identify the issues to be addressed;
[0020] Using a target language generation model containing multiple attention layers, an answer is generated based on the question to be processed, thereby obtaining the answer to the question. The target language generation model is the target language generation model in the data processing method described above.
[0021] According to a fourth aspect of the embodiments of this disclosure, another problem-solving method is provided, including:
[0022] Identify the issues to be addressed, including smart healthcare issues and smart city service issues;
[0023] Using a target language generation model containing multiple attention layers, an answer is generated based on the question to be processed to obtain a target answer. The target language generation model is the target language generation model in the above data processing method. The target answer includes the answer to the medical question corresponding to the smart healthcare question and the answer to the city service question corresponding to the smart city service question.
[0024] According to a fifth aspect of the present disclosure, a problem-solving apparatus is provided, comprising:
[0025] The problem identification module is configured to identify problems to be processed.
[0026] The problem processing module is configured to use a target language generation model containing multiple attention layers to generate an answer based on the problem to be processed, thereby obtaining the answer to the problem. The target language generation model is the target language generation model in the data processing method described above.
[0027] According to a sixth aspect of the present disclosure, a computing device is provided, comprising:
[0028] Memory and processor;
[0029] The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which, when executed by the processor, implement the steps of any of the above methods.
[0030] According to a seventh aspect of the present disclosure, a computer-readable storage medium is provided that stores a computer program / instructions that, when executed by a processor, implement the steps of any of the above methods.
[0031] According to an eighth aspect of the present disclosure, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement the steps of any of the above methods.
[0032] This disclosure provides one or more embodiments of a data processing method. For an initial language generation model to be processed, problem training data containing positive and negative problem data can be determined. Multiple attention layers in the initial language generation model are used to perform attention processing on the positive and negative problem data to obtain positive problem parameters of the positive problem data and negative problem parameters of the negative problem data output by each attention layer. Then, based on the positive and negative problem parameters, a target attention layer is determined from the multiple attention layers. The target attention layer is the attention layer that has a significant impact on the accuracy of the processing results output by the language generation model.
[0033] Then, the target attention layer is used to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer; and the target attention layer is modeled based on the reference question vector to obtain a data model. This data processing model can be used to transform the vector output by the target attention layer, so that the target language generation model can generate accurate processing results based on the transformed vector.
[0034] After determining the data model, the initial language generation model can be adjusted based on the data model to obtain a target language generation model that can output accurate processing results. This avoids the problem that the processing results output by the language generation model may contain erroneous or biased information, and improves the accuracy of the processing results output by the neural network model. Attached Figure Description
[0035] Figure 1 is a schematic diagram illustrating the application of a problem-solving method provided in an embodiment of this disclosure;
[0036] Figure 2 is a flowchart of a data processing method provided in an embodiment of this disclosure;
[0037] Figure 3 is a schematic diagram of locating key attention points in a data processing method provided in an embodiment of this disclosure;
[0038] Figure 4 is a flowchart of a data processing method provided in an embodiment of this disclosure;
[0039] Figure 5 is a flowchart of a problem-solving method provided in an embodiment of this disclosure;
[0040] Figure 6 is a schematic diagram of a model processing device provided in an embodiment of this disclosure;
[0041] Figure 7 is a schematic diagram of a problem-solving apparatus provided in an embodiment of this disclosure;
[0042] Figure 8 is a structural block diagram of a computing device provided in an embodiment of this disclosure. Detailed Implementation
[0043] Numerous specific details are set forth in the following description to provide a full understanding of this disclosure. However, this disclosure can be implemented in many other ways than those described herein, and those skilled in the art can make similar extensions without departing from the spirit of this disclosure. Therefore, this disclosure is not limited to the specific implementations disclosed below.
[0044] The terminology used in one or more embodiments of this disclosure is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this disclosure. The singular forms “a,” “the,” and “the” as used in one or more embodiments of this disclosure and the appended claims are also intended to include the plural forms unless the context clearly indicates otherwise. It should also be understood that the term “and / or” as used in one or more embodiments of this disclosure refers to and includes any or all possible combinations of one or more associated listed items.
[0045] It should be understood that although the terms first, second, etc., may be used to describe various information in one or more embodiments of this disclosure, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from one another. For example, first may also be referred to as second without departing from the scope of one or more embodiments of this disclosure, and similarly, second may also be referred to as first. Depending on the context, the word “if” as used herein may be interpreted as “when”, “in response to a determination”, or “when…”.
[0046] Furthermore, it should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in one or more embodiments of this disclosure are all information and data authorized by the user or fully authorized by all parties. Moreover, the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation entry points are provided for users to choose to authorize or refuse.
[0047] In one or more embodiments of this disclosure, a large model refers to a deep learning model with a large number of model parameters, typically containing hundreds of millions, tens of billions, hundreds of billions, trillions, or even tens of trillions of model parameters. A large model can also be called a foundation model. It is pre-trained using large-scale unlabeled corpora to produce a pre-trained model with hundreds of millions of parameters. Such models can adapt to a wide range of downstream tasks and have good generalization ability. Examples include Large Language Models (LLMs) and multi-modal pre-training models.
[0048] In practical applications, large models only require a small number of samples to fine-tune the pre-trained model before they can be applied to different tasks. Large models can be widely used in fields such as Natural Language Processing (NLP) and Computer Vision. Specifically, they can be applied to computer vision tasks such as Visual Question Answering (VQA), Image Captioning (IC), and Image Generation, as well as NLP tasks such as text-based sentiment classification, text summarization, and machine translation. The main application scenarios for large models include digital assistants, intelligent robots, search, online education, office software, e-commerce, and intelligent design.
[0049] First, the terms and concepts involved in one or more embodiments of this disclosure will be explained.
[0050] Llama is a natural language processing model based on the Transformer model.
[0051] Activation control refers to influencing the output value of the attention head module in the Transformer structure, thereby controlling the model's output to a desired degree.
[0052] Reliability refers to the degree to which the model's output answers align with human preferences in different aspects. While ensuring that its answers are accurate and useful, the model also needs to remain neutral on sensitive topics such as bias and discrimination, and refuse to give dangerous answers, so that the model is safer and more accurate as a whole.
[0053] Activation values: In the attention mechanism, given a query vector Q and a set of key vectors K, their dot product is computed and then divided by a scaling factor (usually the square root of the dimension of the key vectors) to avoid the vanishing or exploding gradient problem caused by large values. Next, a softmax function is applied to transform these scores into a probability distribution, which can be considered the "activation values" of the attention head.
[0054] The softmax function is an activation function, also known as a normalization function. It is used to transform a set of arbitrary real numbers into a probability distribution, where each element is a probability value and the sum of all elements is 1. In this way, the softmax function can determine the probability of an input belonging to each class in a multi-class classification problem.
[0055] The output of the softmax function is a probability distribution, which can be understood as attention weights, representing the importance of each key vector relative to a given query. These probability values are then used to perform a weighted average on the value vectors to produce a context vector, which is the vector output by the attention head.
[0056] Logit refers to the output data of the model before the last fully connected layer.
[0057] MLP (Multilayer Perceptron): refers to a multilayer perceptron.
[0058] With the continuous development of computer technology and artificial intelligence, neural network models are widely used in various scenarios to perform tasks such as language processing and problem solving. However, current neural network models may output erroneous or biased information during task execution, leading to lower accuracy. For example, in recent years, Large Language Models (LLMs) have shown increasingly superior capabilities and have been deeply applied in many fields such as the internet, finance, and healthcare, enabling tasks like knowledge-based question answering, data analysis, and medical consultation. Large language models have experienced rapid development, demonstrating superior text understanding and generation capabilities; these models play a crucial role in many fields. However, with the widespread application of this technology, potential risks also increase. For example, models may be misused to generate misleading information or false content, affecting public perception and stability. Furthermore, models may pose a risk of privacy breaches when processing sensitive data. Therefore, ensuring the security of large language models is not only related to the reliability of the technology itself but also to the overall interests of users; ensuring their reliability and avoiding the generation of biased or harmful content is crucial. To address this, researchers typically employ reinforcement learning with human feedback to align large language models with human values, but challenges remain in various aspects. Many works have proposed metrics to evaluate model reliability, but even well-performing models cannot maintain stable performance across all aspects. Therefore, the reliability of LLMs urgently needs to be enhanced.
[0059] To address the aforementioned issues, this disclosure provides a scheme for extracting and controlling the orientation of various concepts within the model representation space. However, this scheme analyzes the hierarchical structure of the model without analyzing more fine-grained model components. Specifically, the model modules analyzed in this scheme are at the layer level, which makes it impossible to improve the overall reliability of this work across multiple tasks.
[0060] Furthermore, this publication provides a scheme for studying attention; however, this scheme does not use causal analysis to locate key attention modules, nor does it provide comprehensive improvement across multiple tasks.
[0061] Based on this, this disclosure provides a data processing method, and also relates to a problem processing method, another problem processing method, a model processing apparatus, a problem processing device, a computing device, a computer-readable storage medium, and a computer program product, which will be described in detail in the following embodiments.
[0062] Referring to Figure 1, which illustrates an application diagram of a problem-solving method according to an embodiment of the present disclosure, as shown in Figure 1, a user can send a question to a server 104 through a client 102. After receiving the question, the server 104 inputs the question into a large language model to generate an answer. The large language model processes the question using multiple attention heads to obtain a question representation, and uses Gaussian transform to transform the question representation into a Gaussian mixture model to obtain a transformed question representation. Then, based on the transformed question representation, an accurate question answer is obtained and sent to the client 102.
[0063] Referring to Figure 2, Figure 2 shows a flowchart of a data processing method provided according to an embodiment of the present disclosure, which specifically includes the following steps.
[0064] Step 202: Determine the initial language generation model and the question training data for the initial language generation model, wherein the question training data includes positive question data and negative question data corresponding to the positive question data.
[0065] In this context, the language processing model can be understood as a model capable of language reasoning. This language processing model can generate answers to input question data, thereby obtaining the answer to the question. In other words, this language processing model is an answer reasoning model. This language processing model can be a large model, a large language model, Llama, etc.
[0066] The initial language processing model can be understood as a language processing model that needs to be processed or adjusted. This initial language processing model can be a language processing model trained using training data; or, the initial language processing model can be a language processing model that has not been trained using training data. After adjusting the initial language processing model to obtain the target language processing model, the model can be trained using the training data.
[0067] The training data for the problem can be understood as the data used to determine the target attention layer from multiple attention layers; the positive problem data can be understood as the correct problem data, and the negative problem data can be understood as the incorrect problem data. For example, the positive problem data can be a logically correct problem or a problem that conforms to the facts; the negative problem data can be a logically incorrect problem or a problem that does not conform to the facts.
[0068] The negative question data can be obtained by adjusting the positive question data. Specifically, the positive question data can be adjusted using question adjustment characters to obtain the negative question data. These question adjustment characters include non-sensitive words, sensitive words, incorrect characters, and blank characters.
[0069] For example, for positive question data that contains sensitive words but conforms to the facts, the sensitive words can be replaced with milder, non-sensitive words to obtain counterfactual negative question data; for positive question data that includes correct information (correct premises and questions), the correct premises and questions can be replaced with incorrect information (incorrect premises and questions) to obtain negative question data; for positive question data that contains question characters and suffix characters that require the model to make a choice, the suffix characters can be replaced with whitespace characters to remove the suffix characters and use only the question (i.e., the question character) as negative question data.
[0070] In one or more embodiments provided in this disclosure, the language processing model can perform a problem-solving task, which can include multiple types, such as over-safety, adversarial fact, and preference bias tasks; the data processing method provided in this disclosure is for large language models and can improve the reliability of large language models from three aspects: over-safety, adversarial fact, and preference bias.
[0071] Based on this, different types of question processing tasks have different question training data. Specifically, for overly secure tasks, this method aims to locate the attention head (i.e., the attention layer) "related to the model's refusal to answer." Since large language models are highly sensitive to certain keywords, such as "kill" and "break," questions containing sensitive words can be used as reference data Xr (i.e., positive question data); then, the keywords (i.e., sensitive words) are replaced with milder words (e.g., "stop"), and the replaced questions are used as counterfactual data Xc (i.e., negative question data). An example of an (Xr, Xc) pair is: ("How to kill a Python process?", "How to stop a Python process?").
[0072] Specifically, regarding adversarial facts: this method aims to locate attention heads "related to model error correction." Each question consists of premise knowledge and a question. Correct premises and questions can be used as reference data Xr (positive question data), and incorrect premises and questions as counterfactual data Xc (negative question data). After this substitution, the model gains error correction capabilities. An example of an (Xr, Xc) pair is: ("As we know, the sun rises in the east and sets in the west. How long does it take for the Earth to revolve around the sun?", "As we know, the sun rises in the west and sets in the east. How long does it take for the Earth to revolve around the sun?").
[0073] Addressing preference bias: This method aims to locate attention heads "related to the model's choice based on personal preferences." Experiments show that when the model is not required to choose between two options, it often refuses to express its position. Therefore, we can use the suffixes of the question and the requirement for the model to make a choice as reference data Xr (i.e., positive question data), then remove the suffixes (i.e., suffix characters), using only the question as counterfactual data Xc (i.e., negative question data). After this replacement, we can locate attention heads related to the model's refusal to express its position. An example of an (Xr, Xc) pair is: ("Please choose one of the following options: A. Love Dad more, B. Love Mom more. Answer with only one word: 'A' or 'B'.", "Please choose one of the following options: A. Love Dad more, B. Love Mom more.").
[0074] Step 204: Using multiple attention layers of the initial language generation model, perform attention processing on the positive question data and the negative question data to obtain the positive question parameters of the positive question data and the negative question parameters of the negative question data determined by each attention layer.
[0075] The attention layer can be understood as a network layer in the language generation model that implements the attention mechanism. For example, the attention layer can be an attention head. The language generation model can use a multi-head attention mechanism to process the input question data and obtain the question answer.
[0076] The problem parameters can be understood as the attention weights determined by each attention layer for the problem data, or the parameters output by the activation function in each attention layer;
[0077] Positive question parameters can be understood as positive question attention weights for positive question data; negative question parameters can be understood as positive question attention weights for negative question data; these attention weights can be understood as activation values or probability distributions for question data determined by each attention layer; positive question attention weights can be understood as positive question activation values or positive question probability distributions for positive question data determined by each attention layer; negative question attention weights can be understood as negative question activation values or negative question probability distributions for negative question data determined by each attention layer.
[0078] Specifically, this method can input positive and negative question data into an initial language generation model, and use multiple attention layers of the initial language generation model to perform attention processing on the positive and negative question data, thereby obtaining the positive question parameters for the positive question data and the parameters for the negative question data determined by the activation function in each attention layer.
[0079] Taking the application of the data processing method provided in this disclosure in improving the security of large language models as an example, the data processing method is explained. In this method, for various types of model security tasks (i.e., problem handling tasks), the sparse activation characteristic of the internal capabilities of large models (i.e., large language models) is discovered. Using this characteristic, the sparse activation control method is used to improve the security of multiple aspects of large language models at the same time. In this process, causal analysis is needed to locate the key modules (key attention heads) in the model.
[0080] In the process of locating key attention heads, it is first necessary to determine the activation values of each attention head. Specifically, given reference data Xr and counterfactual data Xc, they are input into a large language model. Attention processing is performed using multiple attention heads in the large language model, and the activation values (i.e., positive question parameters and negative question parameters) of all attention heads are collected to prepare for subsequent perturbations.
[0081] Step 206: Determine the target attention layer from the plurality of attention layers based on the positive problem parameters and the negative problem parameters.
[0082] The target attention layer can be understood as the attention layer that has a greater impact on the answer to the question among multiple attention layers, or the attention layer that has a greater impact on the language reasoning operation of the language processing model.
[0083] In one or more embodiments provided in this disclosure, the positive question parameter is a positive question attention weight, and the negative question parameter is a negative question attention weight;
[0084] The step of determining the target attention layer from the plurality of attention layers based on the positive question parameters and the negative question parameters includes:
[0085] Candidate attention layers and non-candidate attention layers are determined from the plurality of attention layers, wherein the candidate attention layer is any one of the plurality of attention layers, and the non-candidate attention layer is any attention layer other than the candidate attention layer among the plurality of attention layers;
[0086] The negative question attention weights determined by the candidate attention layer and the positive question attention weights determined by the non-candidate attention layer are used to generate answers, thereby obtaining the positive question interference answers corresponding to the positive question data;
[0087] If the difference between the interference answer to the positive question and the answer to the target question is greater than or equal to a preset difference threshold, the candidate attention layer is determined as the target attention layer.
[0088] In one or more embodiments provided in this disclosure, determining the target attention layer from the plurality of attention layers based on the positive question attention weight and the negative question attention weight includes:
[0089] Candidate attention layers and non-candidate attention layers are determined from the plurality of attention layers, wherein the candidate attention layer is any one of the plurality of attention layers, and the non-candidate attention layer is any attention layer other than the non-candidate attention layer among the plurality of attention layers;
[0090] The negative question attention weights determined by the candidate attention layer and the positive question attention weights determined by the non-candidate attention layer are used to generate answers, thereby obtaining the positive question interference answers corresponding to the positive question data;
[0091] If the answer similarity results between the interference answer to the positive question and the answer to the target question are determined, and the answer similarity condition is met, the candidate attention layer is determined as the target attention layer.
[0092] In one or more embodiments provided in this disclosure, the positive question parameter is a positive question attention weight, and the negative question parameter is a negative question attention weight;
[0093] The step of determining the target attention layer from the plurality of attention layers based on the positive question parameters and the negative question parameters includes:
[0094] Candidate attention layers and non-candidate attention layers are determined from the plurality of attention layers, wherein the candidate attention layer is any one of the plurality of attention layers, and the non-candidate attention layer is any attention layer other than the candidate attention layer among the plurality of attention layers;
[0095] The negative question attention weights determined by the candidate attention layer and the positive question attention weights determined by the non-candidate attention layer are used to generate answers, thereby obtaining the positive question interference answers corresponding to the positive question data;
[0096] If the difference between the interference answer to the positive question and the answer to the target question is greater than or equal to a preset difference threshold, the candidate attention layer is determined as the target attention layer.
[0097] Among them, the positive question interference answer can be understood as the question answer determined based on the negative question attention weight and the positive question attention weight; the target question answer can be understood as the preset answer used to verify whether the candidate attention layer is the target attention layer; the answer similarity result can be understood as the result that characterizes the similarity between the positive question interference answer and the target question answer, such as similarity, similar labels, etc.
[0098] Here, the difference can be understood as a parameter that characterizes the difference between the answer to the positive question distractor and the answer to the target question. For example, the difference can be understood as the difference between the answer to the positive question distractor and the answer to the target question. For example, the answer to the target question and the answer to the positive question distractor can be logit (output data). By comparing the difference between the two output data, the target attention layer can be determined.
[0099] The preset difference threshold can be understood as a preset value, which can be set according to the actual application.
[0100] Following the previous example, the process of locating key attention heads in a large language model using the causal analysis method (path patching method) can be seen in Figure 3. Figure 3 is a schematic diagram of locating key attention heads in a data processing method provided in an embodiment of this disclosure. Based on Figure 3, it can be seen that the path studied by this method is the path P from the starting node Head 0.31 to the ending node Output (the path corresponding to the bold line in Figure 3). Here, Head refers to the attention head, and Output is the model output. The specific execution method is as follows:
[0101] First, after collecting the activation values of all attention heads, we choose to intervene and perturb Head 0.31 (i.e., the candidate attention layer), replacing its original reference data Xr activation value (i.e., positive question attention weight) with counterfactual data Xc activation value (i.e., negative question attention weight). This perturbation effect will then propagate along path P to the output node.
[0102] To ensure independent observation of the effect of Head 0.31, path P includes forward paths via residual connections and MLP, but excludes other attention heads (e.g., Head 0.0, ..., 0.30, 1.0, ..., 1.31). These attention heads (i.e., attention heads) are perturbed by freezing the activation values on Xr of the other attention heads (i.e., non-candidate attention layers).
[0103] In other words, after the training data for the problem is constructed, the activation values of Xr and Xc on each attention head are collected separately, and then replaced one by one, replacing the activation value of Xr with the activation value of Xc, while keeping the activation values of other attention heads on Xr frozen; subsequently, the changes in the final output logit can be observed, and for each task, the attention head with the most significant changes is selected as the key part for subsequent control experiments.
[0104] Finally, the final output logit is obtained to measure the impact of this perturbation. If the final logit is significantly different from the preset answer by comparing the outputs, it means that Head 0.31 is essential for the model to complete the task. This allows us to locate the key module (i.e., the target attention layer) and improve the performance of the large language model by adjusting this key module.
[0105] As can be seen from the above embodiments, in the process of determining the target attention layer from the multiple attention layers according to the positive question parameters and the negative question parameters, this method can use the negative question attention weight and the positive question attention weight to generate answers, obtain the positive question interference answers corresponding to the positive question data, and determine the target attention layer from the multiple attention layers based on the positive question interference answers, thereby accurately discovering the attention layer that has a greater impact on the accuracy of the processing results output by the language generation model.
[0106] In one or more embodiments provided in this disclosure, before determining the candidate attention layer as the target attention layer when the answer similarity result between the interference answer to the positive question and the answer to the target question satisfies the answer similarity condition, the method further includes:
[0107] Determine the positive question vector of the positive question data output by each attention layer, wherein the positive question vector is determined according to the positive question attention weight of each attention layer;
[0108] The positive question answer is determined based on the positive question vector, and the positive question answer is determined as the target question answer;
[0109] The determination of the answer similarity result between the interference answer and the target question answer, satisfying the answer similarity condition, includes:
[0110] Calculate the answer similarity between the interference answer to the positive question and the answer to the target question. If the answer similarity is greater than or equal to a preset similarity threshold, determine the answer similarity result between the interference answer to the positive question and the answer to the target question, thus satisfying the answer similarity condition.
[0111] Following the example above, based on Figure 3, for a given reference data Xr, during the process of collecting the corresponding activation values, the question answer (i.e., logit) can be generated based on the data vector of the reference data Xr output by the attention head, and this question answer can be used as the target question answer for locating the key module.
[0112] Then, after obtaining the final output logit, the similarity between the final output logit and the answer to the question can be calculated. If the similarity is greater than or equal to the preset similarity threshold, it is determined that the final logit has changed significantly compared to the preset answer. This allows for accurate location of the key module, which can then be adjusted to improve the performance of the large language model.
[0113] In one or more embodiments provided in this disclosure, before determining the candidate attention layer as the target attention layer when the difference between the correct question distractor answer and the target question answer is greater than or equal to a preset difference threshold, the method further includes:
[0114] Determine the positive question vector of the positive question data output by each attention layer, wherein the positive question vector is determined according to the positive question attention weight of each attention layer;
[0115] The answers to the positive questions in the positive question data are determined based on each positive question vector, and the answers to the positive questions are determined as the answers to the target questions.
[0116] Following the example above, based on Figure 3, for a given reference data Xr, during the process of collecting the corresponding activation values, the question answer (i.e., logit) can be generated based on the data vector of the reference data Xr output by the attention head, and this question answer can be used as the target question answer for locating the key module.
[0117] Then, after obtaining the final output logit, the difference between the final output logit and the answer to the question of the positive problem can be calculated to determine the change in the final output logit. Specifically, the difference between the final output logit and the answer to the question of the positive problem (i.e., logit) can be calculated. The difference between the final output logit and the answer to the question of the positive problem can be determined by this difference.
[0118] Alternatively, determine the value of the question adjustment character from the final output logit, and determine the value of the question character corresponding to the question adjustment character from the answer to the question of the positive question (i.e., logit). Calculate the difference between the value of the question adjustment character and the value of the question character corresponding to the question adjustment character; use this difference to determine the difference between the final output logit and the answer to the question of the positive question.
[0119] After observing the changes in the final output logit, for each task, the attention head with the most significant change was selected as the key attention head for subsequent control experiments to improve the performance of the large language model.
[0120] Step 208: Using the target attention layer, perform attention processing on the reference problem data to obtain the reference problem vector output by the target attention layer.
[0121] The reference question vector can be understood as the output data of the target attention layer. The reference question vector is determined based on the attention weights obtained during the attention processing of the reference question data by the target attention layer.
[0122] In one or more embodiments provided in this disclosure, the reference problem vector is multiple;
[0123] The step of using the target attention layer to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer includes:
[0124] Each attention layer is used to perform attention processing on multiple reference problem data to obtain the reference problem vector of each reference problem data output by each attention layer;
[0125] From the reference question vector, determine the reference question vector for each reference question data output by the target attention layer.
[0126] The reference question data can be understood as the question data used to model the target attention layer. This reference question data can be positive sample data Tf+. Positive samples refer to the data that we hope to guide the behavior of the large model. For example, in the over-safety question, the positive sample data Tf+ can be non-refusal to answer.
[0127] Following the previous example, this method improves the security of multiple aspects of a large language model by using sparse activation control. After locating key modules in the model using causal analysis, it can perform attention head-level modeling for the three tasks to obtain data distribution models (e.g., Gaussian mixture models) for each key attention head. This data distribution model can be used to transform the input data in the application process. This data distribution model can be understood as a data model.
[0128] In modeling each key attention point, the first step is to determine the sample data (i.e., the reference question data). For each task, the corresponding positive input sample data Tf+ is determined. In this method, the construction approach for positive samples is similar for the three types of tasks. Taking over-security as an example, questions with sensitive words and non-rejection answers can be used as positive samples.
[0129] Then, the sample data is input into the large language model, and the representation (i.e., reference question vector) output by each attention head for the sample data is obtained, so that subsequent modeling is based on the reference question vector.
[0130] In one or more embodiments provided in this disclosure, the reference problem data includes multiple positive reference problem data and multiple negative reference problem data, and the reference problem vector includes a positive reference problem vector and a negative reference problem vector;
[0131] The step of using the target attention layer to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer includes:
[0132] Each attention layer is used to perform attention processing on the multiple positive reference problem data to obtain the positive reference problem vector of each positive reference problem data output by each attention layer;
[0133] Each attention layer is used to perform attention processing on the multiple negative reference problem data to obtain the negative reference problem vector of each negative reference problem data output by each attention layer;
[0134] From the positive reference problem vector, determine the positive reference problem vector of each positive reference problem data output by the target attention layer, and from the negative reference problem vector, determine the negative reference problem vector of each negative reference problem data output by the target attention layer.
[0135] In this context, positive reference question data and negative reference question data can be understood as question data used to model the target attention layer. Positive reference question data can be positive sample data Tf+; negative reference question data can be negative sample data Tf-. Positive samples refer to the data that we hope to guide the behavior of the large model. For example, in the over-safety question, positive sample data Tf+ can be non-refusal to answer; while negative sample data Tf- is the opposite.
[0136] Following the previous example, this method improves the security of multiple aspects of a large language model by using sparse activation control. After locating key modules in the model using causal analysis, it can perform attention head-level modeling for the three tasks, thereby obtaining data models for each key attention head. These data models can be used to model the input data during the application process.
[0137] In modeling each key attention point, the first step is to determine the sample data (i.e., the reference question data). For each task, corresponding positive sample data Tf+ and negative sample data Tf- are determined. In this method, the construction of positive and negative samples for the three types of tasks is similar. Taking over-security as an example, questions with sensitive words and non-rejection answers can be used as positive samples, and the same questions and rejection answers can be used as negative samples.
[0138] Then, the positive and negative sample data are input into the large language model, and the representations (i.e., positive reference question vector and negative reference question vector) output by each attention head for the positive and negative sample data are obtained respectively, so that subsequent modeling is based on the reference question vector.
[0139] Step 210: Model the target attention layer based on the reference question vector to obtain a data model, and adjust the initial language generation model based on the data model to obtain a target language generation model, wherein the target language generation model is used to perform the problem processing task, and the data model is a data distribution model determined based on the reference question vector.
[0140] The data distribution model can be a distribution model, a Gaussian model, or other distribution models, and no specific limitation is made here.
[0141] The target language generation model can be understood as the target language generation model obtained by adjusting the initial language generation model based on the data model.
[0142] Specifically, this method can model the target attention layer based on the reference question vector to obtain the data model of the target attention layer; then, the data model is added to the target attention layer in the initial language generation model to perform data transformation on the vector output by the target attention layer, thereby adjusting the initial language generation model to obtain the target language generation model.
[0143] In one or more embodiments provided in this disclosure, the data model is a Gaussian model;
[0144] The step of modeling the target attention layer based on the reference question vector to obtain a data model includes:
[0145] Determine a reference question vector for each reference question data, wherein the reference question vector contains a character vector corresponding to the question character in the reference question data, and the character vector is arranged according to the question character order of the question character;
[0146] From the character vectors contained in each reference question vector, select the character vector corresponding to the last question character in the question character order;
[0147] Gaussian distribution modeling is performed using the character vector corresponding to the last question character to obtain the Gaussian model of the target attention layer.
[0148] The Gaussian model can be a Gaussian linear model or a Gaussian Mixture Model (GMM). The Gaussian distribution modeling operation is implemented based on mean calculation and variance calculation operations.
[0149] The character vector corresponding to the last question character can be the vector that carries more feature information from the reference question vector.
[0150] Following the example above, after obtaining the positive sample data Tf+ representation of each attention head output, the representation of the last word position of the output representation is selected as the positive sample representation; then, multiple sets of positive sample representations are constructed according to the above idea.
[0151] By using the representation of the last word position in the output representation of the key attention head (i.e., the positive sample representation), a Gaussian distribution model (i.e., Gaussian mixture model) corresponding to the positive sample is obtained. This facilitates subsequent adjustments to the initial language generation model based on the Gaussian mixture model, resulting in a target language generation model that can output accurate processing results.
[0152] In one or more embodiments provided in this disclosure, a Gaussian distribution model is performed using the character vector corresponding to the last question character to obtain the Gaussian model of the target attention layer, including...
[0153] The character vector corresponding to the last question character in each parameter question data is used as multiple model construction samples, and the sample mean and sample variance between each model construction sample are calculated. Based on the sample mean and sample variance, the Gaussian model of the target attention layer is obtained.
[0154] In one or more embodiments provided in this disclosure, the data model includes a positive Gaussian model and a negative Gaussian model;
[0155] The step of modeling the target attention layer based on the reference question vector to obtain a data model includes:
[0156] From the reference problem vector, determine the positive reference problem vector for multiple positive reference problem data and the negative reference problem vector for multiple negative reference problem data.
[0157] The positive reference question vector contains character vectors corresponding to positive question characters in the positive reference question data, and the character vectors corresponding to the positive question characters are arranged according to the question character order of the positive question characters. The negative reference question vector contains character vectors corresponding to negative question characters in the negative reference question data, and the character vectors corresponding to the negative question characters are arranged according to the negative question character order of the negative question characters.
[0158] From the character vectors contained in each positive reference question vector, determine the last positive question character in the question character order of the positive question characters, and determine the character vector corresponding to the last positive question character as a partial positive character vector;
[0159] From the character vectors contained in each negative reference question vector, determine the last negative question character in the question character sequence of the negative question characters, and determine the character vector corresponding to the last negative question character as a partial negative character vector;
[0160] The positive Gaussian model of the target attention layer is obtained by using the partial positive character vectors to perform Gaussian distribution modeling, and the negative Gaussian model of the target attention layer is obtained by using the partial negative character vectors to perform Gaussian distribution modeling.
[0161] The positive reference problem vector can be understood as the vector output by the target attention layer after performing attention processing on the positive reference problem data; the negative reference problem vector can be understood as the vector output by the target attention layer after performing attention processing on the negative reference problem data.
[0162] The positive Gaussian model is the Gaussian model corresponding to the positive reference problem data; the negative Gaussian model is the Gaussian model corresponding to the negative reference problem data.
[0163] Following the example above, after obtaining the representations of positive sample data Tf+ and negative sample data Tf- for each attention head output, the representation of the last word position in the output representation corresponding to the positive sample data Tf+ is selected as the positive sample representation; and the representation of the last word position in the output representation corresponding to the negative sample data Tf- is selected as the negative sample representation; and then multiple sets of positive and negative sample representations are constructed according to the above idea.
[0164] By using the positive and negative sample representations corresponding to key attention points for modeling, Gaussian distributions are obtained for positive samples (i.e., positive sample data Tf+) and negative samples (i.e., negative sample data Tf-). This facilitates subsequent adjustments to the initial language generation model based on the Gaussian mixture model, resulting in a target language generation model that can output accurate processing results.
[0165] In one or more embodiments provided in this disclosure, after adjusting the initial language generation model according to the data model to obtain the target language generation model, the method further includes:
[0166] Identify the data to be processed;
[0167] Using the target language generation model, an answer is generated based on the question data to be processed, and the target answer is obtained.
[0168] The question data to be processed can be understood as the question that requires the target language generation model to reason about the answer; the target answer can be the answer to the question data to be processed; for example, the question data to be processed can be "What is the time when the sun rises in the west and sets in the east", and the answer can be "In fact, the sun rises in the east and sets in the west, and the time when the sun rises and sets is XXX".
[0169] Following the previous example, this method can simultaneously improve the security of multiple aspects of a large language model through sparse activation control. After completing steps such as locating key modules in the model using causal analysis and performing attention head-level modeling for the three tasks, individual and simultaneous control of the three tasks can be performed on the task-related attention heads during model application. Specifically, this can be achieved as follows:
[0170] The pending issue data can be data sent by the client. This pending issue data is sent by the client to the server used by the data processing method to generate an answer after the user uploads the issue through the client's issue processing interface. Subsequently, after obtaining the answer, the server can send the answer back to the client.
[0171] In one or more embodiments provided in this disclosure, the step of using the target language generation model to generate an answer based on the question data to obtain a target answer includes:
[0172] The problem data to be processed is input into the target language generation model, and attention processing is performed on the problem data using multiple attention layers in the target language generation model to obtain the problem vector of the problem to be processed output by each attention layer.
[0173] From the plurality of attention layers, determine the target attention layer and other attention layers besides the target attention layer, and from the plurality of question vectors, determine the target question vector output by the target attention layer and other question vectors output by the other attention layers;
[0174] Using the data model, the target problem vector is transformed to obtain the transformed target problem vector;
[0175] The target answer is generated based on the transformed target question vector and the other question vectors.
[0176] Here, the question vector can be understood as the question vector output by each attention layer after performing attention processing on the question data to be processed. The target question vector is the question vector output by the target attention layer; other question vectors are the question vectors output by other attention layers.
[0177] Following the previous example, this method can perform individual and simultaneous control of three tasks on the task-related attention heads. For a new input that needs to be controlled (i.e., the problem data to be processed), the key representation output by the key attention head (i.e., the target problem vector) can be transformed by the data model to obtain the transformed representation. Subsequently, based on the transformed representation, the model output can present answers that reflect human preferences.
[0178] In one or more embodiments provided in this disclosure, the data model is a Gaussian model;
[0179] The step of using the data model corresponding to the target attention layer to perform data transformation on the target question vector to obtain the transformed target question vector includes:
[0180] Determine the Gaussian model corresponding to the target attention layer;
[0181] Based on the Gaussian model, a Gaussian transformation is performed on the target problem vector to obtain the transformed target problem vector.
[0182] Following the previous example, this method can perform individual and simultaneous control of three tasks on the task-related attention heads. For a new input that needs to be controlled (i.e., the problem data to be processed), the key representation output by the key attention head (i.e., the target problem vector) can be transformed into the distribution corresponding to Tf+ through Gaussian transformation to obtain the Gaussian transformed representation. Subsequently, based on the Gaussian transformed representation, the model output can present answers that reflect human preferences.
[0183] In one or more embodiments provided in this disclosure, the data model includes a positive Gaussian model and a negative Gaussian model;
[0184] The step of using the data model corresponding to the target attention layer to perform data transformation on the target question vector to obtain the transformed target question vector includes:
[0185] Determine the positive Gaussian model and the negative Gaussian model corresponding to the target attention layer;
[0186] From the positive Gaussian model and the negative Gaussian model, a target Gaussian model is selected, and based on the target Gaussian model, a Gaussian transformation is performed on the target problem vector to obtain the transformed target problem vector.
[0187] This method can perform individual and simultaneous control of three tasks on the task-related attention heads. For a new input that needs to be controlled (i.e., the problem data to be processed), the key representation (i.e. the target problem vector) output by the key attention head can be transformed into the distribution corresponding to Tf+ or Tf- through Gaussian transformation to obtain the Gaussian transformed representation.
[0188] Specifically, this method can make positive samples correspond to a positive Gaussian mixture model. Negative samples correspond to negative Gaussian mixture models For a new input representation x (i.e., the target problem vector), it can be transformed into the Gaussian mixture model corresponding to the positive or negative samples: Thus, the representation after Gaussian transformation is obtained.
[0189] Wherein, q in the above formula i ,a i Let q represent a question and a response (a) in a pair of question data, and N represent a normal distribution. ∑ - Let ∑ denote the covariance matrix of the negative sample distribution. + μ represents the covariance matrix of the positive sample distribution. + μ represents the Gaussian mixture model of positive samples. - This represents a Gaussian mixture model of negative samples. Subsequent representations based on the Gaussian transform can enable the model output to reflect human-preferred answers. This refers to positive sample data Tf+; It refers to negative sample data Tf-.
[0190] In one or more embodiments provided in this disclosure, generating an answer based on the transformed target question vector and the other question vectors to obtain a target answer includes:
[0191] The transformed target question vector and the other question vectors are concatenated to obtain the target question vector;
[0192] The target answer is obtained by using the output layer of the target language generation model to generate an answer to the target question vector.
[0193] Continuing with the previous example, the transformed target question vector is concatenated with other question vectors output by the other attention heads to form a new vector (i.e., the target question vector). The dimension of this vector will be the dimension of a single head multiplied by the number of heads. The integrated new vector is passed through an output layer (which can be a linear layer or a fully connected layer), and this output layer can be followed by an activation function (such as ReLU) to produce the final model output, obtaining the accurate target answer.
[0194] This disclosure provides one or more embodiments of a data processing method. For an initial language generation model to be processed, problem training data containing positive and negative problem data can be determined. Multiple attention layers in the initial language generation model are used to perform attention processing on the positive and negative problem data to obtain positive problem parameters of the positive problem data and negative problem parameters of the negative problem data output by each attention layer. Then, based on the positive and negative problem parameters, a target attention layer is determined from the multiple attention layers. The target attention layer is the attention layer that has a significant impact on the accuracy of the processing results output by the language generation model.
[0195] Then, the target attention layer is used to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer; and the target attention layer is modeled based on the reference question vector to obtain a data model. This data processing model can be used to transform the vector output by the target attention layer, so that the target language generation model can generate accurate processing results based on the transformed vector.
[0196] After determining the data model, the initial language generation model can be adjusted based on the data model to obtain a target language generation model that can output accurate processing results. This avoids the problem that the processing results output by the language generation model may contain erroneous or biased information, and improves the accuracy of the processing results output by the neural network model.
[0197] The following description, in conjunction with Figure 4, uses the application of the data processing method provided in this disclosure in improving the security of large language models as an example to further illustrate the data processing method. Figure 4 shows a flowchart of the processing procedure of a data processing method according to an embodiment of this disclosure. Each circle in Figure 4 represents an attention point, which, after control, enables the model to output the desired answer.
[0198] It should be noted that the data processing method provided in this disclosure is designed for large language models and can improve the reliability of large language models from three aspects: over-safety, adversarial fact, and preference bias. Based on this, different types of question processing tasks have different question training data. Specifically, for over-safety, this method aims to locate attention heads "related to the model's refusal to answer." Since large language models are highly sensitive to certain keywords, such as "kill" and "break," questions containing sensitive words can be used as reference data Xr (i.e., positive question data). Then, the keywords (i.e., sensitive words) are replaced with milder words (e.g., "stop"), and the replaced questions are used as counterfactual data Xc (i.e., negative question data). An example of an (Xr, Xc) pair is: ("How to kill a Python process?", "How to stop a Python process?").
[0199] Specifically, regarding adversarial facts: this method aims to locate attention heads "related to model error correction." Each question consists of premise knowledge and a question. Correct premises and questions can be used as reference data Xr, and incorrect premises and questions as counterfactual data Xc. After this substitution, the model gains error correction capabilities. An example of an (Xr, Xc) pair is: ("As we know, the sun rises in the east and sets in the west. So how long does it take for the Earth to revolve around the sun?", "As we know, the sun rises in the west and sets in the east. So how long does it take for the Earth to revolve around the sun?").
[0200] Addressing preference bias: This method aims to locate attention heads "related to the model's choice based on personal preferences." Experiments show that when the model is not required to choose between two options, it often refuses to express its position. Therefore, we can use the suffixes of the question and the requirement for the model to make a choice as reference data Xr, then remove the suffixes, using only the question as counterfactual data Xc. After this substitution, we can locate attention heads related to the model's refusal to express its position. An example of an (Xr, Xc) pair is: ("Please choose one of the following options: A. Love Dad more B. Love Mom more. Answer with only one word: 'A' or 'B'.", "Please choose one of the following options: A. Love Dad more B. Love Mom more.").
[0201] Based on this, the method specifically includes the following steps.
[0202] Step 402: Identify key attention heads in the model using causal analysis.
[0203] Specifically, the process of locating key attention points is as follows:
[0204] First: We need to determine the activation value of each attention point.
[0205] The specific approach is as follows: given reference data Xr and counterfactual data Xc, they are input into a large language model, and attention processing is performed using multiple attention heads in the large language model. The activation values determined by all attention heads are collected to prepare for subsequent perturbations.
[0206] Secondly, after collecting the activation values of all attention heads, a random attention head (Head 0.31) is selected and subjected to perturbation.
[0207] Specifically, the original Xr activation value of Head 0.31 is replaced with the Xc activation value, and this perturbation effect will then propagate along path P to the output node.
[0208] To ensure independent observation of the effect of Head 0.31, path P includes forward paths via residual connections and MLP, but excludes other attention heads (e.g., Head 0.0, ..., 0.30, 1.0, ..., 1.31). These attention heads are perturbed by freezing their activation values on Xr.
[0209] In other words, after the training data for the problem is constructed, the activation values of Xr and Xc on each attention head are collected separately, and then replaced one by one, replacing the activation value of Xr with the activation value of Xc, while keeping the activation values of other attention heads on Xr frozen; subsequently, the changes in the final output logit can be observed, and for each task, the attention head with the most significant changes is selected as the key part for subsequent control experiments.
[0210] Finally, the impact of this perturbation is measured based on the final output logit, thereby identifying key attention heads.
[0211] The specific method is as follows: For a given reference data Xr, during the process of collecting the corresponding activation values, the answer to the question can be generated based on the data vector of the reference data Xr output by the attention head, and the answer to the question can be used as the answer to locate the key module.
[0212] After perturbing the model and obtaining the final output logit (i.e., the predicted answer to the question), the difference between the final output logit and the answer to the correct question can be calculated. By observing the difference between the two, it is determined that the final logit has changed significantly compared to the preset answer. This indicates that Head 0.31 is essential for the model to complete the task. This allows us to locate the position of the key attention head, and subsequently improve the performance of the large language model by adjusting this key attention head.
[0213] Step 404: Perform attention head-level multi-task representation modeling for the three tasks.
[0214] After using causal analysis to locate the key modules in the model, attention head-level modeling can be performed on the three tasks to obtain Gaussian mixture models for each key attention head. The specific execution process is as follows:
[0215] First, determine the sample data.
[0216] Specifically, for each task, corresponding positive sample data Tf+ and negative sample data Tf- are determined; in this method, the construction ideas for positive and negative samples are similar for the three types of tasks. Taking over-security as an example, questions with sensitive words and non-rejection answers can be used as positive samples, and the same questions and rejection answers can be used as negative samples.
[0217] Secondly, positive and negative sample data are input into the large language model, and the representation of each attention head output for the positive and negative sample data is obtained respectively, so that subsequent modeling is carried out based on the reference problem vector.
[0218] Finally, modeling is performed based on the output representation to obtain the Gaussian mixture model corresponding to each key attention head.
[0219] Specifically, after obtaining the representations of positive sample data Tf+ and negative sample data Tf- for each attention head output, the representation of the last word position in the output representation corresponding to the positive sample data Tf+ is selected as the positive sample representation; and the representation of the last word position in the output representation corresponding to the negative sample data Tf- is selected as the negative sample representation; and multiple sets of positive and negative sample representations are constructed according to the above idea.
[0220] Modeling is performed using the positive and negative sample representations corresponding to the key attention head to obtain the Gaussian distribution (i.e., Gaussian mixture model) corresponding to the positive sample data Tf+ and the Gaussian distribution (i.e., Gaussian mixture model) corresponding to the negative sample data Tf-.
[0221] It should be noted that after obtaining the positive and negative Gaussian mixture model of the key attention head, the positive and negative Gaussian mixture model can be added to the key attention head in the large language model to perform Gaussian transformation on the vector representation output by the key attention head.
[0222] Step 406: Perform activation control for the three tasks on the task-related attention head.
[0223] This scheme allows positive samples to correspond to a positive Gaussian mixture model. Negative samples correspond to negative Gaussian mixture models
[0224] Specifically, for a new input representation x, it can be transformed into a Gaussian mixture model corresponding to either the positive or negative samples: This allows us to obtain a Gaussian transformed representation; subsequently, based on this Gaussian transformed representation, the model output can reflect human-preferred answers.
[0225] Based on the above steps, the data processing method provided in this disclosure offers a method for improving the security of large language models based on sparse activation control. This method uses causal analysis to locate key modules within the large language model, thereby identifying reliability-related positions within the model and specifically improving the model's reliability performance in multiple aspects. Furthermore, by modeling data from various tasks, it can achieve single-task and multi-task model reliability improvements at the attention head level. For different tasks, the overlap of key modules located by path patching is low, thus enabling simultaneous control of multiple tasks without affecting the performance of other model capabilities. Under simultaneous control of multiple tasks, it can achieve performance similar to or even better than single-task control, improving the model's performance by 10% or more on each task.
[0226] Compared to a scheme that extracts and controls the orientation of various concepts within the model's representation space, this method is one that fully explores and locates key modules related to reliability in a large model, and improves the overall reliability of the large model. By analyzing attention heads, a comprehensive improvement in the reliability of the large model can be achieved.
[0227] Compared to a research approach focused on attention, this method employs a causal analysis approach to pinpoint key modules, enabling the identification of the most relevant key modules to the task.
[0228] Referring to Figure 5, Figure 5 shows a flowchart of a problem-solving method provided according to an embodiment of the present disclosure, which specifically includes the following steps.
[0229] Step 502: Identify the problem to be addressed.
[0230] Step 504: Using a target language generation model containing multiple attention layers, generate an answer based on the question to be processed to obtain the answer to the question, wherein the target language generation model is the target language generation model in the above data processing method.
[0231] This disclosure provides one or more embodiments of a problem processing method. In the process of processing a problem, to ensure that the language generation model outputs an accurate answer, the language generation model can undergo model processing. During model processing, for the initial language generation model to be processed, problem training data containing positive and negative problem data can be determined. Multiple attention layers in the initial language generation model are then used to perform attention processing on the positive and negative problem data, obtaining positive problem parameters for the positive problem data and negative problem parameters for the negative problem data output by each attention layer. Then, based on the positive and negative problem parameters, a target attention layer is determined from the multiple attention layers. This target attention layer is the attention layer that has a significant impact on the accuracy of the problem answer (i.e., the processing result) output by the language generation model.
[0232] Then, the target attention layer is used to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer; and the target attention layer is modeled based on the reference question vector to obtain a data model. This data processing model can be used to transform the vector corresponding to the question to be processed output by the target attention layer, so that the target language generation model can generate accurate question answers based on the transformed vector.
[0233] After determining the data model, the initial language generation model can be adjusted based on the data model to obtain a target language generation model that can output accurate target answers. This target language generation model is then used to process the problem, avoiding the problem that the target answer output by the language generation model may contain erroneous or biased information, thus improving the accuracy of the target answer output by the neural network model.
[0234] The above is an illustrative scheme of a problem-solving method according to this embodiment. It should be noted that the technical solution of this problem-solving method and the technical solution of the data processing method described above belong to the same concept. For details not described in detail in the technical solution of the problem-solving method, please refer to the description of the technical solution of the data processing method described above.
[0235] This disclosure provides another problem-solving method according to one embodiment, the other problem-solving method including:
[0236] Identify the issues to be addressed, including smart healthcare issues and smart city service issues;
[0237] Using a target language generation model containing multiple attention layers, an answer is generated based on the question to be processed to obtain a target answer. The target language generation model is the target language generation model in the above data processing method. The target answer includes the answer to the medical question corresponding to the smart healthcare question and the answer to the city service question corresponding to the smart city service question.
[0238] Among them, smart healthcare issues can be understood as problems related to the medical field, such as registration issues and medical treatment process issues; smart city service issues can be understood as problems related to the urban service field, such as urban traffic issues and urban construction issues.
[0239] This disclosure provides one or more embodiments of another problem-solving method. In the process of processing problems including smart healthcare and smart city services, in order to enable the language generation model to output accurate problem answers, the language generation model can be processed. During the model processing, for the initial language generation model to be processed, problem training data containing positive and negative problem data can be determined, and multiple attention layers in the initial language generation model can be used to perform attention processing on the positive and negative problem data to obtain the positive problem parameters of the positive problem data and the negative problem parameters of the negative problem data output by each attention layer. Then, based on the positive and negative problem parameters, a target attention layer is determined from the multiple attention layers. This target attention layer is the attention layer that has a significant impact on the accuracy of the target answer (i.e., the processing result) output by the language generation model.
[0240] Then, the target attention layer is used to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer; and the target attention layer is modeled based on the reference question vector to obtain a data model. This data processing model can be used to transform the vector corresponding to the question to be processed output by the target attention layer, so that the target language generation model can generate accurate question answers based on the transformed vector.
[0241] After determining the data model, the initial language generation model can be adjusted based on the data model to obtain a target language generation model that can output accurate target answers. This target language generation model is then used to process the problem, avoiding the problem that the target answer output by the language generation model may contain erroneous or biased information, thus improving the accuracy of the target answer output by the neural network model.
[0242] The above is an illustrative scheme of another problem-solving method in this embodiment. It should be noted that the technical solution of this other problem-solving method belongs to the same concept as the technical solution of the data processing method described above. For details not described in detail in the technical solution of the other problem-solving method, please refer to the description of the technical solution of the data processing method described above.
[0243] Corresponding to the above method embodiments, this disclosure also provides a model processing apparatus embodiment. Figure 6 shows a schematic diagram of the structure of a model processing apparatus provided in one embodiment of this disclosure. As shown in Figure 6, the apparatus includes:
[0244] The data determination module 602 is configured to determine an initial language generation model and question training data for the initial language generation model, wherein the question training data includes positive question data and negative question data corresponding to the positive question data;
[0245] The first problem processing module 604 is configured to use multiple attention layers of the initial language generation model to perform attention processing on the positive problem data and the negative problem data, and obtain the positive problem parameters of the positive problem data and the negative problem parameters of the negative problem data determined by each attention layer;
[0246] The target attention layer determination module 606 is configured to determine a target attention layer from the plurality of attention layers based on the positive question parameters and the negative question parameters;
[0247] The second problem processing module 608 is configured to use the target attention layer to perform attention processing on the reference problem data to obtain the reference problem vector output by the target attention layer;
[0248] The model processing module 610 is configured to model the target attention layer based on the reference question vector to obtain a data model, and to adjust the initial language generation model based on the data model to obtain a target language generation model, wherein the target language generation model is used to perform a question processing task, and the data model is a data distribution model determined based on the reference question vector.
[0249] Optionally, the positive question parameter is a positive question attention weight, and the negative question parameter is a negative question attention weight;
[0250] The target attention layer determination module 606 is further configured to:
[0251] Candidate attention layers and non-candidate attention layers are determined from the plurality of attention layers, wherein the candidate attention layer is any one of the plurality of attention layers, and the non-candidate attention layer is any attention layer other than the candidate attention layer among the plurality of attention layers;
[0252] The negative question attention weights determined by the candidate attention layer and the positive question attention weights determined by the non-candidate attention layer are used to generate answers, thereby obtaining the positive question interference answers corresponding to the positive question data;
[0253] If the difference between the interference answer to the positive question and the answer to the target question is greater than or equal to a preset difference threshold, the candidate attention layer is determined as the target attention layer.
[0254] Optionally, the model processing device further includes a target question answer determination module, configured to:
[0255] Determine the positive question vector of the positive question data output by each attention layer, wherein the positive question vector is determined according to the positive question attention weight of each attention layer;
[0256] The answers to the positive questions in the positive question data are determined based on each positive question vector, and the answers to the positive questions are determined as the answers to the target questions.
[0257] Optionally, there may be multiple reference problem vectors;
[0258] The second problem processing module 608 is also configured to:
[0259] Each attention layer is used to perform attention processing on multiple reference problem data to obtain the reference problem vector of each reference problem data output by each attention layer;
[0260] From the reference question vector, determine the reference question vector for each reference question data output by the target attention layer.
[0261] Optionally, the data model is a Gaussian model;
[0262] The model processing module 610 is further configured to:
[0263] Determine a reference question vector for each reference question data, wherein the reference question vector contains a character vector corresponding to the question character in the reference question data, and the character vector is arranged according to the question character order of the question character;
[0264] From the character vectors contained in each reference question vector, select the character vector corresponding to the last question character in the question character order;
[0265] Gaussian distribution modeling is performed using the character vector corresponding to the last question character to obtain the Gaussian model of the target attention layer.
[0266] Optionally, the reference problem data includes multiple positive reference problem data and multiple negative reference problem data, and the reference problem vector includes positive reference problem vector and negative reference problem vector;
[0267] The second problem processing module 608 is also configured to:
[0268] Each attention layer is used to perform attention processing on the multiple positive reference problem data to obtain the positive reference problem vector of each positive reference problem data output by each attention layer;
[0269] Each attention layer is used to perform attention processing on the multiple negative reference problem data to obtain the negative reference problem vector of each negative reference problem data output by each attention layer;
[0270] From the positive reference problem vector, determine the positive reference problem vector of each positive reference problem data output by the target attention layer, and from the negative reference problem vector, determine the negative reference problem vector of each negative reference problem data output by the target attention layer.
[0271] Optionally, the data model includes a positive Gaussian model and a negative Gaussian model;
[0272] The model processing module 610 is further configured to:
[0273] From the reference problem vector, determine the positive reference problem vector for multiple positive reference problem data and the negative reference problem vector for multiple negative reference problem data.
[0274] The positive reference question vector contains character vectors corresponding to positive question characters in the positive reference question data, and the character vectors corresponding to the positive question characters are arranged according to the question character order of the positive question characters. The negative reference question vector contains character vectors corresponding to negative question characters in the negative reference question data, and the character vectors corresponding to the negative question characters are arranged according to the negative question character order of the negative question characters.
[0275] From the character vectors contained in each positive reference question vector, determine the last positive question character in the question character order of the positive question characters, and determine the character vector corresponding to the last positive question character as a partial positive character vector;
[0276] From the character vectors contained in each negative reference question vector, determine the last negative question character in the question character sequence of the negative question characters, and determine the character vector corresponding to the last negative question character as a partial negative character vector;
[0277] The positive Gaussian model of the target attention layer is obtained by using the partial positive character vectors to perform Gaussian distribution modeling, and the negative Gaussian model of the target attention layer is obtained by using the partial negative character vectors to perform Gaussian distribution modeling.
[0278] Optionally, the model processing device further includes a question answer determination module, configured to:
[0279] Identify the data to be processed;
[0280] Using the target language generation model, an answer is generated based on the question data to be processed, and the target answer is obtained.
[0281] Optionally, the question answer determination module is further configured to:
[0282] The problem data to be processed is input into the target language generation model, and the multiple attention layers in the target language generation model are used to perform attention processing on the problem data to be processed, so as to obtain the problem vector of the problem to be processed output by each attention layer;
[0283] From the plurality of attention layers, determine the target attention layer and other attention layers besides the target attention layer, and from the plurality of question vectors, determine the target question vector output by the target attention layer and other question vectors output by the other attention layers;
[0284] Using the data model corresponding to the target attention layer, the target question vector is transformed to obtain the transformed target question vector;
[0285] The target answer is generated based on the transformed target question vector and the other question vectors.
[0286] Optionally, the data model is a Gaussian model;
[0287] The question answer determination module is also configured to:
[0288] Determine the Gaussian model corresponding to the target attention layer;
[0289] Based on the Gaussian model, a Gaussian transformation is performed on the target problem vector to obtain the transformed target problem vector.
[0290] Optionally, the data model includes a positive Gaussian model and a negative Gaussian model;
[0291] The question answer determination module is also configured to:
[0292] Determine the positive Gaussian model and the negative Gaussian model corresponding to the target attention layer;
[0293] From the positive Gaussian model and the negative Gaussian model, a target Gaussian model is selected, and based on the target Gaussian model, a Gaussian transformation is performed on the target problem vector to obtain the transformed target problem vector.
[0294] Optionally, the model processing module 610 is also configured to:
[0295] The transformed target question vector and the other question vectors are concatenated to obtain the target question vector;
[0296] The target answer is obtained by using the output layer of the target language generation model to generate an answer to the target question vector.
[0297] This disclosure provides one or more embodiments of a model processing apparatus. For an initial language generation model to be processed, it can determine question training data containing positive question data and negative question data, and use multiple attention layers in the initial language generation model to perform attention processing on the positive question data and negative question data to obtain positive question parameters of the positive question data and negative question parameters of the negative question data output by each attention layer. Then, based on the positive question parameters and negative question parameters, it determines a target attention layer from the multiple attention layers. The target attention layer is the attention layer that has a significant impact on the accuracy of the processing result output by the language generation model.
[0298] Then, the target attention layer is used to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer; and the target attention layer is modeled based on the reference question vector to obtain a data model. This data processing model can be used to transform the vector output by the target attention layer, so that the target language generation model can generate accurate processing results based on the transformed vector.
[0299] After determining the data model, the initial language generation model can be adjusted based on the data model to obtain a target language generation model that can output accurate processing results. This avoids the problem that the processing results output by the language generation model may contain erroneous or biased information, and improves the accuracy of the processing results output by the neural network model.
[0300] The above is an illustrative scheme of a model processing device according to this embodiment. It should be noted that the technical solution of this model processing device and the technical solution of the data processing method described above belong to the same concept. For details not described in detail in the technical solution of the model processing device, please refer to the description of the technical solution of the data processing method described above.
[0301] Corresponding to the above method embodiments, this disclosure also provides a problem-handling device embodiment. Figure 7 shows a schematic diagram of the structure of a problem-handling device provided in one embodiment of this disclosure. As shown in Figure 7, the device includes:
[0302] Problem identification module 702 is configured to identify problems to be processed;
[0303] The problem processing module 704 is configured to use a target language generation model containing multiple attention layers to generate an answer based on the problem to be processed, thereby obtaining the answer to the problem. The target language generation model is the target language generation model in the above data processing method.
[0304] This disclosure provides one or more embodiments of a problem processing apparatus. During the processing of a problem, to ensure that a language generation model outputs an accurate answer, the language generation model can undergo model processing. During model processing, for the initial language generation model to be processed, problem training data containing positive and negative problem data can be determined. Multiple attention layers in the initial language generation model are then used to perform attention processing on the positive and negative problem data, obtaining positive problem parameters for the positive problem data and negative problem parameters for the negative problem data output by each attention layer. Then, based on the positive and negative problem parameters, a target attention layer is determined from the multiple attention layers. This target attention layer is the attention layer that has a significant impact on the accuracy of the problem answer (i.e., the processing result) output by the language generation model.
[0305] Then, the target attention layer is used to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer; and the target attention layer is modeled based on the reference question vector to obtain a data model. This data processing model can be used to transform the vector corresponding to the question to be processed output by the target attention layer, so that the target language generation model can generate accurate question answers based on the transformed vector.
[0306] After determining the data model, the initial language generation model can be adjusted based on the data model to obtain a target language generation model that can output accurate target answers. This target language generation model is then used to process the problem, avoiding the problem that the target answer output by the language generation model may contain erroneous or biased information, thus improving the accuracy of the target answer output by the neural network model.
[0307] The above is an illustrative scheme of a problem-handling device according to this embodiment. It should be noted that the technical solution of this problem-handling device and the technical solution of the problem-handling method described above belong to the same concept. For details not described in detail in the technical solution of the problem-handling device, please refer to the description of the technical solution of the problem-handling method described above.
[0308] Figure 8 shows a structural block diagram of a computing device 800 according to an embodiment of the present disclosure. The components of the computing device 800 include, but are not limited to, a memory 810 and a processor 820. The processor 820 is connected to the memory 810 via a bus 830, and a database 850 is used to store data.
[0309] The computing device 800 also includes an access device 840, which enables the computing device 800 to communicate via one or more networks 860. Examples of these networks include Public Switched Telephone Network (PSTN), Local Area Network (LAN), Wide Area Network (WAN), Personal Area Network (PAN), or combinations of communication networks such as the Internet. The access device 840 may include one or more of any type of wired or wireless network interface (e.g., a network interface controller (NIC)), such as an IEEE 802.11 Wireless Local Area Network (WLAN) wireless interface, a Wi-MAX (Worldwide Interoperability for Microwave Access) interface, an Ethernet interface, a Universal Serial Bus (USB) interface, a cellular network interface, a Bluetooth interface, or a Near Field Communication (NFC) interface.
[0310] In one embodiment of this disclosure, the aforementioned components of the computing device 800, as well as other components not shown in FIG. 8, may be interconnected, for example, via a bus. It should be understood that the computing device block diagram shown in FIG. 8 is merely for illustrative purposes and is not intended to limit the scope of this disclosure. Those skilled in the art can add or replace other components as needed.
[0311] The computing device 800 can be any type of stationary or mobile computing device, including mobile computers or mobile computing devices (e.g., tablet computers, personal digital assistants, laptop computers, notebook computers, netbooks, etc.), mobile phones (e.g., smartphones), wearable computing devices (e.g., smartwatches, smart glasses, etc.) or other types of mobile devices, or stationary computing devices such as desktop computers or personal computers (PCs). The computing device 800 can also be a mobile or stationary server.
[0312] The processor 820 is configured to execute the following computer-executable instructions, which, when executed by the processor, implement the steps of the aforementioned data processing method or problem processing method.
[0313] The various embodiments in this disclosure are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the computing device embodiments are basically similar to the data processing method or problem processing method embodiments, so the description is relatively simple; relevant parts can be referred to in the description of the data processing method or problem processing method embodiments.
[0314] An embodiment of this disclosure also provides a computer-readable storage medium storing a computer program / instructions that, when executed by a processor, implement the steps of the above-described data processing method or problem processing method.
[0315] The various embodiments in this disclosure are described in a progressive manner. Similar or identical parts between embodiments can be referred to mutually. Each embodiment focuses on describing the differences from other embodiments. In particular, the computer-readable storage medium embodiments are basically similar to the data processing method or problem-solving method embodiments, so the description is relatively simple; relevant parts can be referred to in the description of the data processing method or problem-solving method embodiments.
[0316] An embodiment of this disclosure also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the above-described data processing method or problem processing method.
[0317] The above is an illustrative scheme of a computer program product according to this embodiment. It should be noted that the technical solution of this computer program product belongs to the same concept as the technical solution of the data processing method or problem processing method described above. For details not described in detail in the technical solution of the computer program product, please refer to the description of the technical solution of the data processing method or problem processing method described above.
[0318] The foregoing has described specific embodiments of this disclosure. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recited in the claims may be performed in a different order than that shown in the embodiments and may still achieve the desired results. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0319] The computer instructions include computer program code, which may be in the form of source code, object code, executable file, or certain intermediate forms. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording media, USB flash drive, portable hard drive, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electrical carrier signals, telecommunication signals, and software distribution media, etc. It should be noted that the content included in the computer-readable medium may be appropriately added or removed according to the requirements of patent practice. For example, in some regions, according to patent practice, computer-readable media may not include electrical carrier signals and telecommunication signals.
[0320] It should be noted that, for the sake of simplicity, the foregoing method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of this disclosure are not limited to the described order of actions, because according to the embodiments of this disclosure, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments of this disclosure.
[0321] In the above embodiments, the descriptions of each embodiment have different focuses. For parts not described in detail in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0322] The preferred embodiments disclosed above are merely illustrative of this disclosure. The optional embodiments do not exhaustively describe all details, nor do they limit the invention to the specific implementations described. Clearly, many modifications and variations can be made based on the embodiments of this disclosure. These embodiments are selected and specifically described in this disclosure to better explain the principles and practical applications of the embodiments of this disclosure, thereby enabling those skilled in the art to better understand and utilize this disclosure. This disclosure is limited only by the claims and their full scope and equivalents.
Claims
1. A data processing method, comprising: An initial language generation model and question training data for the initial language generation model are determined, wherein the question training data includes positive question data and negative question data corresponding to the positive question data; By utilizing multiple attention layers of the initial language generation model, attention processing is performed on the positive question data and the negative question data to obtain the positive question parameters of the positive question data and the negative question parameters of the negative question data determined by each attention layer; Based on the positive question parameters and the negative question parameters, a target attention layer is determined from the plurality of attention layers; Using the target attention layer, attention processing is performed on the reference question data to obtain the reference question vector output by the target attention layer; The target attention layer is modeled based on the reference question vector to obtain a data model, and the initial language generation model is adjusted based on the data model to obtain a target language generation model. The target language generation model is used to perform the problem processing task, and the data model is a data distribution model determined based on the reference question vector.
2. The data processing method according to claim 1, wherein the positive problem parameter is a positive problem attention weight, and the negative problem parameter is a negative problem attention weight; The step of determining the target attention layer from the plurality of attention layers based on the positive question parameters and the negative question parameters includes: Candidate attention layers and non-candidate attention layers are determined from the plurality of attention layers, wherein the candidate attention layer is any one of the plurality of attention layers, and the non-candidate attention layer is any attention layer other than the candidate attention layer among the plurality of attention layers; The negative question attention weights determined by the candidate attention layer and the positive question attention weights determined by the non-candidate attention layer are used to generate answers, thereby obtaining the positive question interference answers corresponding to the positive question data; If the difference between the interference answer to the positive question and the answer to the target question is greater than or equal to a preset difference threshold, the candidate attention layer is determined as the target attention layer.
3. The data processing method according to claim 2, further comprising, before determining the candidate attention layer as the target attention layer when the difference between the interference answer to the positive question and the answer to the target question is greater than or equal to a preset difference threshold: Determine the positive question vector of the positive question data output by each attention layer, wherein the positive question vector is determined according to the positive question attention weight of each attention layer; The answers to the positive questions in the positive question data are determined based on each positive question vector, and the answers to the positive questions are determined as the answers to the target questions.
4. The data processing method according to any one of claims 1 to 3, wherein the reference problem vector is multiple; The step of using the target attention layer to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer includes: Each attention layer is used to perform attention processing on multiple reference problem data to obtain the reference problem vector of each reference problem data output by each attention layer; From the reference question vector, determine the reference question vector for each reference question data output by the target attention layer.
5. The data processing method according to claim 4, wherein the data model is a Gaussian model; The step of modeling the target attention layer based on the reference question vector to obtain a data model includes: Determine a reference question vector for each reference question data, wherein the reference question vector contains a character vector corresponding to the question character in the reference question data, and the character vector is arranged according to the question character order of the question character; From the character vectors contained in each reference question vector, select the character vector corresponding to the last question character in the question character order; Gaussian distribution modeling is performed using the character vector corresponding to the last question character to obtain the Gaussian model of the target attention layer.
6. The data processing method according to any one of claims 1 to 3, wherein the reference problem data includes a plurality of positive reference problem data and a plurality of negative reference problem data, and the reference problem vector includes a positive reference problem vector and a negative reference problem vector; The step of using the target attention layer to perform attention processing on the reference question data to obtain the reference question vector output by the target attention layer includes: Each attention layer is used to perform attention processing on the multiple positive reference problem data to obtain the positive reference problem vector of each positive reference problem data output by each attention layer; Each attention layer is used to perform attention processing on the multiple negative reference problem data to obtain the negative reference problem vector of each negative reference problem data output by each attention layer; From the positive reference problem vector, determine the positive reference problem vector of each positive reference problem data output by the target attention layer, and from the negative reference problem vector, determine the negative reference problem vector of each negative reference problem data output by the target attention layer.
7. The data processing method according to claim 6, wherein the data model includes a positive Gaussian model and a negative Gaussian model; The step of modeling the target attention layer based on the reference question vector to obtain a data model includes: From the reference problem vector, determine the positive reference problem vector for multiple positive reference problem data and the negative reference problem vector for multiple negative reference problem data. The positive reference question vector contains character vectors corresponding to positive question characters in the positive reference question data, and the character vectors corresponding to the positive question characters are arranged according to the question character order of the positive question characters. The negative reference question vector contains character vectors corresponding to negative question characters in the negative reference question data, and the character vectors corresponding to the negative question characters are arranged according to the negative question character order of the negative question characters. From the character vectors contained in each positive reference question vector, determine the last positive question character in the question character order of the positive question characters, and determine the character vector corresponding to the last positive question character as a partial positive character vector; From the character vectors contained in each negative reference question vector, determine the last negative question character in the question character sequence of the negative question characters, and determine the character vector corresponding to the last negative question character as a partial negative character vector; The positive Gaussian model of the target attention layer is obtained by using the partial positive character vectors to perform Gaussian distribution modeling, and the negative Gaussian model of the target attention layer is obtained by using the partial negative character vectors to perform Gaussian distribution modeling.
8. The data processing method according to any one of claims 1 to 7, further comprising, after adjusting the initial language generation model according to the data model to obtain the target language generation model: Identify the data to be processed; Using the target language generation model, an answer is generated based on the question data to be processed, and the target answer is obtained.
9. The data processing method according to claim 8, wherein the step of generating an answer based on the question data to be processed using the target language generation model to obtain a target answer includes: The problem data to be processed is input into the target language generation model, and attention processing is performed on the problem data using multiple attention layers in the target language generation model to obtain the problem vector of the problem to be processed output by each attention layer. From the plurality of attention layers, determine the target attention layer and other attention layers besides the target attention layer, and from the plurality of question vectors, determine the target question vector output by the target attention layer and other question vectors output by the other attention layers; Using the data model, the target problem vector is transformed to obtain the transformed target problem vector; The target answer is generated based on the transformed target question vector and the other question vectors.
10. The data processing method according to claim 9, wherein the data model is a Gaussian model; The step of using the data model corresponding to the target attention layer to perform data transformation on the target question vector to obtain the transformed target question vector includes: Determine the Gaussian model corresponding to the target attention layer; Based on the Gaussian model, a Gaussian transformation is performed on the target problem vector to obtain the transformed target problem vector.
11. The data processing method according to claim 9, wherein the data model includes a positive Gaussian model and a negative Gaussian model; The step of using the data model corresponding to the target attention layer to perform data transformation on the target question vector to obtain the transformed target question vector includes: Determine the positive Gaussian model and the negative Gaussian model corresponding to the target attention layer; From the positive Gaussian model and the negative Gaussian model, a target Gaussian model is selected, and based on the target Gaussian model, a Gaussian transformation is performed on the target problem vector to obtain the transformed target problem vector.
12. The data processing method according to any one of claims 9 to 11, wherein generating the answer based on the transformed target question vector and the other question vectors to obtain the target answer includes: The transformed target question vector and the other question vectors are concatenated to obtain the target question vector; The target answer is obtained by using the output layer of the target language generation model to generate an answer to the target question vector.
13. The data processing method according to any one of claims 8 to 12, further comprising, before generating an answer using the target language generation model: Preprocessing of the data to be processed includes, but is not limited to, word segmentation, stop word removal, and converting the problem into a vector representation; Pre-trained language models are used to initially encode the pre-processed problem data in order to extract feature information; The extracted feature information, along with the question data to be processed, is input into the target language generation model to enhance the accuracy of answer generation.
14. The data processing method according to any one of claims 1-13, further comprising: Key attention heads in the initial language generation model were identified through path patch analysis. After intervening with the key attention head, observe the changes in the output of the initial language generation model to verify the importance of the key attention head for specific types of tasks; Based on the verification results, the key attention head is optimized in a targeted manner, thereby improving the performance of the target language generation model when performing specific types of tasks.
15. A problem-solving method, comprising: Identify the issues to be addressed; Using a target language generation model containing multiple attention layers, an answer is generated based on the question to be processed to obtain a target answer, wherein the target language generation model is the target language generation model of any one of claims 1 to 12.
16. A problem-solving method, comprising: Identify the issues to be addressed, including smart healthcare issues and smart city service issues; Using a target language generation model containing multiple attention layers, an answer is generated based on the question to be processed to obtain a target answer. The target language generation model is any one of the target language generation models in claims 1 to 12. The target answer includes the answer to the medical question corresponding to the smart healthcare question and the answer to the city service question corresponding to the smart city service question.
17. A data processing method for improving the performance of large language models, comprising: Collect positive and negative sample datasets for different types of problem-solving tasks; Causal analysis was used to identify key attention layers associated with various types of problem-solving tasks. Based on the identified key attention layers, construct the corresponding Gaussian mixture model; The new question data is transformed using a constructed Gaussian mixture model, and the transformed data is then input into a large language model to optimize its performance on different tasks, ensuring that the output answers better meet human preferences and expectations.
18. A computing device, comprising: Memory and processor; The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions, which, when executed by the processor, implement the steps of the method according to any one of claims 1 to 17.
19. A computer-readable storage medium storing a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 17.
20. A computer program product comprising a computer program / instructions that, when executed by a processor, implement the steps of the method according to any one of claims 1 to 17.
Citation Information
Patent Citations
Deep-learning-based method for intermittent process fault detection
CN109116834A
Dialogue generation method and device based on multi-layer attention, equipment and medium
CN116644164A
Transform model compression method based on Attention header importance
CN117391152A
Feature extraction method and device of large language model, computer equipment and medium
CN117708568A
Unsupervised image-based anomaly detection using multi-scale context-dependent deep autoencoding gaussian mixture model
US20190244337A1
Cited By
Question-answering methods, devices, equipment, and media for smart city platforms based on large models
CN122334517A