A model adjustment method and device for a discriminative language model

The discriminative language model is adjusted through the Prompt-Tuning method, which eliminates the difference between the pre-training stage and downstream tasks, improves the accuracy of the model in text classification and question and answer tasks, and solves the problem of unstable fine-tuning of the discriminative language model. problem, achieving more efficient model performance.

CN115080736BActive Publication Date: 2024-09-20TSINGHUA UNIVERSITY +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210567681.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-23
Publication Date
2024-09-20
Estimated Expiration
2042-05-23

AI Technical Summary

Technical Problem

In the existing technology, there are formal differences between the pre-training task stage and the downstream task stage of discriminative language models, resulting in poor model fine-tuning effects, especially unstable performance in text classification and question and answer tasks.

Method used

The Prompt-Tuning method is used to adjust the pre-trained discriminative language model. By inserting category tokens into the input text and performing inner product processing, using Sigmoid function activation to obtain the probability value, calculating the model loss and fine-tuning, eliminating the pre-training stage and downstream tasks.

Benefits of technology

It improves the accuracy of the model in text classification and question and answer tasks, solves the problem of unstable fine-tuning of the discriminative language model, reduces the dependence on annotated data, and improves the overall effect of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115080736B
    Figure CN115080736B
Patent Text Reader

Abstract

The present invention provides a model adjustment method and device for a discriminative language model, the method comprising the following steps: obtaining a pre-trained discriminative language model and a training data set of a downstream task; in response to a task request, adjusting the pre-trained language model according to the type of the task request and the training data set; wherein the discriminative language model is obtained by training with text samples. By adjusting the model parameters of the discriminative language model at different downstream task stages, the difference between the discriminative language model at the model pre-training stage and the downstream task is eliminated, thereby improving the overall effect of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and in particular to a model adjustment method and device for a discriminative language model. Background Art

[0002] Text classification and question answering are important tasks in the field of natural language processing and are widely used in daily life. For example, text classification can be used to classify news types, judge the emotional tone of comments, and determine whether the text is grammatical, while question answering can be used for knowledge question answering robots. For these two tasks, the most effective existing work is the large-scale pre-trained language model (PLM).

[0003] Pre-training a language model means dividing the model into two stages: pre-training and model fine-tuning. Pre-training is performed on a large-scale corpus. In this stage, the model learns the representation method of common text, that is, the "commonality" of knowledge; model fine-tuning is performed on the downstream task dataset. In this stage, the model needs to quickly adapt to the task. Model fine-tuning refers to fine-tuning based on a given pre-trained model. Compared with training a model from scratch, fine-tuning saves a lot of computing resources and computing time. Separating pre-training from model fine-tuning can greatly save training costs while giving the model strong knowledge potential. The pre-training stage is usually completed by companies and institutions such as Google and Facebook and is open for download. Therefore, the effect of the model fine-tuning stage directly affects the quality of the model.

[0004] The key to the current limitation of pre-trained language models lies in the difference in form between pre-training tasks and downstream tasks. How to eliminate this difference is the key and difficulty in improving the effect of model fine-tuning. Summary of the invention

[0005] The present invention provides a model fine-tuning method and device for a discriminative language model, which are used to solve the defect in the prior art that there is a formal difference between the discriminative language model in the pre-training task stage and the downstream task stage, eliminate the difference between the discriminative language model in the pre-training stage and the downstream task stage, and improve the effect of model fine-tuning.

[0006] The present invention provides a model adjustment method for a discriminative language model, the method comprising:

[0007] Obtain a pre-trained discriminative language model and training datasets for downstream tasks;

[0008] In response to the task request, adjusting the pre-trained language model according to the type of the task request and the training data set;

[0009] The discriminative language model is obtained through training with text samples.

[0010] According to a model adjustment method for a discriminative language model provided by the present invention, the pre-trained language model is adjusted based on the Prompt-Tuning paradigm.

[0011] According to a model adjustment method of a discriminative language model provided by the present invention, in response to a task request, adjusting the pre-trained language model according to the type of the task request and the training data set specifically includes:

[0012] Obtaining input text in the training data set;

[0013] If the task request type is a text classification task, then:

[0014] Encode the input text into a token group including a plurality of tokens, and insert a category token after the plurality of tokens;

[0015] Extracting a vector corresponding to the category token, and performing an inner product process on the vector and a shared vector of the same length to obtain a probability value corresponding to the vector;

