Text processing model adjusting method and device and text processing method and device
By obtaining intermediate features and prediction results from the text processing model, determining the network layer set, and adjusting the target network layer, the problem of high adjustment cost of the text processing model is solved, achieving performance improvement and cost reduction.
Patent Information
- Application Number
- CN202411164753.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-22
- Publication Date
- 2026-03-03
AI Technical Summary
The performance optimization and bias correction of existing text processing models are limited, and they cannot be adjusted reasonably and at low cost, especially since large-scale model training is costly.
By obtaining the intermediate features and predicted text processing results of the text processing model on the target text sample, multiple network layer sets are determined, and the target network layer is precisely adjusted according to the preset model and task adjustment, thus avoiding model training.
It improves the performance of text processing models, reduces tuning costs, and enhances the accuracy of text processing results and user trust.
Smart Images

Figure CN121599086A_ABST
Abstract
Description
Technical Field
[0001] This specification relates to the field of computer technology, and in particular to a method for adjusting a text processing model. One or more embodiments of this specification also relate to a text processing method, a text processing model adjustment device, and a text processing apparatus. Background Technology
[0002] In-Context Learning (ICL) is a method that uses contextual information to learn text and can be applied to text processing models to achieve more flexible text processing.
[0003] Currently, due to the unclear internal mechanism of context learning, it is impossible to reasonably adjust the text processing model itself without model training. This limits the performance optimization and bias correction of the text processing model. However, adjusting the text processing model through large-scale model training will bring high training costs. Therefore, there is an urgent need for a reasonable and low-cost technical solution to adjust the text processing model to solve the above technical problems. Summary of the Invention
[0004] In view of this, embodiments of this specification provide a method for adjusting a text processing model. One or more embodiments of this specification also relate to a text processing method, a text processing model adjustment device, a text processing apparatus, a computing device, a computer-readable storage medium, and a computer program product, to address the technical deficiencies in the prior art that prevent reasonable and low-cost adjustment of text processing models.
[0005] According to a first aspect of the embodiments of this specification, a text processing model adjustment method is provided, comprising:
[0006] The text processing model is defined, and the text processing model performs multiple text processing stages on the target text sample. The text processing model is a machine learning model.
[0007] The text processing model performs text processing on the target text sample, and the predicted text processing result and intermediate features generated during the text processing are obtained. The intermediate features are the intermediate output results of multiple network layers of the text processing model.
[0008] Based on the intermediate features, the predicted text processing results, and the target text sample, determine the set of network layers corresponding to the multiple text processing stages from the multiple network layers of the text processing model;
[0009] According to the preset model, the task is adjusted by determining the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjusting the target network layer to obtain the adjusted text processing model.
[0010] According to a second aspect of the embodiments of this specification, a text processing method is provided, comprising:
[0011] Receive text to be processed sent by the client, wherein the text to be processed is generated in response to a user's trigger operation on the client's graphical interface;
[0012] The text to be processed is processed using a text processing model to obtain a text processing result, wherein the text processing model is obtained according to the text processing model adjustment method described above;
[0013] The text processing result is sent to the client so that the client can display the text processing result to the user through a graphical user interface.
[0014] According to a third aspect of the embodiments of this specification, an information processing method based on a text processing model is provided, applied to a task platform, comprising:
[0015] The device receives a model request sent by a terminal device, wherein the model request includes at least one of the following: a scene identifier of the target scene, scene input data of the target scene, and model specification parameters.
[0016] Based on the model request, a target text processing model is determined from multiple text processing models, wherein the multiple text processing models are adjusted based on the method described above.
[0017] According to a fourth aspect of the embodiments of this specification, a text processing model adjustment apparatus is provided, comprising:
[0018] The preprocessing module is configured to determine a text processing model and multiple text processing stages in which the text processing model processes the target text sample, wherein the text processing model is a machine learning model;
[0019] The feature analysis module is configured to acquire the predicted text processing result determined by the text processing model when processing the target text sample, as well as the intermediate features generated during the text processing, wherein the intermediate features are the intermediate output results of multiple network layers of the text processing model.
[0020] The network layer partitioning module is configured to determine the set of network layers corresponding to the multiple text processing stages from multiple network layers of the text processing model based on the intermediate features, the loss function, the predicted text processing result, and the target text sample.
[0021] The adjustment module is configured to adjust the task according to a preset model, determine the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjust the target network layer to obtain the adjusted text processing model.
[0022] According to a fifth aspect of the embodiments of this specification, a text processing apparatus is provided, comprising:
[0023] The receiving module is configured to receive text to be processed sent by the client, wherein the text to be processed is generated in response to a user's trigger operation on the client's graphical interface.
[0024] The processing module is configured to process the text to be processed using a text processing model to obtain a text processing result, wherein the text processing model is obtained according to the above-mentioned text processing model adjustment method;
[0025] The sending module is configured to send the text processing result to the client, so that the client can display the text processing result to the user through a graphical user interface.
[0026] According to a sixth aspect of the embodiments of this specification, a computing device is provided, comprising:
[0027] Memory and processor;
[0028] The memory is used to store computer programs / instructions, and the processor is used to execute the computer programs / instructions. When the computer programs / instructions are executed by the processor, they implement the steps of the above-mentioned text processing model adjustment method.
[0029] According to a seventh aspect of the embodiments of this specification, a computer-readable storage medium is provided that stores a computer program / instructions that, when executed by a processor, implement the steps of the text processing model adjustment method described above.
[0030] According to an eighth aspect of the embodiments of this specification, a computer program product is provided, including a computer program / instructions that, when executed by a processor, implement the steps of the text processing model adjustment method described above.
[0031] This specification provides a text processing model adjustment method in one embodiment. This method acquires intermediate features and predicted text processing results generated during the text processing of a target text sample by the text processing model. Based on these features, the multiple network layers of the text processing model are divided into stages to obtain multiple network layer sets. When it is necessary to adjust the text processing model, a target network layer is precisely determined from the multiple network layer sets according to a preset model adjustment task. By adjusting this target network layer, the text processing model can be adjusted without model training. This achieves the technical effect of improving the performance of the text processing model while reducing the cost of improving its performance. Attached Figure Description
[0032] Figure 1 This is a specific application scenario diagram of a text processing model adjustment method provided in one embodiment of this specification;
[0033] Figure 2 This is a flowchart illustrating a text processing model adjustment method provided in one embodiment of this specification;
[0034] Figure 3a This is a schematic diagram of the text processing stage of a text processing model adjustment method provided in one embodiment of this specification;
[0035] Figure 3b This is a flowchart illustrating the network layer determination and verification of a text processing model adjustment method provided in one embodiment of this specification;
[0036] Figure 4 This is a saliency matrix diagram illustrating a text processing model adjustment method provided in one embodiment of this specification;
[0037] Figure 5 This is a schematic diagram illustrating the blocking of a text processing model adjustment method provided in one embodiment of this specification;
[0038] Figure 6 This is a schematic diagram of the matching mapping rule stage positioning of a text processing model adjustment method provided in one embodiment of this specification;
[0039] Figure 7 This is a schematic diagram illustrating the interference effect of the matching mapping rule stage in a text processing model adjustment method provided in one embodiment of this specification;
[0040] Figure 8 This is a flowchart illustrating a text processing method provided in one embodiment of this specification;
[0041] Figure 9 This is a schematic diagram of the structure of a text processing model adjustment device provided in one embodiment of this specification;
[0042] Figure 10 This is a schematic diagram of the structure of a text processing device provided in one embodiment of this specification;
[0043] Figure 11 This is a structural block diagram of a computing device provided in one embodiment of this specification. Detailed Implementation
[0044] Many specific details are set forth in the following description to provide a full understanding of this specification. However, this specification 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 specification. Therefore, this specification is not limited to the specific implementations disclosed below.
[0045] The terminology used in one or more embodiments of this specification is for the purpose of describing particular embodiments only and is not intended to be limiting of the one or more embodiments of this specification. The singular forms “a,” “described,” and “the” as used in one or more embodiments of this specification 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 specification refers to and includes any or all possible combinations of one or more associated listed items.
[0046] 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 specification, 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 specification, 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," "when," or "in response to a determination."
[0047] 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 specification 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.
[0048] In one or more embodiments of this specification, 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.
[0049] 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 natural language processing 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.
[0050] First, the terms and concepts used in one or more embodiments of this specification will be explained.
[0051] Large Language Model (LLM): A natural language processing model based on the Transformer architecture, which uses text data to perform word-by-word sequence prediction. Its characteristics are that it acquires extensive knowledge and basic language abilities through self-supervised pre-training on corpora and supervised fine-tuning on a small amount of high-quality data. Chat dialogue assistants based on large language models are receiving increasing attention.
[0052] Multi-Layer Perceptron (MLP) layer: In large language models, each Transformer layer contains a Multi-Layer Perceptron (MLP) layer. The MLP layer usually consists of two fully connected layers with a non-linear activation function in between. They are used to perform non-linear transformations on the input features, enhancing the expressive power of the model (i.e., the large language model). The role of the MLP layer is to further extract and transform features from the information processed by the attention mechanism.
[0053] Attention layer: The attention layer is the core component of the Transformer architecture, used to capture the dependencies between different positions in the input sequence. By calculating the attention weights between different positions, the attention layer can focus on important information, improving the model's understanding and generation capabilities. Specifically, when processing a word, the attention layer will refer to the information of other words in the input sequence in order to better understand the meaning of the word in the context.
[0054] The head inside the Attention layer (head is the attention head): In the Attention layer, a multi-head attention mechanism is usually used. Each attention head independently calculates a set of attention weights to capture the dependencies in the input sequence from different perspectives. These independent attention heads can be regarded as different subspace mappings. Through parallel computation, the model can represent the input information more richly. The outputs of each attention head are eventually concatenated, linearly transformed, and used for subsequent calculations.
[0055] Attention Matrix: The attention matrix is the core result calculated in the attention layer; it represents the influence weight of words at different positions in the input sequence on the current word; each element of the matrix reflects the degree of attention one word pays to another; through the attention matrix, the model can dynamically adjust the relationship between words in the input sequence, and more efficiently pass more important information to subsequent layers.
[0056] In summary, large language models enhance language understanding and generation capabilities through multi-layered MLP layers and multi-head attention layers in the Transformer architecture; the Attention layer and its internal attention heads and attention matrices enable the model to efficiently handle complex dependencies in sequential data, greatly improving the model's natural language processing capabilities; these internal mechanisms work together to enable large language models to perform well in various tasks.
[0057] In-Context Learning (ICL) is a learning method that utilizes contextual information and is commonly used in large language models. By providing examples and questions as input sequences to the model (i.e., the large language model), the model can understand the task and generate corresponding outputs from contextual cues without explicit parameter tuning. Its characteristic is that it can perform instant reasoning and responses based on a small number of example cues without a traditional training process, thus demonstrating excellent generalization ability and flexibility in handling specific tasks. In-Context Learning is gradually becoming an important technical means for developing intelligent dialogue systems and solving complex tasks.
[0058] Prompt: In In-Context Learning (ICL), a prompt refers to the initial input information provided to the model, including the question and possible background knowledge or context. Through prompts, the model can obtain key information to understand the requirements of the task and generate corresponding answers. The design and content of prompts have a significant impact on the performance of the model. Its characteristic is that it does not require explicit parameter tuning, but enables the model to reason and generate results in new tasks simply by providing contextual information. Prompt technology is gradually becoming an important means of guiding large language models to perform diverse tasks.
[0059] Example (demonstration): In In-Context Learning (ICL), a demonstration refers to several examples included in the input sequence for the model to reference. These examples show input-output pairs relevant to the task the model needs to process, thus providing the model with explicit operational steps or answer formats. Through these examples, the model can learn task-related mapping rules from the examples and apply them to new tasks. The core advantage of demonstrations is that, without the need for traditional training processes, a small number of example prompts can significantly improve the model's understanding and answering abilities, thereby enhancing its performance in handling specific tasks. For example, to test the question, we would find multiple sets (Question1 and Answer1, Question2 and Answer2, ...) as prompts; each (Question-n and Answer-n) represents a demonstration.
[0060] With the development of large language models, their capabilities have sparked a surge of research into their internal mechanisms. Large language models rely on the Transformer architecture and, through self-supervised pre-training and fine-tuning with a small amount of high-quality data, have mastered a wide range of knowledge and language abilities, demonstrating strong generalization capabilities. Among them, In-Context Learning (ICL), as an important learning method, has attracted much attention.
[0061] ICL utilizes contextual information for task processing without requiring explicit parameter tuning or retraining. By providing examples and relevant questions, the model can obtain cues from the context and perform tasks, improving the model's flexibility and applicability. However, the internal mechanisms of ICL are not yet clear, which limits the ability to optimize performance and correct biases. Understanding the mechanisms of ICL is of great significance, as it can enhance trust and transparency, and detect and correct model biases.
[0062] In view of this, this specification provides a text processing model adjustment method, and also relates to a text processing method, a text processing model adjustment device, a text processing apparatus, a computing device, a computer-readable storage medium, and a computer program product, which will be described in detail in the following embodiments.
[0063] Considering the large number of model parameters in large models and the limited computing resources of mobile terminals, the text processing model adjustment method provided in this application can be applied to, for example, Figure 1 The application scenarios shown are not limited to these. In, for example... Figure 1 In the application scenario shown, the large model is deployed on server 104, which includes, but is not limited to, physical servers, cloud servers, etc. Server 104 can connect to one or more clients 102 via LAN, WAN, Internet, or other types of data networks. Clients 102 can include, but are not limited to, smartphones, tablets, laptops, PDAs, personal computers, smart home devices, and in-vehicle devices. Clients 102 can interact with users through a graphical user interface, enabling server 104 to access the large model and thus implement the method provided in the embodiments of this specification.
[0064] In this embodiment of the specification, server 104 adjusts the text processing model, and the following steps are performed:
[0065] The text processing model is defined, and the text processing model performs multiple text processing stages on the target text sample. The text processing model is a machine learning model.
[0066] The text processing model performs text processing on the target text sample, and the predicted text processing result and intermediate features generated during the text processing are obtained.
[0067] Based on the intermediate features, the predicted text processing results, and the target text sample, determine the set of network layers corresponding to the multiple text processing stages from the multiple network layers of the text processing model;
[0068] According to the preset model, the task is adjusted by determining the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjusting the target network layer to obtain the adjusted text processing model.
[0069] After obtaining the adjusted text processing model, the server 104 can receive the target text sent by the client 102, process the target text using the adjusted text processing model to obtain the text processing result, and send the text processing result to the client 102. The client 102 displays the text processing result to the user through a graphical interactive interface to meet the user's text processing needs.
[0070] It should be noted that, provided that the client's runtime resources can meet the deployment and operation conditions of the large model, the embodiments of this application can be carried out on the client. In addition, the large model can also be deployed on a third-party server, including but not limited to third-party physical servers, third-party cloud servers, etc.
[0071] This specification provides an embodiment of a text processing model adjustment method. The server acquires intermediate features, loss functions, and predicted text processing results generated during the text processing of a target text sample by the text processing model. Based on this, it divides multiple network layers of the text processing model into multiple sets of network layers according to stages. When the text processing model needs adjustment, according to a preset model adjustment task, it accurately determines the more critical network layer, i.e., the target network layer, from the multiple network layer sets. By adjusting this target network layer, the text processing model is adjusted without requiring model training. This achieves the technical effect of improving the performance of the text processing model while reducing the cost of performance improvement, thereby improving the accuracy of the text processing results displayed to the user by the client and increasing user trust.
[0072] See Figure 2 , Figure 2 A flowchart of a text processing model adjustment method according to an embodiment of this specification is shown, which specifically includes the following steps.
[0073] Step 202: Determine the text processing model and the multiple text processing stages by which the text processing model processes the target text sample, wherein the text processing model is a machine learning model.
[0074] Specifically, text processing models can be understood as machine learning models used for text processing, such as large language models and multimodal pre-trained models.
[0075] The text processing stage can be understood as the processing stage divided by different context learning functions during the context learning process of the text processing model to process the target text sample. For example, the text processing stage can be the mapping rule construction stage, the mapping rule matching stage, the decoding output result stage, etc. A text processing stage can contain one or more network layers. A network layer can be understood as containing the encoding layer and decoding layer of the text processing model.
[0076] In practical applications, the text processing stages of a text processing model can be determined by analyzing its execution process. The specific implementation method is as follows:
[0077] The defined text processing model and the multiple text processing stages in which the text processing model processes the target text sample include:
[0078] Determine the text processing model;
[0079] The intermediate features generated by the text processing model during the text processing of the target text sample are obtained, and the intermediate text corresponding to the intermediate features is determined.
[0080] The intermediate text is analyzed to obtain the analysis results;
[0081] Based on the analysis results, multiple text processing stages are determined for the text processing model to process the target text sample.
[0082] Specifically, in LLMs, the key principal components embedded in the intermediate layer encode human-interpretable task-related words, such as "harsh" and "joy" for sentiment analysis, and "rating" and "opinion" for subjective and objective sentence classification. Based on this, the ICL process can be divided into three subsequent steps: based on the relational abstraction input-label mapping in the example, the mapping is matched to the new question, that is, there are multiple text processing stages, which can be the mapping rule construction stage, the mapping rule matching stage, and the decoding output result stage.
[0083] This specification provides a text processing model adjustment method in one embodiment. By observing and verifying intermediate features, multiple text processing stages of the text processing model are determined, making the text processing model interpretable to a certain extent. This allows subsequent adjustments to the text processing model based on multiple text processing stages, thereby improving the accuracy of the text processing model.
[0084] Step 204: Obtain the predicted text processing result and intermediate features generated during the text processing process by the text processing model on the target text sample.
[0085] Specifically, the implementation method for obtaining the parameters of each text processing model during text processing is as follows:
[0086] The target text sample includes the target text, the target text processing result corresponding to the target text, the example text, and the example text processing result corresponding to the example text.
[0087] The step of obtaining the text processing model to process the target text sample, determining the predicted text processing result, and the intermediate features generated during the text processing includes:
[0088] The target text, the target text processing result, the example text, and the example text processing result are input into the text processing model.
[0089] In the text processing model, text processing is performed on the target text, the example text, and the example text processing result to obtain the predicted text processing result corresponding to the target text and the intermediate features generated during the text processing. The intermediate features are the intermediate features generated by the text processing model in each network layer during the text processing.
[0090] Specifically, after obtaining the predicted text processing result corresponding to the target text, the following can also be done:
[0091] Based on the target text processing result and the corresponding predicted text processing result, the loss value of the text processing model is obtained using a loss function.
[0092] The target text sample includes the target text to be predicted, the target text processing result that the text processing model should theoretically output as the prompt text for the text processing model to use as an example, one or more example texts, and the example text processing result corresponding to the example text.
[0093] Intermediate features can be understood as intermediate outputs of network layers. For example, intermediate features can be understood as the attention matrix of the attention module in a network layer.
[0094] Based on this, the target text, the target text processing result, the example text, and the example text processing result are input into the text processing model. Based on the mapping rule between the example text and the example text processing result, the text processing model can predict the target text and obtain the predicted text processing result. It can also use a loss function to obtain the loss value between the predicted text processing result and the target text processing result. The loss function includes, but is not limited to, the entropy increase function, the cross-entropy loss function, etc. The specific calculation method will not be elaborated.
[0095] This specification provides an embodiment of a text processing model adjustment method, which uses a text processing model to process text and obtains model running parameters such as intermediate features and loss functions during the text processing process, making subsequent interpretability analysis of the text processing model more accurate.
[0096] Step 206: Based on the intermediate features, the predicted text processing results, and the target text sample, determine the set of network layers corresponding to the multiple text processing stages from the multiple network layers of the text processing model.
[0097] The network layer set can be understood as a set containing one or more network layers.
[0098] In practical applications, we can first analyze and determine the multiple text processing stages of the text processing model in order to more accurately explain the execution logic of the text processing model. The specific implementation method is as follows:
[0099] The multiple text processing stages include a first text processing stage and a second text processing stage;
[0100] The step of determining the set of network layers corresponding to the multiple text processing stages from multiple network layers of the text processing model based on the intermediate features, the predicted text processing result, and the target text sample includes:
[0101] Based on the predicted text processing results and the target text processing results in the target text samples, the loss value of the text processing model is obtained;
[0102] Based on the intermediate features and the loss value, the set of first network layers corresponding to the first text processing stage is determined from multiple network layers of the text processing model.
[0103] Based on the predicted text processing results and the target text sample, the set of second network layers corresponding to the second text processing stage is determined from multiple network layers of the text processing model.
[0104] The first text processing stage can be understood as the text processing stage used to construct mapping rules, and the second text processing stage can be understood as the text processing stage used to match the mapping rules. That is, the first text processing stage can learn the mapping rules from the example text and the example text processing result to the example text, and the second text processing stage can predict the target text according to the above mapping rules.
[0105] In practical applications, since the objects processed internally by the model are vectors, a third text processing stage can exist to facilitate the output of text results from the model. This stage is used to decode the predicted vectors into text, that is, to decode them into text processing results that can be displayed by the client.
[0106] In practice, the analysis of intermediate features and loss values can be used to determine the network layers in the text processing model that focus on the mapping rule establishment process, i.e., the set of first network layers corresponding to the first text processing stage.
[0107] Regardless of the order, the predicted text processing results can be used to backtrack to the target text sample, thereby analyzing and obtaining the key network layer that maps the target text sample to the predicted text processing results, that is, the set of second network layers corresponding to the second text processing stage. Specifically, in this process, the key attention heads can be specifically determined by the attention heads as the dimension, so that the text processing model can be adjusted more specifically and within a smaller scope in the future.
[0108] Specifically, after obtaining the intermediate features, loss values, and predicted text processing results generated by the text processing model during text processing, the analysis of these intermediate features, loss values, and predicted text processing results can determine which network layers of the text processing model performed mapping rule construction, mapping rule matching, or decoding. Based on this, the network layers of the text processing model can be divided to determine the network layer set corresponding to each text processing stage in multiple text processing stages. For example, if mapping rule construction was performed in network layers 1-10, mapping rule matching was performed in layers 11-25, and decoding was performed in layers 16-32, then network layers 1-10 are divided into the first network layer set, network layers 11-25 are divided into the second network layer set, and network layers 16-32 are divided into the third network layer set.
[0109] This specification provides a text processing model adjustment method in one embodiment. By analyzing intermediate features and loss values, a first set of network layers is obtained, making the network layers in the first set capable of mapping rule analysis, thereby improving the accuracy of the first set of network layers. Based on the mapping path between the predicted text processing result and the target text sample, a second set of network layers is determined, ensuring that the obtained second set of network layers is the network layer that plays a role in the mapping process, thereby improving the accuracy of the second set of network layers.
[0110] In practical applications, intermediate features can be adjusted using a loss function to accurately locate the first text processing stage of the text processing model. The specific implementation method is as follows:
[0111] The intermediate features are the intermediate features of each network layer in multiple network layers generated during the text processing process of the target text sample by the text processing model.
[0112] The step of determining the set of first network layers corresponding to the first text processing stage from multiple network layers of the text processing model based on the intermediate features and the loss value includes:
[0113] Based on the loss function, gradient backpropagation is performed on the intermediate features of each network layer to determine the gradient corresponding to the intermediate features of each network layer.
[0114] Based on the intermediate features of each network layer and the gradients corresponding to the intermediate features of each network layer, determine the correlation matrix corresponding to the intermediate features of each network layer;
[0115] Based on the correlation matrix corresponding to the intermediate features of each network layer, the association between the example text corresponding to each network layer and the example text processing result corresponding to the example text is determined, wherein the example text is the example text contained in the target text sample;
[0116] Among the multiple network layers, the network layer whose association relationship satisfies the preset association relationship is determined as the first network layer corresponding to the first text processing stage, and the first network layer set is constructed based on the first network layer.
[0117] Gradient backpropagation can be understood as calculating the gradient of the loss value relative to each intermediate feature (i.e., the intermediate features of each network layer). Through gradient backpropagation, the gradient of the loss value relative to each intermediate feature can be obtained, that is, the gradient corresponding to the intermediate features of each network layer can be obtained.
[0118] A correlation matrix can be understood as a matrix containing the correlations between feature vectors corresponding to example texts, the correlations between feature vectors corresponding to example texts and feature vectors corresponding to the processed result of example texts, and the correlations between feature vectors corresponding to the processed result of instance texts. A correlation matrix can also be understood as a significance matrix.
[0119] The preset correlation can be understood as the correlation between the example text and the processing result of the example text corresponding to that example text being greater than or equal to other correlations.
[0120] Specifically, based on the correlation matrix, we can determine the factors (example text or example text processing result) that have a greater impact on the processing results of each example text. This allows us to determine the focus of the text processing model at each network layer, and thus determine the network layer used to construct the mapping rules in the text processing model, i.e., the first network layer corresponding to the first text processing stage.
[0121] This specification provides a text processing model adjustment method in one embodiment, which improves the accuracy of the determined first network layer set by quantifying the correlation between various factors to locate the network layer of the mapping rule.
[0122] In practical applications, the network layer set corresponding to the second text processing stage can be initially located by using intervention processing methods. The specific implementation method is as follows:
[0123] Each network layer contains multiple attention heads;
[0124] The step of determining the set of second network layers corresponding to the second text processing stage from multiple network layers of the text processing model based on the predicted text processing result and the target text sample includes:
[0125] Determine the simulated text sample corresponding to the target text sample, and sequentially determine the target attention head from the multiple attention heads contained in each network layer;
[0126] Based on the simulated text sample and the target attention head, the text processing model is adjusted to process the target text sample to obtain the adjusted text processing result;
[0127] Based on the adjusted text processing results, the second network layer corresponding to the second text processing stage is determined from the plurality of network layers, and the set of second network layers corresponding to the second text processing stage is determined based on the second network layer.
[0128] The simulated text sample can be understood as a control sample of the target text sample. The simulated text sample is input into the text processing model, and the obtained text processing result is the opposite of or a different classification result from the above predicted text processing result. For example, if the target text sample is "I am very happy today", the simulated text sample can be understood as "I am very sad today". Another example is that if the target text sample is "There are many cars on the road", the simulated text sample can be understood as "There are very few cars on the road", and so on.
[0129] In practice, simulated text samples can be used to influence the target attention head. Since the target attention head will affect the output of the text processing model, influencing the target attention head with simulated text samples will significantly change the text processing process of the text processing model on the target text sample, thereby obtaining an adjusted text processing result that differs significantly from the predicted text processing result.
[0130] When the target attention head has no effect on the output of the text processing model, using simulated text samples to influence the target attention head will slightly change the text processing process of the text processing model on the target text sample, thereby obtaining an adjusted text processing result that has a small difference from the predicted text processing result.
[0131] Based on this, the network layers that play a role in the output of the text processing model can be selected according to the adjusted text processing results, namely the second network layers. Thus, the set of second network layers can be determined based on the second network layers, namely the set of second network layers corresponding to the second text processing stage.
[0132] This specification provides a text processing model adjustment method in one embodiment. By interfering with the attention heads in the network layer, it analyzes whether the text processing model provides more inaccurate output results, i.e., whether the accuracy is reduced significantly. It can be determined that the interference with the attention heads in the network layer is effective interference, thereby determining that the network layer plays an important role in the rule matching process. In this way, the judgment of the second network layer set is more accurate.
[0133] In practical applications, the specific implementation method of adjusting the text processing process using simulated text samples and target attention heads is as follows:
[0134] The text processing process of adjusting the text processing model to process the target text sample based on the simulated text sample and the target attention head, to obtain the adjusted text processing result, includes:
[0135] The target attention head is determined to process the simulated text sample, and the simulated text processing result is obtained;
[0136] The target attention head is used to process the target text sample to obtain the intermediate text processing result;
[0137] Replace the intermediate text processing result with the simulated text processing result;
[0138] The next layer attention head in the text processing model is determined based on the target attention head, and the simulated text processing result is used as the input of the next layer attention head to adjust the text processing process of the text processing model on the target text sample, thereby obtaining the adjusted text processing result.
[0139] The simulated text processing result can be obtained by inputting a simulated text sample into a text processing model, which then processes the simulated text sample. Based on the text processing process of the simulated text sample by the text processing model, the activation of the target attention head can be obtained, which is the simulated text processing result.
[0140] Similarly, the intermediate text processing results can be obtained from the text processing process of the text processing model on the target text sample, which will not be elaborated here.
[0141] Then, by replacing the intermediate text processing result with the simulated text processing result, the text processing process of the text processing model on the target text sample can be intervened, and the adjusted text processing model output after intervention can be obtained.
[0142] This specification provides a text processing model adjustment method in one embodiment, which intervenes in the text processing process by replacing the intermediate text processing result with the simulated text processing result. This allows for precise determination of the impact of the target attention on the predicted text processing result, thereby further improving the accuracy of positioning in the second text processing stage.
[0143] In practical applications, to accurately select the second network layer, the accuracy of the text processing results can be used as the selection criterion. The specific implementation method is as follows:
[0144] The step of determining the second network layer corresponding to the second text processing stage from the plurality of network layers based on the adjusted text processing result includes:
[0145] Based on the accuracy of the adjusted text processing result and the accuracy of the preset text processing result, the degree of difference in the processing result is determined;
[0146] Based on the degree of difference in the processing results, a second attention head is selected from the plurality of attention heads, and the network layer containing the second attention head is determined as the second network layer corresponding to the second text processing stage.
[0147] The degree of difference in processing results can be determined by calculating the ratio of the difference between the accuracy of the adjusted text processing result and the accuracy of the preset text processing result to the accuracy of the preset text processing result. Alternatively, it can be determined by adjusting the difference between the accuracy of the adjusted text processing result and the accuracy of the preset text processing result. The specific settings can be configured according to actual needs.
[0148] In practice, based on the degree of difference in the processing results corresponding to each target attention head, a preset number of target attention heads with a higher degree of difference can be determined as second attention heads, thereby determining the network layer containing the second attention heads as the second network layer corresponding to the second text processing stage.
[0149] This specification provides a text processing model adjustment method in one embodiment, which further improves the accuracy of positioning in the second text processing stage by precisely analyzing the effect of target attention based on the changes in the accuracy of the text processing results.
[0150] In practical applications, the first and second network layer sets can be finely demarcated to improve the accuracy of stage positioning. The specific implementation method is as follows:
[0151] After determining the set of first network layers corresponding to the first text processing stage from multiple network layers of the text processing model based on the intermediate features and the loss value, the method further includes:
[0152] Based on the first set of network layers, multiple candidate boundary network layers are determined from the multiple network layers of the text processing model;
[0153] Obtain the hidden layer features of each candidate boundary network layer, and perform principal component analysis on the hidden layer features of each candidate boundary network layer to obtain the principal component features and principal component feature values corresponding to the hidden layer features of each candidate boundary network layer.
[0154] Based on the principal component features and principal component feature values corresponding to the hidden layer features of each candidate boundary network layer, the target boundary network layer is selected from the multiple candidate boundary network layers.
[0155] The set of network layers corresponding to the first text processing stage is updated according to the target boundary network layer to obtain the updated set of the first network layers corresponding to the first text processing stage.
[0156] Among them, multiple candidate boundary network layers can be understood as including the last network layer of the first network layer set and the adjacent network layers of the layer above and below the last network layer. For example, if the first network layer set is 1-18, then multiple candidate boundary network layers can be understood as 17, 18, and 19.
[0157] In one or more embodiments of this specification, multiple candidate boundary network layers can also be understood as including the last network layer of the first network layer set, the adjacent network layer above and below the last network layer, and the network layer above and below the adjacent network layer. For example, if the first network layer set is 1-18, then multiple candidate boundary network layers can be understood as 16, 17, 18, 19, and 20.
[0158] In one or more embodiments of this specification, the multiple candidate boundary network layers can also be understood as all network layers of the text processing model, which will not be elaborated further.
[0159] Specifically, principal component analysis can be performed on the intermediate outputs of multiple candidate boundary network layers (feature vectors passed from the candidate boundary network layers to the next layer), and the presence or absence of mapping of principal components can be used to verify whether the second text processing stage has been entered. This can not only improve the accuracy of the boundary but also reduce resource consumption.
[0160] In practical applications, it is also possible to directly analyze all intermediate features of multiple candidate boundary network layers to see if a mapping signal has appeared, thereby verifying whether the second text processing stage has been entered, thus improving the accuracy of the boundary.
[0161] This specification provides a text processing model adjustment method in one embodiment. By performing refined mapping analysis on the critical layers of the first network layer set and the second network layer set, and verifying the precise boundary points, the accuracy of the boundary points between the first network layer set and the second network layer set is improved. Furthermore, by using principal component analysis, the resource consumption for accurately determining the boundary points is reduced.
[0162] In practical applications, multiple candidate boundary network layers can also be understood as containing the last network layer of the first network layer set and the adjacent network layers above and below the last network layer. The specific implementation is as follows:
[0163] The step of determining multiple candidate boundary network layers from multiple network layers of the text processing model based on the first set of network layers includes:
[0164] Based on the first set of network layers, an initial boundary network layer is determined, wherein the initial boundary network layer has a higher level in the text processing model than the other network layers in the first set of network layers in the text processing model.
[0165] From the multiple network layers of the text processing model, determine the adjacent network layers of the initial boundary network layer;
[0166] The adjacent network layers of the initial boundary network layer and the initial boundary network layer are determined as the plurality of candidate boundary network layers.
[0167] The first set of network layers includes an initial boundary network layer, which can be understood as the last network layer in the first set of network layers.
[0168] Specifically, the level can be understood as the layer number, i.e., which layer; the two layers above and below the initial boundary network layer, as well as the initial boundary network layer, can be used as candidate boundary network layers. For specific implementation methods, please refer to the embodiments in the above specification.
[0169] This specification provides a text processing model adjustment method in one embodiment, which uses only the last network layer of the first network layer set and the adjacent network layers of the layer above and below the last network layer as candidate boundary network layers, without analyzing other network layers with low probability of boundary points, thereby further reducing the resource consumption of text processing model adjustment.
[0170] In practical applications, the accuracy of boundary layer determination can be improved by analyzing the text corresponding to the principal components. The specific implementation method is as follows:
[0171] The step of selecting the target boundary network layer from the multiple candidate boundary network layers based on the principal component features and principal component feature values corresponding to the hidden layer features of each candidate boundary network layer includes:
[0172] Based on the principal component feature values corresponding to the hidden layer features of each candidate boundary network layer, the principal component features corresponding to the hidden layer features of each candidate boundary network layer are sorted to obtain the sorting result;
[0173] Based on the sorting results and the preset retention quantity, multiple target principal component features are determined from each principal component feature;
[0174] Using the text processing model, the multiple target principal component features are transformed into text to obtain the transformed text corresponding to the multiple target principal component features;
[0175] The transformed text corresponding to the multiple target principal component features is determined as the transformed text corresponding to each candidate boundary network layer, and the target transformed text that meets the preset transformed text conditions is obtained from the transformed text corresponding to each candidate boundary network layer.
[0176] The candidate boundary network layer corresponding to the target converted text is determined as the target boundary network layer.
[0177] The eigenvalues corresponding to each principal component can be understood as the eigenvalues of each principal component in the attention matrix, symbolizing the strength of the effect of that principal component on the text processing model.
[0178] Text conversion can be achieved through vector-to-text technology or through the output projection matrix of a text processing model; there is no limitation on which method is used.
[0179] This specification provides a text processing model adjustment method in one embodiment. By sorting each principal component according to its eigenvalue, multiple target principal components with strong effects are obtained, thereby analyzing the target principal components. This not only reduces resource consumption but also improves the accuracy of principal component analysis.
[0180] In practical applications, the first network layer set can also be validated to improve its accuracy. The specific implementation method is as follows:
[0181] The intermediate features of each first network layer in the first network layer set are determined sequentially, and the target features of the intermediate features are zeroed out, thereby obtaining the zeroed text processing model.
[0182] The target text sample is processed according to the text processing model after each zeroing process, and the target first boundary network layer is determined from each first network layer based on the accuracy of the processing result.
[0183] Based on the target first boundary network layer, the set of first network layers corresponding to the first text processing stage is updated to obtain the updated set of first network layers corresponding to the first text processing stage.
[0184] Instruction processing can be understood as the process of replacing one or more feature values in the intermediate features with zero.
[0185] Target features can be understood as features located in a preset position among intermediate features, such as one, multiple, or all features that characterize the correlation between the example text and the example text processing result.
[0186] Specifically, the correlation between the example text and the example text processing result in the intermediate features can be blocked to determine whether it has an impact on the predicted text processing result. If it has an impact, the network layer is considered to be the first network layer. If it does not have a significant impact (e.g., the rate of change is lower than a preset threshold, 0.2, 0.3, etc.), the network layer is considered not to belong to the first network layer.
[0187] Based on this, it can be verified whether the above first network layer is accurate. If it is not accurate, the first network layer in the first network layer set can be updated by adding, deleting or other operations to obtain the first network layer set corresponding to the first text processing stage after the update.
[0188] This specification provides a text processing model adjustment method in one embodiment, which further improves the positioning accuracy of the first network layer set by verifying the network layer set corresponding to the first text processing stage after determining the network layer set corresponding to the first text processing stage.
[0189] In practical applications, the second network layer set can also be validated to improve its accuracy. The specific implementation method is as follows:
[0190] The intermediate features of each network layer in the text processing model are determined, and the intermediate features of each network layer are sequentially identified as target features.
[0191] The feature values representing different text processing results in the target features are swapped to obtain swapped features;
[0192] The target feature is replaced according to the replacement feature to adjust the text processing process of the text processing model on the target text sample, so as to obtain the adjusted text processing result;
[0193] Based on the accuracy of the adjusted text processing results, the target processing network layer is determined from the plurality of network layers;
[0194] Based on the target processing network layer, the set of second network layers corresponding to the second text processing stage is updated to obtain the updated set of second network layers corresponding to the second text processing stage.
[0195] Specifically, the numerical values of the features of the example text processing results in different categories can be swapped at the attention heads. The performance of the text processing model can be observed to decrease as a result of this swapping operation. The more drastic the decrease, the more accurate the module found. For example, as the number of swaps increases, the accuracy of the text processing model decreases. The accuracy of the 9th attention head in the 19th layer has already dropped to 20%, indicating that the 9th attention head in the 19th layer is relatively critical.
[0196] This specification provides a text processing model adjustment method in one embodiment, which further improves the positioning accuracy of the second network layer set by verifying the network layer set corresponding to the second text processing stage after determining the network layer set corresponding to the second text processing stage.
[0197] Step 208: Adjust the task according to the preset model, determine the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjust the target network layer to obtain the adjusted text processing model.
[0198] The target network layer can be understood as a network layer with the purpose of adjustment.
[0199] Specifically, different target network layers can be determined according to different tasks. The specific implementation method for one task is as follows:
[0200] The preset model adjustment task is a task to improve model accuracy.
[0201] The step of adjusting the task according to the preset model, determining the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjusting the target network layer to obtain the adjusted text processing model, includes:
[0202] Based on the model accuracy improvement task, the target boundary network layer is determined as the target network layer from the set of network layers corresponding to the multiple text processing stages;
[0203] Based on the multiple target principal component features, the hidden layer features of the target network layer are updated to obtain the adjusted text processing model.
[0204] Specifically, the specific implementation of the embodiments in this specification can be found in the specific implementation of the boundary layer determination in the first text processing stage described above, and will not be repeated here.
[0205] This specification provides a text processing model adjustment method in one embodiment. By filtering intermediate features at the end of the first text processing stage and the beginning of the second text processing stage, only some principal component components with larger feature values are retained. After filtering out principal components that are irrelevant to the mapping rules, subsequent inference continues. This improves the model accuracy without training the model and without incurring high training costs.
[0206] For another task, the specific implementation method is as follows:
[0207] The preset model adjustment task is a target text task adaptation task;
[0208] The step of adjusting the task according to the preset model, determining the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjusting the target network layer to obtain the adjusted text processing model, includes:
[0209] Based on the target text task adaptation task, the target processing network layer is determined as the target network layer;
[0210] Based on the predicted text processing results and the target text sample, the target network layer is adjusted to obtain the adjusted text processing model.
[0211] Specifically, the target processing network layer can be determined by referring to the above-described embodiments. Subsequently, the adjustment method of the target network layer can be adjusted according to the actual target text task, and this embodiment does not limit this.
[0212] This specification provides an embodiment of a text processing model adjustment method that determines the network layer and key attention heads corresponding to the matching mapping rules of the target task. This allows for precise adjustment of the model for the target task, making the model adjustment more targeted, improving the accuracy of model training, and avoiding the model's impact on other tasks.
[0213] This specification provides an embodiment of a text processing model adjustment method. This method acquires intermediate features, loss functions, and predicted text processing results generated during the text processing of a target text sample by the text processing model. Based on these features, the method divides multiple network layers of the text processing model into stages. When the text processing model needs adjustment, the method accurately identifies the more critical network layer (the target network layer) from the divided network layers according to the model adjustment task. By adjusting this target network layer, the text processing model can be adjusted without requiring model training. This achieves the technical effect of improving the performance of the text processing model while reducing its training cost.
[0214] The following description, in conjunction with Figure 3, uses the application of the text processing model adjustment method provided in this specification in a sentiment classification text processing task as an example to further illustrate the text processing model adjustment method. However, it is not limited to this. The text processing model adjustment method provided in the embodiments of this specification can also be applied to tasks including but not limited to text sentiment classification, subjective / objective sentence classification, hate speech detection, repeated question identification, question classification, text entailment identification, financial sentiment analysis, etc. Furthermore, the embodiments of this specification use a large language model with 32 network layers as an example for illustrative purposes. For specific implementation methods of text processing model adjustment in other text processing models and / or other application scenarios, please refer to the embodiments of this specification.
[0215] in, Figure 3a This diagram illustrates the text processing stage of a text processing model adjustment method provided in one embodiment of this specification.
[0216] like Figure 3a As shown, the text processing model in this embodiment can be divided into three stages to achieve context learning for text processing: the mapping rule construction stage, the mapping rule matching stage, and the decoding output result stage. For details on the determination of the network layers corresponding to these three stages and the verification methods, please refer to [link to documentation]. Figure 3b The steps included, among which, Figure 3bThe flowchart illustrates a text processing model adjustment method, including network layer determination and verification, provided in an embodiment of this specification.
[0217] Step 302: Determine the sample.
[0218] Here, the determined sample can be understood as the sample to be processed by the text processing model.
[0219] Specifically, before locating the three stages of the large language model, we first determine multiple samples for text processing by the large language model. Each sample contains the target text, the text processing result corresponding to the target text, and multiple examples related to the sentiment classification text processing task. Each example contains the example text and the example text processing result corresponding to the example text. For example, as shown in Figure 3, a sample may contain example text 1 "trashy time", the example text processing result "Negative" corresponding to example text 1, example text 2 "so larger than life", the example text processing result "Positive" corresponding to example text 2, the target text "the sheerjoy", and the text processing result "Positive" corresponding to the target text.
[0220] Step 304: Initial positioning and mapping rule construction stage.
[0221] Specifically, after determining the samples as described above, multiple samples are input into the large language model. The large language model processes the multiple samples to obtain the predicted text processing results corresponding to each sample.
[0222] Based on this, the server obtains the intermediate features generated by each network layer of the large language model (including the attention matrix of the attention module of each network layer and the hidden layer features), and obtains the loss value calculated by the large language model for each sample (e.g., the cross-entropy loss value calculated by the large language model based on the predicted text processing result and the text processing result corresponding to the target text).
[0223] Furthermore, the loss values calculated for each sample using the large language model are used to backpropagate the gradients of each attention matrix to obtain the backpropagated gradients. Based on the backpropagated gradients of each attention matrix and their products, the saliency matrix corresponding to each attention matrix is obtained.
[0224] Then, based on the analysis of the saliency matrix, the network layer in the process of constructing mapping rules can be determined. Specifically, the target feature value at the target position in the saliency matrix of each network layer is determined, and the network layer with the larger target feature value is initially positioned as the stage of constructing mapping rules.
[0225] The target position can be understood as the intersection of each example text with the processing result of its corresponding example text. For example, the position that represents the correlation between example text 1 and the processing result of example text 1, the position that represents the correlation between example text 2 and the processing result of example text 2, and so on.
[0226] A network layer with a large target feature value can be understood as a network layer whose target feature value at the target position in the saliency matrix is greater than other feature values in the row / column where the target position is located.
[0227] For example, see Figure 4 , Figure 4 This is a saliency matrix diagram illustrating a text processing model adjustment method provided in one embodiment of this specification. Figure 4 The diagram shows the attention matrix of a certain layer of a large language model, which can be used to describe the degree of correlation (feature value) between different examples within the large language model (e.g., the text processing results of example text 1 and example text 1) and between different examples. The higher the correlation, the stronger the association between the corresponding rows and columns and the stronger the interaction between them.
[0228] like Figure 4 As shown, the target feature value at target positions (I1, L1) is 0.43, which is greater than the other feature values in the row and column of the target position (I1, L1). The target feature value at target positions (I2, L2) is 0.30, which is also greater than the other feature values in the row and column of the target position (I2, L2). The same applies to target positions (I3, L3) and (I4, L4). Therefore, the network layer corresponding to this saliency matrix can be initially positioned as the mapping rule construction stage.
[0229] Based on the above preliminary positioning, for example, layers 1-18 of the large language model are identified as the stage for constructing mapping rules.
[0230] Step 306: Verify the location of the mapping rule building phase.
[0231] Specifically, verifying the positioning in the mapping rule construction stage can be understood as verifying the positioning in the mapping rule construction stage to ensure the accuracy of the network layer in the preliminary mapping rule stage.
[0232] In practice, the feature values at the target position in the attention matrix of the attention module in each network layer of the large language model are set to zero in turn, and the accuracy of the large language model in text processing after the zeroing process is observed in turn.
[0233] After determining the accuracy of the large language model corresponding to the above zeroing process for each network layer, the network layer whose accuracy falls within the preset accuracy range can be verified as the boundary layer of the mapping layer that constructs the mapping rules.
[0234] For example, see Figure 5 , Figure 5 This is a schematic diagram illustrating a blocking method for adjusting a text processing model according to one embodiment of this specification. Figure 5 This demonstrates how information from input to label plays a role in exploring which parts of the model within each example. Specifically, the feature values at the target position on the attention matrix of the attention module in each network layer are set to zero, thereby blocking the information flow from the input sample to the text processing result. The horizontal axis represents the layer number, and the vertical axis represents the accuracy of the large language model after blocking the corresponding layer.
[0235] like Figure 5 As shown, for example, the preset accuracy range is 50% ± 10%. The accuracy of the large language model corresponding to the above zeroing process of the 19 network layers falls within the range of 50% ± 10%. Therefore, the first 18 network layers can be determined to be in the above-mentioned mapping rule construction stage.
[0236] It should be noted that step 306 can also be used as a specific implementation of the preliminary positioning and mapping rule construction stage. That is, it is not used as a verification implementation, but rather the network layer of the mapping rule construction stage is located according to the implementation of steps 302 and 306, without executing step 304. For specific implementation, please refer to the above-mentioned specification embodiment, which will not be elaborated here.
[0237] Step 308: Determine the dividing point between the mapping rule construction phase and the mapping rule matching phase.
[0238] Based on the network layers corresponding to the preliminary mapping rule construction stage, multiple candidate boundary points can be determined, including the final layer corresponding to the mapping rule construction stage and the network layers adjacent to the top and bottom of that final layer.
[0239] Using the previous example, if the network layers corresponding to the initial positioning and mapping rule construction stage are layers 1-18, layers 17, 18, and 19 can be identified as candidate dividing points.
[0240] Subsequently, principal component analysis is performed on the hidden layer features generated by the above multiple samples at multiple candidate boundary points of the large language model, and a preset number (e.g., 10) of principal component components are obtained. Then, using the output projection matrix of the large language model, it is calculated whether the principal component components that meet the preset number of principal component components contain sentiment classification task words. The network layer corresponding to the principal component component component that first contains sentiment classification task words is determined as the target boundary point. The layer above the target boundary point is located in the mapping rule construction stage, and the target boundary point is located in the matching mapping rule stage.
[0241] Step 310: Locating and matching mapping rules stage.
[0242] Specifically, based on the output of the large language model, the path that influences the output is traced back in reverse. The path includes one or more attention heads in one or more network layers. Each attention head in each network layer is then perturbed to determine the network layer and attention head that have a greater influence on the output.
[0243] For example, see Figure 6 , Figure 6 This diagram illustrates the matching mapping rule stage positioning of a text processing model adjustment method provided in one embodiment of this specification.
[0244] like Figure 6 As shown, for example, the path obtained through this reverse tracing is as follows: Figure 6 The red path in the middle is Head0.31-MLP0-Add-MLP1-Ootput.
[0245] Preset reference data Xr and interference data Xc, and determine the activation values of all attention heads in the above path. Then, the attention heads in the path are interfered with in turn. Interference can be understood as replacing the activation value of the attention head to be interfered with with the activation value of Xc. Based on the output result of the large language model after interference, determine the impact of interference on the output result.
[0246] To ensure the accuracy of the interference, when interfering with one attention head, the activation values of other attention heads on Xr can be frozen.
[0247] Next, we can identify the interference objects that have a significant impact on the output results. For example, if interfering with Head0.31 causes the final output result to change by more than 5 times, Head0.31 can be used as the key attention head, and the network layer containing Head0.31 can be identified as the key network layer.
[0248] Based on this, the network layer in the matching mapping rule stage can be located, for example, such as Figure 7 As shown, see Figure 7 , Figure 7 This diagram illustrates the interference effect of the matching mapping rule stage in a text processing model adjustment method provided in one embodiment of this specification.
[0249] like Figure 7 As shown, Figure 7 Figure (a) shows the output record when a certain attention head of a certain network layer is interfered with. It can be seen that the interference with the attention head corresponding to Figure (a) leads to more inaccurate output results from the large language model, that is, the accuracy is reduced significantly. Therefore, the interference with this attention head is considered to be effective interference, and this attention head plays an important role in the rule matching process.
[0250] Figure 7 Figure (b) shows the degree of interference to the output results of each network layer. It can be seen that the interference to layers 18-21 causes greater interference to the output results, so layers 18-21 can be considered more critical.
[0251] Figure 7 Figure (c) in the figure illustrates the importance of different attention heads. For example, Figure (c) shows that the 8th attention head in the 19th layer of the network is relatively important.
[0252] Figure 7 Figure (d) shows the verification of the network layer in the matching mapping rule stage. For the specific implementation, see step 312.
[0253] Step 312: Verify matching mapping rules stage.
[0254] Specifically, the text processing results in different categories of examples are swapped with the values of the features of the key attention heads identified above to determine the performance degradation. The more severe the degradation, the more accurate the localization of the key attention heads is considered.
[0255] like Figure 7 As shown in Figure (d), each attention head in layer 19 is processed sequentially (in the sorting order obtained by the above positioning method) as the number of swaps increases, and the decrease in accuracy of the large language model output (i.e., the text processing result) is determined. Figure 7 Figure (d) shows that with 9 attention heads, the accuracy drops to 20%, so the attention heads identified above can be considered valid.
[0256] Step 314: Locate the decoding output result stage.
[0257] Specifically, based on the aforementioned positioning of the mapping rule construction stage and the mapping rule matching stage, it can be preliminarily determined that the remaining network layers in the large language model are the decoding output result stage.
[0258] Step 316: Verification of decoding output results.
[0259] Specifically, probing can be used to further verify the results. In particular, by using classification methods (such as logistic regression (LR) or support vector machine (SVM)), probes are constructed to directly classify the intermediate output results of the samples at each network layer, observe the accuracy of the intermediate output results of each network layer, and verify that the network layer with the constant accuracy belongs to the decoding output stage.
[0260] Based on steps 302 to 316 above, the three stages of context learning for large language models can be located.
[0261] In one or more embodiments of this specification, after completing the localization of the three stages of context learning for a large language model, a feature control method can be used to filter and retain the principal components that are ranked first and meet a preset number (e.g., 10) in the output of the key module, thereby improving the large language model. For example, at the end of the first stage and the beginning of the second stage (i.e., the aforementioned target boundary point), intermediate features are filtered accordingly. After filtering out principal components that are irrelevant to the mapping rules, subsequent inference continues. This improves the model accuracy without training the model and without incurring high training costs.
[0262] In one or more embodiments of this specification, by performing steps 302 to 316 above for a specified target task (i.e., a text classification task), the network layer and key attention head corresponding to the target task and in the matching mapping rule can be determined. The key attention head in the network layer can be precisely adjusted for the target task, thereby improving the accuracy of the large language model in processing the target task. Furthermore, while the large language model is more accurate in processing the target task, it can also avoid the influence of the large language model on other tasks.
[0263] The text processing model adjustment method provided in one or more embodiments of this specification improves the accuracy of the boundary between the three stages—constructing mapping rules, matching mapping rules, and decoding output results—by locating and verifying them separately. Furthermore, after locating the boundary, a more detailed and precise analysis is performed to determine the key network layers of each stage, making subsequent adjustments to the text processing model more targeted and accurate. Moreover, the embodiments of this specification can improve the performance of a large language model without training it, reducing the cost of model performance improvement. In practical applications, the adjusted text processing model of the embodiments of this specification can significantly improve the computational performance of the large language model by adding principal component analysis at the boundary point between the construction and matching mapping rule stages, reducing the interference of unnecessary intermediate features on the text processing of the large language model.
[0264] See Figure 8 , Figure 8 A flowchart of a text processing method according to an embodiment of this specification is shown, which specifically includes the following steps.
[0265] Step 802: Receive the text to be processed sent by the client.
[0266] The text to be processed is generated in response to a user's trigger operation on the graphical interface of the client.
[0267] Step 804: Use a text processing model to process the text to be processed and obtain the text processing result.
[0268] The text processing model is obtained according to the above-mentioned text processing model adjustment method;
[0269] Step 806: Send the text processing result to the client so that the client can display the text processing result to the user through a graphical user interface.
[0270] Here, the client can be understood as the aforementioned client 102, and the graphical user interface can be understood as a computer interface that can provide graphical interaction with the user, and the triggered operations include but are not limited to text box input, selection, swiping, etc.
[0271] In practice, the server can input the text to be processed by the user and a preset reference example into the text processing model to obtain the text processing result. Specifically, the embodiments in this specification do not limit the specific processing process of the text processing model.
[0272] This specification provides a text processing model adjustment method in one embodiment. By utilizing the improved text processing model described above, the accuracy of the text processing results displayed to the user by the client is improved, thereby significantly increasing the user's trust in the text processing model.
[0273] Corresponding to the above method embodiments, this specification also provides embodiments of a text processing model adjustment device. Figure 9 A schematic diagram of a text processing model adjustment device according to one embodiment of this specification is shown. Figure 9 As shown, the device includes:
[0274] The preprocessing module 902 is configured to determine a text processing model and multiple text processing stages for the text processing model to process the target text sample, wherein the text processing model is a machine learning model;
[0275] The feature analysis module 904 is configured to acquire the predicted text processing result determined by the text processing model when processing the target text sample, and the intermediate features generated during the text processing, wherein the intermediate features are the intermediate output results of multiple network layers of the text processing model.
[0276] The network layer partitioning module 906 is configured to determine the set of network layers corresponding to the multiple text processing stages from multiple network layers of the text processing model based on the intermediate features, the predicted text processing results, and the target text sample.
[0277] The adjustment module 908 is configured to adjust the task according to a preset model, determine the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjust the target network layer to obtain the adjusted text processing model.
[0278] Optionally, the plurality of text processing stages include a first text processing stage and a second text processing stage;
[0279] The network layer partitioning module 906 is further configured to:
[0280] Based on the predicted text processing results and the target text processing results in the target text samples, the loss value of the text processing model is obtained;
[0281] Based on the intermediate features and the loss value, the set of first network layers corresponding to the first text processing stage is determined from multiple network layers of the text processing model.
[0282] Based on the predicted text processing results and the target text sample, the set of second network layers corresponding to the second text processing stage is determined from multiple network layers of the text processing model.
[0283] Optionally, the intermediate features are the intermediate features of each network layer in multiple network layers generated during the text processing of the target text sample by the text processing model;
[0284] The network layer partitioning module 906 is further configured to:
[0285] Based on the loss value, gradient backpropagation is performed on the intermediate features of each network layer to determine the gradient corresponding to the intermediate features of each network layer.
[0286] Based on the intermediate features of each network layer and the gradients corresponding to the intermediate features of each network layer, determine the correlation matrix corresponding to the intermediate features of each network layer;
[0287] Based on the correlation matrix corresponding to the intermediate features of each network layer, the association between the example text corresponding to each network layer and the example text processing result corresponding to the example text is determined, wherein the example text is the example text contained in the target text sample;
[0288] Among the multiple network layers, the network layer whose association relationship satisfies the preset association relationship is determined as the first network layer corresponding to the first text processing stage, and the first network layer set is constructed based on the first network layer.
[0289] Optionally, the device further includes a first network layer precise positioning module, configured to:
[0290] Based on the first set of network layers, multiple candidate boundary network layers are determined from the multiple network layers of the text processing model;
[0291] Obtain the hidden layer features of each candidate boundary network layer, and perform principal component analysis on the hidden layer features of each candidate boundary network layer to obtain the principal component features and principal component feature values corresponding to the hidden layer features of each candidate boundary network layer.
[0292] Based on the principal component features and principal component feature values corresponding to the hidden layer features of each candidate boundary network layer, the target boundary network layer is selected from the multiple candidate boundary network layers.
[0293] The set of network layers corresponding to the first text processing stage is updated according to the target boundary network layer to obtain the updated set of the first network layers corresponding to the first text processing stage.
[0294] Optionally, the first network layer precise positioning module is configured as follows:
[0295] Based on the first set of network layers, an initial boundary network layer is determined, wherein the initial boundary network layer has a higher level in the text processing model than the other network layers in the first set of network layers in the text processing model.
[0296] From the multiple network layers of the text processing model, determine the adjacent network layers of the initial boundary network layer;
[0297] The adjacent network layers of the initial boundary network layer and the initial boundary network layer are determined as the plurality of candidate boundary network layers.
[0298] Optionally, the first network layer precise positioning module is configured as follows:
[0299] Based on the principal component feature values corresponding to the hidden layer features of each candidate boundary network layer, the principal component features corresponding to the hidden layer features of each candidate boundary network layer are sorted to obtain the sorting result;
[0300] Based on the sorting results and the preset retention quantity, multiple target principal component features are determined from each principal component feature;
[0301] Using the text processing model, the multiple target principal component features are transformed into text to obtain the transformed text corresponding to the multiple target principal component features;
[0302] The transformed text corresponding to the multiple target principal component features is determined as the transformed text corresponding to each candidate boundary network layer, and the target transformed text that meets the preset transformed text conditions is obtained from the transformed text corresponding to each candidate boundary network layer.
[0303] The candidate boundary network layer corresponding to the target converted text is determined as the target boundary network layer.
[0304] Optionally, each network layer includes multiple attention heads;
[0305] The network layer partitioning module 906 is further configured to:
[0306] Determine the simulated text sample corresponding to the target text sample, and sequentially determine the target attention head from the multiple attention heads contained in each network layer;
[0307] Based on the simulated text sample and the target attention head, the text processing model is adjusted to process the target text sample to obtain the adjusted text processing result;
[0308] Based on the adjusted text processing results, the second network layer corresponding to the second text processing stage is determined from the plurality of network layers, and the set of second network layers corresponding to the second text processing stage is determined based on the second network layer.
[0309] Optionally, the network layer partitioning module 906 is further configured to:
[0310] The target attention head is determined to process the simulated text sample, and the simulated text processing result is obtained;
[0311] The target attention head is used to process the target text sample to obtain the intermediate text processing result;
[0312] Replace the intermediate text processing result with the simulated text processing result;
[0313] The next layer attention head in the text processing model is determined based on the target attention head, and the simulated text processing result is used as the input of the next layer attention head to adjust the text processing process of the text processing model on the target text sample, thereby obtaining the adjusted text processing result.
[0314] Optionally, the network layer partitioning module 906 is further configured to:
[0315] Based on the accuracy of the adjusted text processing result and the accuracy of the preset text processing result, the degree of difference in the processing result is determined;
[0316] Based on the degree of difference in the processing results, a second attention head is selected from the plurality of attention heads, and the network layer containing the second attention head is determined as the second network layer corresponding to the second text processing stage.
[0317] Optionally, the device further includes a first verification module, configured to:
[0318] The intermediate features of each first network layer in the first network layer set are determined sequentially, and the target features of the intermediate features are zeroed out, thereby obtaining the zeroed text processing model.
[0319] The target text sample is processed according to the text processing model after each zeroing process, and the target first boundary network layer is determined from each first network layer based on the accuracy of the processing result.
[0320] Based on the target first boundary network layer, the set of first network layers corresponding to the first text processing stage is updated to obtain the updated set of first network layers corresponding to the first text processing stage.
[0321] Optionally, the device further includes a second verification module, configured to:
[0322] The intermediate features of each network layer in the text processing model are determined, and the intermediate features of each network layer are sequentially identified as target features.
[0323] The feature values representing different text processing results in the target features are swapped to obtain swapped features;
[0324] The target feature is replaced according to the replacement feature to adjust the text processing process of the text processing model on the target text sample, so as to obtain the adjusted text processing result;
[0325] Based on the accuracy of the adjusted text processing results, the target processing network layer is determined from the plurality of network layers;
[0326] Based on the target processing network layer, the set of second network layers corresponding to the second text processing stage is updated to obtain the updated set of second network layers corresponding to the second text processing stage.
[0327] Optionally, the preprocessing module 902 is configured to:
[0328] Determine the text processing model;
[0329] The intermediate features generated by the text processing model during the text processing of the target text sample are obtained, and the intermediate text corresponding to the intermediate features is determined.
[0330] The intermediate text is analyzed to obtain the analysis results;
[0331] Based on the analysis results, multiple text processing stages are determined for the text processing model to process the target text sample.
[0332] Optionally, the preset model adjustment task is a model accuracy improvement task;
[0333] The adjustment module 908 is further configured to:
[0334] Based on the model accuracy improvement task, the target boundary network layer is determined as the target network layer from the set of network layers corresponding to the multiple text processing stages;
[0335] Based on the multiple target principal component features, the hidden layer features of the target network layer are updated to obtain the adjusted text processing model.
[0336] Optionally, the preset model adjustment task can be adapted to the target text task.
[0337] The adjustment module 908 is further configured to:
[0338] Based on the target text task adaptation task, the target processing network layer is determined as the target network layer;
[0339] Based on the predicted text processing results and the target text sample, the target network layer is adjusted to obtain the adjusted text processing model.
[0340] Optionally, the target text sample includes the target text, the target text processing result corresponding to the target text, the example text, and the example text processing result corresponding to the example text;
[0341] The feature analysis module 904 is configured as follows:
[0342] The target text, the target text processing result, the example text, and the example text processing result are input into the text processing model.
[0343] In the text processing model, text processing is performed on the target text, the example text, and the example text processing result to obtain the predicted text processing result corresponding to the target text and the intermediate features generated during the text processing. The intermediate features are the intermediate features generated by the text processing model in each network layer during the text processing.
[0344] Based on the target text processing result and the corresponding predicted text processing result, the loss value of the text processing model is obtained using a loss function.
[0345] This specification provides an embodiment of a text processing model adjustment device. This device acquires intermediate features, loss functions, and predicted text processing results generated during the text processing of a target text sample by the text processing model. Based on these, it divides multiple network layers of the text processing model into stages. When the text processing model needs adjustment, according to the model adjustment task, it accurately determines the more critical network layer, i.e., the target network layer, from the divided network layers. By adjusting this target network layer, the text processing model is adjusted without requiring model training. This achieves the technical effect of improving the performance of the text processing model while reducing the training cost.
[0346] The above is a schematic scheme of a text processing model adjustment device according to this embodiment. It should be noted that the technical solution of this text processing model adjustment device and the technical solution of the above-described text processing model adjustment method belong to the same concept. For details not described in detail in the technical solution of the text processing model adjustment device, please refer to the description of the technical solution of the above-described text processing model adjustment method.
[0347] Corresponding to the above method embodiments, this specification also provides embodiments of a text processing device. Figure 10 A schematic diagram of the structure of a text processing apparatus according to one embodiment of this specification is shown. Figure 10 As shown, the device includes:
[0348] The receiving module 1002 is configured to receive text to be processed sent by the client, wherein the text to be processed is generated in response to a user's trigger operation on the graphical interface of the client.
[0349] The processing module 1004 is configured to process the text to be processed using a text processing model to obtain a text processing result, wherein the text processing model is obtained according to the above-mentioned text processing model adjustment method;
[0350] The sending module 1006 is configured to send the text processing result to the client so that the client can display the text processing result to the user through a graphical interactive interface.
[0351] Figure 11 A structural block diagram of a computing device 1100 according to one embodiment of this specification is shown. The components of the computing device 1100 include, but are not limited to, a memory 1110 and a processor 1120. The processor 1120 is connected to the memory 1110 via a bus 1130, and a database 1150 is used to store data.
[0352] The computing device 1100 also includes an access device 1140, which enables the computing device 1100 to communicate via one or more networks 1060. 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 1140 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, a Near Field Communication (NFC) interface, and so on.
[0353] In one embodiment of this specification, the aforementioned components of the computing device 1100 and Figure 11 Other components, not shown, can also be connected to each other, for example, via a bus. It should be understood that... Figure 11 The block diagram of the computing device shown is for illustrative purposes only and is not intended to limit the scope of this specification. Those skilled in the art can add or replace other components as needed.
[0354] The computing device 1100 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 1100 can also be a mobile or stationary server.
[0355] The memory 1110 is used to store computer programs / instructions, and the processor 1120 is used to execute the computer programs / instructions stored in the memory 1110. When the computer programs / instructions are executed by the processor, they implement the steps of the above-mentioned text processing model adjustment method or text processing method.
[0356] The above is an illustrative scheme of a computing device according to this embodiment. It should be noted that the technical solution of this computing device belongs to the same concept as the above-described text processing model adjustment method or text processing method. For details not described in detail in the technical solution of the computing device, please refer to the description of the above-described text processing model adjustment method or text processing method.
[0357] This specification also provides an embodiment of an information processing method based on a text processing model, applied to a task platform, including:
[0358] The device receives a model request sent by a terminal device, wherein the model request includes at least one of the following: a scene identifier of the target scene, scene input data of the target scene, and model specification parameters.
[0359] Based on the model request, a target text processing model is determined from multiple text processing models, wherein the multiple text processing models are adjusted based on the text processing model adjustment method described in any of the above.
[0360] This specification provides an embodiment of an information processing method based on a text processing model, applied to a task platform. By deploying a pre-adjusted text processing model on the task platform and providing the corresponding target text processing model to the terminal device according to the needs of the terminal device, the user does not need to perform complex model adjustment steps, reducing the difficulty of model acquisition for the user and improving the user experience.
[0361] An embodiment of this specification 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 text processing model adjustment method or text processing method.
[0362] The above is an illustrative scheme of a computer-readable storage medium according to this embodiment. It should be noted that the technical solution of this storage medium belongs to the same concept as the technical solution of the text processing model adjustment method or the text processing method described above. For details not described in detail in the technical solution of the storage medium, please refer to the description of the technical solution of the text processing model adjustment method or the text processing method described above.
[0363] An embodiment of this specification also provides a computer program product, including a computer program / instructions that, when executed by a processor, implement the steps of the above-described text processing model adjustment method or text processing method.
[0364] 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 above-described text processing model adjustment method or text processing method. For details not described in detail in the technical solution of the computer program product, please refer to the description of the above-described text processing model adjustment method or text processing method.
[0365] The foregoing has described specific embodiments of this specification. 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 result. Furthermore, the processes depicted in the drawings do not necessarily require the specific or sequential order shown to achieve the desired result. In some embodiments, multitasking and parallel processing are possible or may be advantageous.
[0366] The computer program / instructions include computer program code, which may be in the form of source code, object code, executable file, or some intermediate form. 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.
[0367] 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 in this specification are not limited to the described order of actions, because according to the embodiments in this specification, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in this specification are all preferred embodiments, and the actions and modules involved are not necessarily essential to the embodiments in this specification.
[0368] 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.
[0369] The preferred embodiments disclosed above are merely illustrative of this specification. 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 described herein. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the embodiments, thereby enabling those skilled in the art to better understand and utilize this specification. This specification is limited only by the claims and their full scope and equivalents.
Claims
1. A method for adjusting a text processing model, comprising: The text processing model is defined, and the text processing model performs multiple text processing stages on the target text sample. The text processing model is a machine learning model. The text processing model performs text processing on the target text sample, and the predicted text processing result and intermediate features generated during the text processing are obtained. The intermediate features are the intermediate output results of multiple network layers of the text processing model. Based on the intermediate features, the predicted text processing results, and the target text sample, determine the set of network layers corresponding to the multiple text processing stages from the multiple network layers of the text processing model; According to the preset model, the task is adjusted by determining the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjusting the target network layer to obtain the adjusted text processing model.
2. The text processing model adjustment method according to claim 1, wherein the plurality of text processing stages include a first text processing stage and a second text processing stage, wherein the first text processing stage is a text processing stage for constructing mapping rules, and the second text processing stage is a text processing stage for matching mapping rules; The step of determining the set of network layers corresponding to the multiple text processing stages from multiple network layers of the text processing model based on the intermediate features, the predicted text processing result, and the target text sample includes: Based on the predicted text processing results and the target text processing results in the target text samples, the loss value of the text processing model is obtained; Based on the intermediate features and the loss value, the set of first network layers corresponding to the first text processing stage is determined from multiple network layers of the text processing model. Based on the predicted text processing results and the target text sample, the set of second network layers corresponding to the second text processing stage is determined from multiple network layers of the text processing model.
3. The text processing model adjustment method according to claim 2, wherein the intermediate features are the intermediate features of each network layer in multiple network layers generated during the text processing of the target text sample by the text processing model; The step of determining the set of first network layers corresponding to the first text processing stage from multiple network layers of the text processing model based on the intermediate features and the loss value includes: Based on the loss value, gradient backpropagation is performed on the intermediate features of each network layer to determine the gradient corresponding to the intermediate features of each network layer. Based on the intermediate features of each network layer and the gradients corresponding to the intermediate features of each network layer, determine the correlation matrix corresponding to the intermediate features of each network layer; Based on the correlation matrix corresponding to the intermediate features of each network layer, the association between the example text corresponding to each network layer and the example text processing result corresponding to the example text is determined, wherein the example text is the example text contained in the target text sample; Among the multiple network layers, the network layer whose association relationship satisfies the preset association relationship is determined as the first network layer corresponding to the first text processing stage, and the first network layer set is constructed based on the first network layer.
4. The text processing model adjustment method according to claim 2, after determining the set of first network layers corresponding to the first text processing stage from multiple network layers of the text processing model based on the intermediate features and the loss value, further includes: Based on the first set of network layers, multiple candidate boundary network layers are determined from the multiple network layers of the text processing model; Obtain the hidden layer features of each candidate boundary network layer, and perform principal component analysis on the hidden layer features of each candidate boundary network layer to obtain the principal component features and principal component feature values corresponding to the hidden layer features of each candidate boundary network layer. Based on the principal component features and principal component feature values corresponding to the hidden layer features of each candidate boundary network layer, the target boundary network layer is selected from the multiple candidate boundary network layers. The set of network layers corresponding to the first text processing stage is updated according to the target boundary network layer to obtain the updated set of the first network layers corresponding to the first text processing stage.
5. The text processing model adjustment method according to claim 4, wherein the first network layer set includes an initial boundary network layer; The step of determining multiple candidate boundary network layers from multiple network layers of the text processing model based on the first set of network layers includes: Based on the first set of network layers, an initial boundary network layer is determined, wherein the initial boundary network layer has a higher level in the text processing model than the other network layers in the first set of network layers in the text processing model. From the multiple network layers of the text processing model, determine the adjacent network layers of the initial boundary network layer; The adjacent network layers of the initial boundary network layer and the initial boundary network layer are determined as the plurality of candidate boundary network layers.
6. The text processing model adjustment method according to claim 4, wherein the step of selecting the target boundary network layer from the plurality of candidate boundary network layers based on the principal component features and principal component feature values corresponding to the hidden layer features of each candidate boundary network layer includes: Based on the principal component feature values corresponding to the hidden layer features of each candidate boundary network layer, the principal component features corresponding to the hidden layer features of each candidate boundary network layer are sorted to obtain the sorting result; Based on the sorting results and the preset retention quantity, multiple target principal component features are determined from each principal component feature; Using the text processing model, the multiple target principal component features are transformed into text to obtain the transformed text corresponding to the multiple target principal component features; The transformed text corresponding to the multiple target principal component features is determined as the transformed text corresponding to each candidate boundary network layer, and the target transformed text that meets the preset transformed text conditions is obtained from the transformed text corresponding to each candidate boundary network layer. The candidate boundary network layer corresponding to the target converted text is determined as the target boundary network layer.
7. The text processing model adjustment method according to claim 2, wherein each network layer contains multiple attention heads; The step of determining the set of second network layers corresponding to the second text processing stage from multiple network layers of the text processing model based on the predicted text processing result and the target text sample includes: Determine the simulated text sample corresponding to the target text sample, and sequentially determine the target attention head from the multiple attention heads contained in each network layer; Based on the simulated text sample and the target attention head, the text processing model is adjusted to process the target text sample to obtain the adjusted text processing result; Based on the adjusted text processing results, the second network layer corresponding to the second text processing stage is determined from the plurality of network layers, and the set of second network layers corresponding to the second text processing stage is determined based on the second network layer.
8. The text processing model adjustment method according to claim 7, wherein adjusting the text processing process of the text processing model on the target text sample based on the simulated text sample and the target attention head to obtain the adjusted text processing result includes: The target attention head is determined to process the simulated text sample, and the simulated text processing result is obtained; The target attention head is used to process the target text sample to obtain the intermediate text processing result; Replace the intermediate text processing result with the simulated text processing result; The next layer attention head in the text processing model is determined based on the target attention head, and the simulated text processing result is used as the input of the next layer attention head to adjust the text processing process of the text processing model on the target text sample, thereby obtaining the adjusted text processing result.
9. The text processing model adjustment method according to claim 7, wherein determining the second network layer corresponding to the second text processing stage from the plurality of network layers based on the adjusted text processing result includes: Based on the accuracy of the adjusted text processing result and the accuracy of the preset text processing result, the degree of difference in the processing result is determined; Based on the degree of difference in the processing results, a second attention head is selected from the plurality of attention heads, and the network layer containing the second attention head is determined as the second network layer corresponding to the second text processing stage.
10. The text processing model adjustment method according to claim 2, further comprising: The intermediate features of each first network layer in the first network layer set are determined sequentially, and the target features of the intermediate features are zeroed out, thereby obtaining the zeroed text processing model. The target text sample is processed according to the text processing model after each zeroing process, and the target first boundary network layer is determined from each first network layer based on the accuracy of the processing result. Based on the target first boundary network layer, the set of first network layers corresponding to the first text processing stage is updated to obtain the updated set of first network layers corresponding to the first text processing stage.
11. The text processing model adjustment method according to claim 2, further comprising: The intermediate features of each network layer in the text processing model are determined, and the intermediate features of each network layer are sequentially identified as target features. The feature values representing different text processing results in the target features are swapped to obtain swapped features; The target feature is replaced according to the replacement feature to adjust the text processing process of the text processing model on the target text sample, so as to obtain the adjusted text processing result; Based on the accuracy of the adjusted text processing results, the target processing network layer is determined from the plurality of network layers; Based on the target processing network layer, the set of second network layers corresponding to the second text processing stage is updated to obtain the updated set of second network layers corresponding to the second text processing stage.
12. The text processing model adjustment method according to claim 11, wherein the preset model adjustment task is a target text task adaptation task; The step of adjusting the task according to the preset model, determining the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjusting the target network layer to obtain the adjusted text processing model, includes: Based on the target text task adaptation task, the target processing network layer is determined as the target network layer; Based on the predicted text processing results and the target text sample, the target network layer is adjusted to obtain the adjusted text processing model.
13. The text processing model adjustment method according to claim 1, wherein the determination of the text processing model and the multiple text processing stages of the text processing model performing text processing on the target text sample include: Determine the text processing model; The intermediate features generated by the text processing model during the text processing of the target text sample are obtained, and the intermediate text corresponding to the intermediate features is determined. The intermediate text is analyzed to obtain the analysis results; Based on the analysis results, multiple text processing stages are determined for the text processing model to process the target text sample.
14. The text processing model adjustment method according to claim 6, wherein the preset model adjustment task is a model accuracy improvement task; The step of adjusting the task according to the preset model, determining the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjusting the target network layer to obtain the adjusted text processing model, includes: Based on the model accuracy improvement task, the target boundary network layer is determined as the target network layer from the set of network layers corresponding to the multiple text processing stages; Based on the multiple target principal component features, the hidden layer features of the target network layer are updated to obtain the adjusted text processing model.
15. The text processing model adjustment method according to any one of claims 2-14, wherein the target text sample includes target text, target text processing result corresponding to the target text, sample text, and sample text processing result corresponding to the sample text; The step of obtaining the text processing model to process the target text sample, determining the predicted text processing result, and the intermediate features generated during the text processing includes: The target text, the target text processing result, the example text, and the example text processing result are input into the text processing model. In the text processing model, text processing is performed on the target text, the example text, and the example text processing result to obtain the predicted text processing result corresponding to the target text and the intermediate features generated during the text processing. The intermediate features are the intermediate features generated by the text processing model in each network layer during the text processing. The step of obtaining the loss value of the text processing model based on the predicted text processing result and the target text processing result in the target text sample includes: Based on the target text processing result and the corresponding predicted text processing result, the loss value of the text processing model is obtained using a loss function.
16. A text processing method, comprising: Receive text to be processed sent by the client, wherein the text to be processed is generated in response to a user's trigger operation on the client's graphical interface; The text to be processed is processed using a text processing model to obtain a text processing result, wherein the text processing model is obtained according to any one of the text processing model adjustment methods described in claims 1 to 15; The text processing result is sent to the client so that the client can display the text processing result to the user through a graphical user interface.
17. An information processing method based on a text processing model, applied to a task platform, comprising: The device receives a model request sent by a terminal device, wherein the model request includes at least one of the following: a scene identifier of the target scene, scene input data of the target scene, and model specification parameters. Based on the model request, a target text processing model is determined from a plurality of text processing models, wherein the plurality of text processing models are adjusted based on the method described in any one of claims 1-15.
18. A text processing model adjustment device, comprising: The preprocessing module is configured to determine a text processing model and multiple text processing stages in which the text processing model processes the target text sample, wherein the text processing model is a machine learning model; The feature analysis module is configured to acquire the predicted text processing result determined by the text processing model when processing the target text sample, as well as the intermediate features generated during the text processing, wherein the intermediate features are the intermediate output results of multiple network layers of the text processing model. The network layer partitioning module is configured to determine the set of network layers corresponding to the multiple text processing stages from multiple network layers of the text processing model based on the intermediate features, the predicted text processing results, and the target text sample. The adjustment module is configured to adjust the task according to a preset model, determine the target network layer from the set of network layers corresponding to the multiple text processing stages, and adjust the target network layer to obtain the adjusted text processing model.
19. A text processing apparatus, comprising: The receiving module is configured to receive text to be processed sent by the client, wherein the text to be processed is generated in response to a user's trigger operation on the client's graphical interface. The processing module is configured to process the text to be processed using a text processing model to obtain a text processing result, wherein the text processing model is obtained according to any one of the text processing model adjustment methods described in claims 1 to 15; The sending module is configured to send the text processing result to the client, so that the client can display the text processing result to the user through a graphical user interface.
20. 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.
21. 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.
22. 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.