[0016] The pre-trained language model is adjusted based on the probability value.

[0017] According to a model adjustment method of a discriminative language model provided by the present invention, the vector is processed with a shared vector of the same length by inner product, and then the method further includes:

[0018] The inner product processing result is activated by a Sigmoid function to obtain a probability value corresponding to the vector.

[0019] According to a model adjustment method of a discriminative language model provided by the present invention, the adjusting of the pre-trained language model based on the probability value specifically includes:

[0020] Assuming the probability value to be p, 1-p is taken as the true probability value;

[0021] Calculate the model loss according to the true probability value;

[0022] Based on the model loss, fine-tuning the pre-trained language model.

[0023] According to a model adjustment method of a discriminative language model provided by the present invention, in response to a task request, adjusting the pre-trained language model according to the type of the task request and the training data set specifically includes:

[0024] Obtaining a model discriminant head of the pre-trained discriminant language model in a pre-training phase;

[0025] If the task request type is a question-answering task, then:

[0026] The pre-trained language model is adjusted based on the training data set and the model discriminant head.

[0027] According to a model adjustment method of a discriminative language model provided by the present invention,

[0028] The pre-training process of the discriminative language model includes:

[0029] Obtain the text sample and an initial discriminant language model, and encode each letter of the text sample into a corresponding token; the initial discriminant language model includes a generator and a discriminator;

[0030] Generating replacement tokens by the generator to replace several tokens corresponding to the text sample;

[0031] The discriminator discriminates the tokens corresponding to the replaced text samples to obtain a discrimination result;

[0032] The tokens corresponding to the replaced text samples and the discrimination results are input into the initial discriminant language model for training to obtain the pre-trained discriminant language model.

[0033] The present invention also provides a model adjustment device for a discriminative language model, the device comprising: an acquisition module, used to acquire a pre-trained discriminative language model and a training data set for a downstream task;

[0034] An adjustment module, configured to adjust the pre-trained language model in response to a task request according to a type of the task request and the training data set;

[0035] The discriminative language model is obtained through training with text samples.

[0036] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a model adjustment method for the discriminant language model as described in any one of the above is implemented.

[0037] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the model adjustment method of the discriminant language model as described in any one of the above is implemented.

[0038] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the model adjustment method of the discriminant language model described in any one of the above is implemented.

[0039] The present invention provides a model adjustment method and device for a discriminative language model, which adjusts the model parameters of the discriminative language model at different downstream task stages, eliminates the difference between the discriminative language model at the model pre-training stage and the downstream task, and improves the overall effect of the model. When the downstream task is a text classification task or a question-answering task, the present invention improves the accuracy of the model when performing text classification or question-answering tasks by adjusting the discriminative language model at the downstream task stage. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0041] Figure 1 It is a flow chart of a model adjustment method of a discriminative language model provided by the present invention;

[0042] Figure 2 is a schematic diagram of a discriminative language model framework provided by the present invention;

[0043] Figure 3 is a schematic diagram of the discriminative language model pre-training stage provided by the present invention;

[0044] Figure 4 A schematic diagram of fine-tuning based on Fine-Tuning for a discriminative language model provided by the present invention;

[0045] Figure 5 The present invention provides a schematic diagram of fine-tuning based on Prompt-Tuning for a discriminative language model;

[0046] Figure 6 This is the experimental result of the discriminative language model provided by the present invention when performing text classification tasks;

[0047] Figure 7 This is the experimental result of the discriminative language model provided by the present invention when performing question-answering tasks;

[0048] Figure 8 It is the experimental result of ablation experiment conducted on the Prompt-Tuning framework for discriminative language model provided by the present invention;

[0049] Fig. 9 It is the experimental result of stability experiment of Prompt-Tuning framework for discriminative language model provided by the present invention;

[0050] Fig.10 It is a structural schematic diagram of a model adjustment device for a discriminative language model provided by the present invention;

[0051] Fig.11 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0053] The best model fine-tuning method currently is called Prompt-Tuning, which mainly eliminates the difference between the pre-training stage and downstream tasks by constructing prompts to improve the effect of model fine-tuning. Constructing task-specific prompts to adjust the pre-trained language model (PLM) is a promising method for text classification tasks. Previous studies have shown that in low-data scenarios, Prompt-Tuning has significant advantages over the Fine-Tuning method with additional classifiers.

[0054] The core idea of ​​Prompt-Tuning is to insert text fragments (i.e., templates) into the input and transform the classification problem into a masked language modeling problem, in which a key step is to use a language expressor to build a mapping between word space and label space.

[0055] However, existing Prompt-Tuning related works are all targeted at generative language models (GLM, such as BERT, RoBERTa, etc.), and none are targeted at discriminative language models (DLM, such as ELECTRA).

[0056] The pre-training process of the generative language model corrupts the input by replacing some of the original tokens with [MASK] tokens, and trains the model to regenerate the original tokens. Its disadvantage is that the task is defined on the small subset that is replaced. The pre-training process of the discriminative language model is to generate replacement tokens using a generative network and train the model to discriminate whether the token is replaced. The task is defined on all inputs. Compared with the generative language model, the discriminative language model has better performance and higher computational efficiency. However, due to problems such as instability in the fine-tuning process, the application of the discriminative language model is greatly limited.

[0057] In summary, text classification and question-answering tasks are important tasks in the field of natural language processing. Exploring the feasibility and performance of designing Prompt-Tuning for discriminative language models and solving problems such as instability in fine-tuning provide the possibility for better using pre-trained language models to complete these two tasks.

[0058] Combine the following Figure 1 A model adjustment method for a discriminative language model of the present invention is described.

[0059] In machine learning, supervised learning can be divided into two types of models: discriminative models and generative models. Simply put, discriminative models model conditional distributions, while generative models model joint distributions. Discriminative language models are particularly attractive for fine-tuning because they usually have competitive performance and superior computational efficiency compared to generative language models.

[0060] The present invention provides a model adjustment method for a discriminative language model.

[0061] Figure 1 is a flow chart of a model adjustment method for a discriminative language model provided by an embodiment of the present invention, such as Figure 1 As shown, the method comprises the following steps:

[0062] Step 110, obtain a pre-trained discriminative language model and a training data set for downstream tasks. First, the discriminative language model needs to be pre-trained in the pre-training stage. The pre-training process of the discriminative language model includes: obtaining a text sample and an initial discriminative language model, encoding each letter of the text sample into a corresponding token; the initial discriminative language model includes a generator and a discriminator. The generator generates replacement tokens to replace several tokens corresponding to the text sample. The discriminator discriminates the tokens corresponding to the replaced text sample to obtain a discrimination result. The tokens corresponding to the replaced text sample and the discrimination result are input into the initial discriminative language model for training to obtain a pre-trained discriminative language model.

[0063] Specifically, Figure 2 As shown in the figure, the pre-training process of the discriminative language model (DLM) is as follows:

[0064] The input sentence is first encoded into several tokens, and DLM generates several tokens through a generator to replace the original input (such as the attached Figure 2 In the example, “the” and “cooked” are replaced), and then the discriminator is trained to determine whether the token has been replaced (“the” has no change before and after replacement, so it is judged as not replaced, “cooked” becomes “ate” and is judged as replaced, and the others are judged as not replaced).

[0065] Step 120: In response to the task request, the pre-trained language model is adjusted according to the type of task request and the training data set. Optionally, the task request type for the discriminative language model includes a text classification task and a question-answering task. By adjusting the discriminative language model in the downstream task stage, the difference from the pre-training stage is eliminated, and the overall effect of the model is improved.

[0066] Among them, the discriminative language model is obtained by training text samples. The present invention adjusts the model parameters of the discriminative language model at different downstream task stages to eliminate the difference between the discriminative language model in the model pre-training stage and the downstream tasks, thereby improving the overall effect of the model. When the downstream task is a text classification task or a question-answering task, the present invention improves the accuracy of the model when performing text classification or question-answering tasks by adjusting the discriminative language model at the downstream task stage.

[0067] Furthermore, in a model adjustment method for a discriminative language model of the present invention, the pre-trained language model is adjusted based on the Prompt-Tuning paradigm.

[0068] As the size of pre-trained language models continues to grow, the hardware requirements, data requirements, and actual costs of Fine-Tune are also rising. In addition, the rich and diverse downstream tasks also make the design of the pre-training and fine-tuning stages cumbersome and complex, so researchers hope to explore a smaller, lighter, more universal and efficient method. Prompt-Tuning is an attempt in this direction.

[0069] This paper proposes DPT, the first prompt-tuning framework for discriminative language models, which reformulates the NLP task as a discriminative language modeling problem. Experimental results on text classification and question answering tasks show that DPT achieves significantly higher performance than traditional model fine-tuning methods, while also solving the training instability problem of large-scale pre-trained models in full data and low-resource scenarios.

[0070] In step 120, in response to the task request, the pre-trained language model is adjusted according to the type of the task request and the training data set, specifically including the following steps:

[0071] Get the input text in the training dataset;

[0072] If the task request type is a text classification task, then:

[0073] Encode the input text into a token group including a number of tokens, and insert a category token after the number of tokens;

[0074] Extract the vector corresponding to the category token and perform inner product processing on the vector with the shared vector of the same length to obtain the probability value corresponding to the vector;

[0075] The pre-trained language model is adjusted based on the probability value. By adjusting the discriminative language model in the text classification task, the difference between the discriminative language model in the pre-training stage and the text recognition task stage is eliminated.

[0076] Furthermore, the vector is processed with a shared vector of the same length by inner product, and then the inner product processing result is activated by the Sigmoid function to obtain the probability value corresponding to the vector. The Sigmoid function is an S-type function commonly seen in biology, also known as the S-type growth curve. In information science, due to its monotonic and inverse monotonic properties, the Sigmoid function is often used as an activation function of a neural network to map variables between 0 and 1. When using this function for classification problems, not only can the category be predicted, but also an approximate probability prediction can be obtained. This is very useful for many tasks that require the use of probability to assist decision-making. The logarithmic probability function is a convex function that can be differentiable in any order. It has good mathematical properties, and many numerical optimization algorithms can be directly used to obtain the optimal solution.

[0077] The basic principle is that during pre-training, the discriminative language model usually needs to generate a large inner product for the replaced token (i.e., incorrect token) and a small inner product for the original token (i.e., correct token). Therefore, in the model adjustment method of the discriminative language model of the present invention, the pre-trained language model is adjusted based on the probability value, and specifically further includes the following steps:

[0078] If the probability value is set to p, then 1-p is used as the true probability value;

[0079] Calculate the model loss based on the true probability value;

[0080] Based on the model loss, fine-tune the pre-trained language model.

[0081] Specifically, Figure 3 ,4 ,5, Figure 3 (a) is a schematic diagram of using the DLM head for pre-training based on discriminative language modeling (DLM). Figure 4 (b) is a schematic diagram of conventional fine-tuning using the new classification (CLS) head based on Fine-Tuning, and Figure 5 (c) Schematic diagram of the DPT model tuning method based on Prompt-Tuning of the present invention, which redesigns the NLP task into a discriminative language modeling problem.

[0082] exist Figure 3 In the algorithm, the input sentence is first encoded into several tokens. DLM generates several tokens through a generator to replace the original input, and then trains the discriminator to determine whether the token has been replaced, for example, "feel" is the original, "make" is replaced, and "on" is the original.

[0083] exist Figure 4 In the paper, the discriminative language model is fine-tuned based on Fine-Tuning. Specifically, in the pre-training stage of the discriminative language model, the input of the pre-training model is first encoded into several tokens, and all tokens are usually wrapped with [CLS] and [SEP]. For text classification tasks, the traditional method is to take the vector corresponding to [CLS], multiply it with a matrix of dimension vector dimension × number of categories (set to N), and obtain a new vector of dimension N, and then perform Softmax normalization to obtain the probability of each category. This method only uses the vector corresponding to [CLS], and it is obviously significantly different from the pre-training stage.

[0084] Specifically, DPT fills the input text into the template containing the candidate answers, and distinguishes whether each candidate answer is correct (i.e., original) or incorrect (i.e., replaced) based on the reused DLM header. The method adopted by the present invention (DPT) is to insert a token of the form "Category is: Class A, Class B..." after the input token, and then determine whether "Class A", "Class B", etc. have been "replaced":

[0085] Take out the vectors corresponding to "Class A", "Class B", etc., do the inner product of these N vectors with a shared vector of the same length and activate them using the Sigmoid function to obtain N probabilities. DPT eliminates the difference between the model fine-tuning and pre-training stages, and keeps the space and time costs unchanged. At the same time, since the number of parameters used for the final probability calculation is changed from focusing on the randomly initialized matrix to focusing on the N vectors from the model, the model's dependence on labeled data is reduced. In addition, during pre-training, the discriminative language model usually needs to generate a large inner product for the replaced token (i.e., incorrect token) and a small inner product for the original token (i.e., correct token), thereby further eliminating the difference between the downstream task dataset and the pre-training corpus.

[0086] The discriminative language model after model adjustment is used for text classification tasks and question-answering tasks. Text classification can be applied to classifying news types, judging the emotional tone of comments, judging whether the text is grammatical, etc.

[0087] When using the discriminative language model after the model adjustment method to perform text classification tasks, the following steps are included:

[0088] Get the text data to be classified;

[0089] The text data to be classified is input into the discriminative language model after pre-training and model adjustment, and the discriminative language model classifies the text data to be classified to obtain a classification result. Compared with the discriminative language model without model adjustment or based on the existing Fine-Tuning model adjustment method, the discriminative language model using the method of the present invention has a higher recognition rate and better classification effect.

[0090] Specifically, the pre-training stage of the discriminative language model is to enable the model to obtain basic semantic understanding functions. Since there are certain differences between the pre-training stage of the discriminative language model and the text classification task stage, it is necessary to adjust the pre-trained discriminative language model based on the text classification task and the data set corresponding to the text classification task after pre-training the discriminative language model.

[0091] In the present invention, the pre-trained discriminative language model is adjusted based on the Prompt-Tuning paradigm to eliminate the difference between the model in the text classification stage and the pre-training stage, so that the stability and accuracy of the adjusted discriminative language model are improved.

[0092] In a model adjustment method of a discriminative language model of the present invention, step 120, in response to a task request, adjusting the pre-trained language model according to the type of the task request and the training data set, specifically also includes:

[0093] Get the model discriminant head of the pre-trained discriminative language model in the pre-training stage;

[0094] If the task request type is a question-and-answer task, then:

[0095] Based on the training data set and the model discriminant head, the pre-trained language model is adjusted. By adjusting the discriminative language model in the question-answering task, the difference between the discriminative language model in the pre-training stage and the text recognition task stage is eliminated.

[0096] The discriminative language model after model adjustment is used for text classification tasks and question-answering tasks, among which text classification can be applied to knowledge question-answering robots, etc.

[0097] When using the discriminative language model after the model adjustment method for question answering tasks, the following steps are included:

[0098] Get the text data for the question-answering task;

[0099] The text data is input into the discriminative language model after pre-training and model adjustment, and the discriminative language model judges the result of the text data to be classified to obtain the result of the question-answering task. Compared with the discriminative language model without model adjustment or based on the existing Fine-Tuning model adjustment method, the discriminative language model using the method of the present invention has higher recognition efficiency and higher accuracy of question-answering results.

[0100] Specifically, the pre-training stage of the discriminative language model is to enable the model to acquire basic semantic understanding functions. Since there are certain differences between the pre-training stage and the question-answering task stage of the discriminative language model, it is necessary to adjust the pre-trained discriminative language model based on the question-answering task and the data set corresponding to the question-answering task after the discriminative language model is pre-trained.

[0101] In the present invention, the pre-trained discriminative language model is adjusted based on the Prompt-Tuning paradigm to eliminate the difference between the model in the question-answering task stage and the pre-training stage, so that the stability and accuracy of the adjusted discriminative language model are improved.

[0102] Specifically, for general multi-span question-answering tasks, the most advanced method is to formulate the task as a sequence labeling problem: given a text and a question, mark the part of the text that belongs to the answer. In the traditional model fine-tuning method, the discriminant head used to judge whether it belongs to the answer in the pre-training stage is discarded, and a randomly initialized discriminant head is used to retrain. The present invention proposes to use the discriminant head used in the pre-training stage as the initialization for fine-tuning, which greatly reduces the dependence of the model fine-tuning process on labeled data.

[0103] The core points of the present invention are: (1) an initial attempt was made to design a prompt-tuning method for the discriminative pre-training model, eliminating the difference between the pre-training stage and the model fine-tuning, and exploring the deep potential connection between the pre-training corpus and downstream tasks; (2) the dependence on labeled data was reduced and the model stability was improved.

[0104] Figure 6 The experimental results are expressed as text classification. The full set setting is: 100% data, and the low resource setting is: 10% data. FT is: Fine-Tuning, DPT is: Prompt-Tuning. "BERT, RoBERTa, ELECTRA, ELECTRA" correspond to different discriminative language models. "SST-2, SST-5, TREC, AGNews" refer to different datasets. The experimental results show the text classification performance of different discriminative language models under different datasets using different model adjustment methods.

[0105] Figure 7 The experimental results show the performance of different discriminative language models in question-answering tasks on different datasets using different model adjustment methods.

[0106] As attached Figure 6 , 7 As shown, it is not difficult to see from the experimental results that: on multiple data sets of text classification tasks and question-answering tasks, the present invention (DPT) achieves the best under various configurations, and the effect is significantly improved compared to before using Prompt-Tuning.

[0107] Figure 8 Represents the model performance on different datasets based on different model adjustment methods in low-resource environments.

[0108] Fig. 9 (a) represents the model performance of the discriminative language model using Fine-Tuning and the DPT of the present invention under each data set when the full set is set to 100% data;

[0109] Fig. 9 (b) represents the model performance distribution of the discriminative language model using Fine-Tuning and the DPT of the present invention under various data sets when the local resources are set to 10% of the data.

[0110] By attaching Figure 8 The ablation experiment shows that the improvement detail of "using 1-p as probability" improves the effect of this model in the text classification task. Fig. 9 From the stability experiment, it can be clearly seen that the present invention effectively solves the problem of unstable training of discriminative language models, and provides strong support for the widespread application of discriminative language models.

[0111] A model adjustment device for a discriminative language model provided by the present invention is described below. The model adjustment device for a discriminative language model described below and the model adjustment method for a discriminative language model described above can correspond to each other.

[0112] like Fig.10 As shown, an embodiment of the present invention provides a model adjustment device for a discriminative language model, and the device includes the following modules: an acquisition module 1010 and an adjustment module 1020.

[0113] The acquisition module 1010 is used to acquire a pre-trained discriminative language model and a training data set for downstream tasks. The adjustment module 1020 is used to adjust the pre-trained language model in response to a task request according to the type of task request and the training data set. Among them, the discriminative language model is obtained through text sample training. A model adjustment device for a discriminative language model of the present invention adjusts the model parameters of the discriminative language model at different downstream task stages, thereby eliminating the difference between the discriminative language model in the model pre-training stage and the downstream task, thereby improving the overall effect of the model. When the downstream task is a text classification task or a question-answering task, the present invention improves the accuracy of the model when performing text classification or question-answering tasks by adjusting the discriminative language model at the downstream task stage.

[0114] The technical problem to be solved by the present invention is to explore the feasibility of using Prompt-Tuning to fine-tune the discriminative language model, solve the problem of unstable training of the discriminative model, and improve the model effect in text classification and question-answering tasks.

[0115] The present invention provides a model adjustment device and method for a discriminative language model. The technical solution of the present invention has the following advantages:

[0116] 1. Compared with the existing model using Prompt-Tuning, this is the first time that a discriminative language model with task definition on all inputs is used, achieving optimal results in text classification and question-answering tasks.

[0117] 2. The Prompt-Tuning method is used to eliminate the differences between the pre-training stage and the model fine-tuning stage, and to explore the deep potential connection between the pre-training corpus and the downstream task dataset. Compared with the traditional model fine-tuning method, the model performance is greatly improved.

[0118] 3. By effectively utilizing the parameters of the pre-trained model, the dependence on labeled data is reduced, thereby solving the problem of unstable training of large-scale discriminative language models in low-resource scenarios.

[0119] Fig.11 An example of a physical structure diagram of an electronic device is shown in FIG. Fig. 9 As shown, the electronic device may include: a processor 1110, a communication interface 1120, a memory 1130 and a communication bus 1140, wherein the processor 1110, the communication interface 1120 and the memory 1130 communicate with each other through the communication bus 1140. The processor 1110 may call the logic instructions in the memory 1130 to execute a model adjustment method for a discriminative language model, the method comprising the following steps: obtaining a pre-trained discriminative language model and a training data set for a downstream task; in response to a task request, adjusting the pre-trained language model according to the type of the task request and the training data set; wherein the discriminative language model is obtained through text sample training.

[0120] In addition, the logic instructions in the above-mentioned memory 1130 can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0121] On the other hand, the present invention also provides a computer program product, which includes a computer program, and the computer program can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute a model adjustment method for a discriminative language model provided by the above methods, and the method includes the following steps: obtaining a pre-trained discriminative language model and a training data set for a downstream task; in response to a task request, adjusting the pre-trained language model according to the type of the task request and the training data set; wherein the discriminative language model is obtained by training with text samples.

[0122] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, is implemented to execute a model adjustment method for a discriminative language model provided by the above-mentioned methods, the method comprising the following steps: obtaining a pre-trained discriminative language model and a training data set for a downstream task; in response to a task request, adjusting the pre-trained language model according to the type of the task request and the training data set; wherein the discriminative language model is obtained by training with text samples.

[0123] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0124] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0125] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A model adjustment method for a discriminative language model, characterized in that: The method comprises: Obtain a pre-trained discriminative language model and training datasets for downstream tasks; In response to the task request, adjusting the pre-trained language model according to the type of the task request and the training data set; Wherein, the discriminative language model is obtained by training with text samples; Adjusting the pre-trained language model based on the Prompt-Tuning paradigm; In response to the task request, adjusting the pre-trained language model according to the type of the task request and the training data set, specifically including: Obtaining input text in the training data set; If the task request type is a text classification task, then: Encode the input text into a token group including a plurality of tokens, and insert a category token after the plurality of tokens; Extracting a vector corresponding to the category token, and performing an inner product process on the vector and a shared vector of the same length to obtain a probability value corresponding to the vector; Adjusting the pre-trained language model based on the probability value; The vector is inner-producted with a shared vector of the same length, followed by: The inner product processing result is activated by a Sigmoid function to obtain a probability value corresponding to the vector; The adjusting the pre-trained language model based on the probability value specifically includes: Assuming the probability value to be p, 1-p is taken as the true probability value; Calculate the model loss according to the true probability value; Fine-tuning the pre-trained language model based on the model loss; The pre-training process of the discriminative language model includes: Obtain the text sample and an initial discriminant language model, and encode each letter of the text sample into a corresponding token; the initial discriminant language model includes a generator and a discriminator; Generating replacement tokens by the generator to replace several tokens corresponding to the text sample; The discriminator discriminates the tokens corresponding to the replaced text samples to obtain a discrimination result; The tokens corresponding to the replaced text samples and the discrimination results are input into the initial discriminant language model for training to obtain the pre-trained discriminant language model.

2. The model adjustment method of the discriminative language model according to claim 1, characterized in that: In response to the task request, adjusting the pre-trained language model according to the type of the task request and the training data set, specifically including: Obtaining a model discriminant head of the pre-trained discriminant language model in a pre-training phase; If the task request type is a question-answering task, then: The pre-trained language model is adjusted based on the training data set and the model discriminant head.

3. A model adjustment device for a discriminative language model, characterized in that: The device comprises: an acquisition module for acquiring a pre-trained discriminative language model and a training data set for a downstream task; An adjustment module, configured to adjust the pre-trained language model in response to a task request according to a type of the task request and the training data set; Wherein, the discriminative language model is obtained by training with text samples; Adjusting the pre-trained language model based on the Prompt-Tuning paradigm; In response to the task request, adjusting the pre-trained language model according to the type of the task request and the training data set, specifically including: Obtaining input text in the training data set; If the task request type is a text classification task, then: Encode the input text into a token group including a plurality of tokens, and insert a category token after the plurality of tokens; Extracting a vector corresponding to the category token, and performing an inner product process on the vector and a shared vector of the same length to obtain a probability value corresponding to the vector; Adjusting the pre-trained language model based on the probability value; The vector is inner-producted with a shared vector of the same length, followed by: The inner product processing result is activated by a Sigmoid function to obtain a probability value corresponding to the vector; The adjusting the pre-trained language model based on the probability value specifically includes: Assuming the probability value to be p, 1-p is taken as the true probability value; Calculate the model loss according to the true probability value; Fine-tuning the pre-trained language model based on the model loss; The pre-training process of the discriminative language model includes: Obtain the text sample and an initial discriminant language model, and encode each letter of the text sample into a corresponding token; the initial discriminant language model includes a generator and a discriminator; Generating replacement tokens by the generator to replace several tokens corresponding to the text sample; The discriminator discriminates the tokens corresponding to the replaced text samples to obtain a discrimination result; The tokens corresponding to the replaced text samples and the discrimination results are input into the initial discriminant language model for training to obtain the pre-trained discriminant language model.

4. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the program, the model adjustment method of the discriminative language model according to any one of claims 1 to 2 is implemented.

5. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the model adjustment method of the discriminative language model according to any one of claims 1 to 2 is implemented.

6. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the model adjustment method of the discriminative language model according to any one of claims 1 to 2 is implemented.