Model training method, computer device and computer readable storage medium

By introducing masking marks and candidates in the dataset, the pre-trained model is prompted to predict, which solves the problems of low accuracy and long training time in small sample learning, and achieves efficient and accurate model training and multi-field application effects .

CN114610878BActive Publication Date: 2024-11-22ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210179812.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-02-25
Publication Date
2024-11-22
Estimated Expiration
2042-02-25

AI Technical Summary

Technical Problem

Traditional pre-trained models perform poorly in small sample learning scenarios, and it is difficult to quickly understand text semantics during the model training process, resulting in long training time and limited accuracy.

Method used

By designing the first dataset, it includes masking marks and at least two candidates, it is used to prompt the pre-trained model to select from candidates when predicting the word in the masking position, providing more semantic information, reducing the difficulty of model prediction and improving prediction efficiency and accuracy.

Benefits of technology

It significantly improves the prediction efficiency and accuracy of the model, and can achieve high-accuracy model training in small sample learning scenarios. It is suitable for downstream tasks in multiple related fields, reduces storage space requirements, and supports small sample learning.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114610878B_ABST
    Figure CN114610878B_ABST
Patent Text Reader

Abstract

One or more embodiments of the present specification provide a model training method, a computer device, and a computer-readable storage medium, wherein the model training method comprises: obtaining a model to be trained; obtaining a first data set; and training the model to be trained using the first data set; wherein the first data in the first data set is text, and a masking mark and at least two candidate items are provided in the first data, and one of the at least two candidate items is used to prompt a word corresponding to the masking mark, so that the model to be trained, under the prompt of the at least two candidate items, selects from the at least two candidate items when predicting the word corresponding to the masking mark.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of this specification relate to the field of machine learning technology, and in particular, to model training methods, computer devices, and computer-readable storage media. Background Art

[0002] The machine learning platform can provide machine learning services to users, such as providing full-process machine learning services from data uploading, data preprocessing, feature engineering, model training, model evaluation to model publishing, etc. Since different users have different task requirements, in order to provide users with better services, some solutions are to deploy pre-trained models and fine-tune the pre-trained models based on the goals of different downstream tasks. However, traditional pre-trained models are trained based on large-scale unlabeled data. The models face greater learning difficulties, the learning process is longer, and the accuracy performance is also poor when used for specific downstream tasks. Summary of the invention

[0003] To overcome the problems existing in the related art, the embodiments of this specification provide a model training method, a computer device and a computer-readable storage medium.

[0004] According to a first aspect of an embodiment of this specification, a model training method is provided, the method comprising:

[0005] Get the pre-trained model;

[0006] Obtaining a first data set;

[0007] The pre-trained model is trained using the first data set; wherein the first data in the first data set is text, a masking mark and at least two candidate items are provided in the first data, and one of the at least two candidate items is used to prompt a word corresponding to the masking mark, so that the pre-trained model selects from the at least two candidate items when predicting the word corresponding to the masking mark under the prompt of the at least two candidate items;

[0008] The trained model is stored and applied to downstream tasks.

[0009] According to a second aspect of an embodiment of this specification, a model training method is provided, including:

[0010] Get the model to be trained;

[0011] Obtaining a first data set;

[0012] The model to be trained is trained using the first data set; wherein the first data in the first data set is text, a masking mark and at least two candidate items are provided in the first data, and one of the at least two candidate items is used to prompt a word corresponding to the masking mark, so that the model to be trained can select from the at least two candidate items when predicting the word corresponding to the masking mark under the prompt of the at least two candidate items.

[0013] According to a third aspect of an embodiment of this specification, a computer device is provided, 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 training method described in the first aspect or the second aspect is implemented.

[0014] According to the fourth aspect of the embodiments of this specification, a computer-readable storage medium is provided, on which a number of computer instructions are stored. When the computer instructions are executed, the model training method described in the first aspect or the second aspect is implemented.

[0015] The technical solutions provided by the embodiments of this specification may have the following beneficial effects:

[0016] In the embodiments of the present specification, for the first data set, the first data set is designed to provide a masking mark and at least two candidate items, one of which is used to prompt the word corresponding to the masking mark. Therefore, when the model is trained using the first data, the first data can prompt the model so that the model can choose from the candidate items when predicting the word at the masked position. This provides the model with a range of options when predicting words, reduces the model's prediction difficulty, provides the model with more semantic information, and improves the model's prediction efficiency and accuracy.

[0017] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present specification. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the specification and, together with the description, serve to explain the principles of the specification.

[0019] Figure 1 It is a flowchart of a model training method shown in this specification according to an exemplary embodiment.

[0020] Figure 2A It is an application scenario diagram of a model training method shown in this specification according to an exemplary embodiment.

[0021] Figure 2BIt is an application scenario diagram of another model training method shown in this specification according to an exemplary embodiment.

[0022] Figure 3 It is a block diagram of a computer device shown in this specification according to an exemplary embodiment. DETAILED DESCRIPTION

[0023] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with this specification. Instead, they are merely examples of devices and methods consistent with some aspects of this specification as detailed in the appended claims.

[0024] The terms used in this specification are for the purpose of describing specific embodiments only and are not intended to limit this specification. The singular forms "a", "the" and "the" used in this specification and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.

[0025] It should be understood that although the terms first, second, third, etc. may be used in this specification to describe various information, this information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of this specification, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the word "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determining".

[0026] A pre-trained model is a model that is pre-trained using a large general dataset and is independent of specific tasks. One of the functions of this pre-trained model is that it can be fine-tuned based on the goals of different downstream tasks to make it suitable for a variety of different downstream tasks, and also enable the models required for downstream tasks to be trained quickly.

[0027] Pre-trained models have been widely used in the field of Natural Language Processing (NLP). Pre-trained language models are a general term for a class of natural language processing models that are used to learn low-dimensional real-valued vector representations of text. For example, the GPT model launched by the OpenAI team and the BERT (Bidirectional Encoder Representations from Transformer) model launched by Google. Early pre-trained language models aimed to learn word embedding representations using shallow neural networks, which can be used for various downstream tasks in natural language processing; while the latest pre-trained language models can learn context-based word embedding representations, and the learned pre-trained language models can be used for fine-tuning in downstream tasks. Generally, the general paradigm of pre-trained language models is: based on large-scale data sets, pre-training obtains a general language representation model; then, by fine-tuning the pre-trained language, the knowledge learned by the model is transferred to different downstream tasks. The training data of the pre-trained model can include text, text-image pairs, or text-video pairs. The training method of the pre-trained model can use self-supervised learning technology (such as autoregressive language model and autoencoding technology), etc. Among them, self-supervised learning is a learning task in machine learning that allows the model to learn directly from unlabeled data without the need for labeled data. Through training, single-language, multi-language or multi-modal models can be obtained. After fine-tuning, such models can be used to support various technologies such as classification, sequence labeling, structure prediction and sequence generation, and to build applications such as abstracts, machine translation, image retrieval, and video annotation.

[0028] Few-shot learning: Few-shot learning is a paradigm of machine learning. Its purpose is to obtain a model with higher accuracy by only slightly tuning the pre-trained model with very small training samples. Since few-shot learning only requires a small number of samples, the industry has an increasing demand for few-shot learning. However, fewer samples pose challenges to model accuracy.

[0029] For example, a traditional way to fine-tune a pre-trained model is to add a small number of task-related neural network layers to the pre-trained model and retrain it for a specific task. For example, for the matching problem, a classifier is added to the BERT model as the base and trained based on the task corpus. This fine-tuning method is more commonly used when the downstream task has a large amount of labeled sample data. Since a large number of additional parameters need to be reinitialized, the results are poor in the scenario of small sample learning due to insufficient data.

[0030] Another fine-tuning method can be Pattern Exploiting Training (PET), that is, in view of the special nature of small sample tasks, the downstream task is reconstructed into a "cloze problem", that is, the prediction problem of the downstream task is converted into an MLM (masked language model) problem. For example, for the text matching problem, if you need to predict the similarity between "what did you eat in the evening" and "what did you eat in the evening". The PET algorithm can rewrite the task as: ""what did you eat in the evening" and "what did you eat in the evening" have the same meaning [MASK]". Here [MASK] means masking, and the characters covered by [MASK] correspond to the predicted output of the pre-trained model MLMhead mapped to the actual category label. If the probability of predicting "same" is higher, it corresponds to the "positive" category, and if the probability of predicting "not" is higher, it corresponds to the "negative" category. The advantage of the PET algorithm is that it can utilize the MLM layer of the pre-trained model without introducing new parameters, and can use manually selected templates and label words to prompt the model prediction, so the model performs better in small sample situations. However, its main disadvantage is that the model performance is sensitive to the selected template and label, and the selection of templates and label words is more dependent on manual experience, and its label words are very limited. Therefore, for machine learning platform manufacturers, requiring users to select templates and labels at the product level is not user-friendly.

[0031] Other fine-tuning methods can be the P-Tuning algorithm. The P-tuning algorithm abandons the assumption that the template must be natural language, and believes that by training continuous text representations as auxiliary inputs, it can also have the effect of prompting the pre-trained model. The P-tuning algorithm builds a small LSTM (Long Short-Term Memory) model to learn these continuous representations used for "prompts". It is found that there is a significant improvement in the small sample learning tasks of GPT-type pre-trained models, and it is also applicable to BERT-type models. Although this method solves the problem of manual selection of prompt templates in the PET algorithm, it requires manual selection of label words and has a greater impact on the model results; and other experiments also show that the P-tuning algorithm does not perform as well as PET when applied to BERT-type models.

[0032] Another solution is that Google uses GPT-3 to fine-tune a large number of downstream natural language processing tasks, and uses this model to make predictions on previously unseen NLP tasks. This algorithm works well, but it relies on a very large pre-trained language model. For machine learning platform vendors, it cannot be directly provided to users, nor can it be productized and launched.

[0033] Other solutions are prompt-tuning, a fine-tuning method based on prompts. Some traditional fine-tuning methods rely on a large amount of labeled data. However, when there is very little training data, overfitting is very likely to occur, and there may be a large gap between downstream tasks and pre-training tasks, which makes the utilization rate of prior knowledge probing very low. The proposal of prompt aims to narrow the gap between pre-training and fine-tuning. By designing prompt and verbalizer, the downstream classification task is converted into an MLM task. Because it avoids the introduction of a large number of new parameters, it makes a significant improvement in small sample scenarios.

[0034] The traditional prompt-based fine-tuning method adopts the PVP (Prompt Verbalizer Pair) design, which includes a template (template or pattern) and a label word mapping relationship (verbalizer). Among them, the template includes at least one [MASK]; the label word mapping relationship refers to the mapping relationship between the vocabulary set output by the [MASK] position prediction and the true label.

[0035] As an example:

[0036] The template can be: It was [MASK]; this template is used to splice into the training text data;

[0037] The label word mapping relationship can be: the label positive corresponds to the word great (or good, etc.), and the negative label corresponds to the word terrible (or bad, etc.).

[0038] Therefore, each training text of the downstream task can be spliced ​​with the template. Through the MLM model, the model will give the predicted words in the [MASK] part. In practical applications, the output of the model is to obtain the probability distribution over the entire vocabulary. According to the Verbalizer, the probability distribution of the two words "great" and "terrible" can be obtained, and the largest one is taken as the prediction result. If the prediction is great, it means that the training text is positive.

[0039] However, the accuracy of the model trained by the above fine-tuning method is limited. Since the model needs to predict the predicted words of the [MASK] part, and there are usually more words in the vocabulary, the model may find it difficult to quickly and accurately understand the semantics of the text when faced with the [MASK] part in the text, resulting in a longer training time. Since the goal of the task cannot be accurately understood, it is difficult to accurately predict the words at the [MASK] position.

[0040] Based on this, this embodiment provides a model training method, which can be used to quickly train a model with high accuracy. Figure 1 FIG. 1 is a flowchart of a model training method according to an exemplary embodiment of the present specification, comprising the following steps:

[0041] In step 102, a model to be trained is obtained;

[0042] In step 104, a first data set is obtained;

[0043] In step 106, the model to be trained is trained using the first data set; wherein the first data in the first data set is text, and the first data provides a masking mark and at least two candidate items, and one of the at least two candidate items is used to prompt the word corresponding to the masking mark, so that the model to be trained can select from the at least two candidate items when predicting the word corresponding to the masking mark under the prompt of the at least two candidate items.

[0044] In the present embodiment, for the first data set, the first data set is designed to provide a mask mark and at least two candidate items, one of which is a word corresponding to the mask mark. Therefore, when the model is trained using the first data, the first data can prompt the model so that the model can choose from the candidate items when predicting the word at the masked position. This provides the model with a range of options when predicting words, reduces the model's prediction difficulty, provides the model with more semantic information, and improves the model's prediction efficiency and accuracy.

[0045] In the present embodiment, the candidate corresponding to the masked word is selected from at least two candidate items, so that the candidate items include the correct option; in addition to the candidate corresponding to the masked word, in actual application, the number of the candidate items is at least two, so that the model can learn how to distinguish between the correct option and the incorrect option. Among them, the incorrect option can be flexibly set as needed. As an example, the candidate item can be used to indicate a word with different semantics from the masked word. For example, it can be a candidate item corresponding to the antonym of the masked word. For example, the number of the at least two candidate items is two, namely, a candidate item indicating the masked word and a candidate item indicating the antonym of the masked word. Through the positive and negative semantics, the model can understand the prediction task more quickly and output the correct prediction result more quickly. Of course, in other examples, there can be a larger number of candidates, and this embodiment does not limit this.

[0046] In practical applications, how the first data provides the at least two candidate items can be flexibly set as needed; in some examples, it can be flexibly set according to the actual model prediction task and the language of the text, so that one of the candidate items can indicate the masked word. As an example, the text representing the at least two candidate items can be pre-set as needed, and the text is also used to prompt the model when predicting words; for the candidate indicating the masked word, the pre-set text can include the word or have the same semantics as the masked word. Traditional data sets do not have the first data designed in this embodiment to prompt the model with at least two candidate items. This embodiment can be based on the training text of the traditional data set, by masking the words therein and splicing the text representing the at least two candidate items designed in this embodiment to become the first data.

[0047] As an example, a traditional training text is "Today the weather is very good, I went hiking. I am [mask]", the masked word is happy, and the label corresponding to the word is good; and the first data designed in this embodiment is "Today the weather is very good, I went hiking, I am [mask]. Is this happy or sad?", where "Is this happy or sad?" is the at least two candidate items.

[0048] In this embodiment, the first data uses at least two candidate items to prompt the model. When implementing the prompt, a declarative sentence or an interrogative sentence can be used as needed. As an example, the preset text provides at least two candidate items in the form of a question, so that the model to be trained can select from the at least two candidate items when predicting the masked word based on the question of the preset text. This embodiment uses a question-based form, which can help the model understand the task it needs to perform more quickly, and can prompt the model that the masked word can be selected from at least two candidate items, so the training efficiency is high.

[0049] In practical applications, model training also involves the construction of labels. As mentioned above, a mapping between each word and label, i.e., a label-word mapping verbalizer, can be constructed according to the words (label words) indicated by the candidate items. The specific labels can be flexibly set according to actual needs, and this embodiment does not limit this.

[0050] It can be seen from the above embodiment that, compared with the traditional prompt-based fine-tuning method using PVP, the solution of this embodiment can be understood as a POV form, in which:

[0051] P (Prompt): indicates the prompt related to the task, which contains at least one [MASK] token, i.e., a masking token;

[0052] O (Option): List the candidate items by asking questions, etc., and each candidate item corresponds to a word (label word);

[0053] V (Verbalizer): label word mapping relationship, that is, the mapping relationship between the label word and the label in the custom candidate.

[0054] The model training method of this embodiment can be applied to any natural language processing scenario; the model to be trained can include any machine learning model. As an example, the model to be trained can be an untrained model, that is, a model with initial parameters set and not yet trained using a data set. Using the scheme of this embodiment, a first data set can be input into the model to train the model. This embodiment can be applicable to any model training scenario. For example, a machine learning platform uses this embodiment to train a pre-trained model, which can be stored for downstream tasks; or, a user can use the scheme of this embodiment to train a model that can solve a specific task for a specific task. In other examples, the model to be trained can include a model that has been trained using a data set, that is, any trained model can be further trained using the scheme of this embodiment to further improve the accuracy of the model.

[0055] In other examples, the model to be trained may also include a pre-trained model. As mentioned above, the pre-trained model is a model that is pre-trained using a large general data set and is unrelated to a specific task. The model training method of this embodiment can be used as an auxiliary task for an existing pre-trained model, and the existing pre-trained model is trained again, and the trained model is then used for downstream tasks. Among them, the pre-trained model of this embodiment refers to one that is pre-trained using a general data set, that is, pre-trained using a large-scale unlabeled data set. The pre-trained model can be obtained in a variety of ways, such as an open source pre-trained model or pre-training, etc. In the traditional solution, the pre-trained model is fine-tuned based on the downstream task before use, while in the embodiment of this specification, the pre-trained model can be trained again using the model training method embodiment, that is, the training of this embodiment can be an auxiliary task of the pre-trained model.

[0056] Moreover, since the prediction efficiency and accuracy of the model training embodiment are significantly improved, the first data set during training may not be limited to the data set of one field, and data sets of multiple related fields may be prepared for training, so that the model can learn knowledge of multiple related fields and can utilize the common information of training texts in multiple related fields, thereby improving the generalization ability of the model, and the trained model can be simultaneously applied to downstream tasks in multiple related fields. In addition, since the model training method of this embodiment can train a model with high accuracy, a small-scale pre-trained model can be used, thereby reducing storage space and improving prediction efficiency; and the obtained high-accuracy model can support the implementation of small sample learning, so that downstream tasks do not need to provide more data sets.

[0057] In practical applications, the model training method of this embodiment can be applied to supervised tasks or self-supervised tasks, or a combination of the two.

[0058] Take the supervision task as an example:

[0059] Taking the review classification task as an example, the first data input to the pre-trained model can be:

[0060] "[X].Is great or bad? It was[MASK]."

[0061] Among them, “[X]” is the comment to be classified;

[0062] “It was [MASK]” is a prompt, which provides a masking mark;

[0063] “Is great or bad” is Option, which lists two candidate options “great” and “bad” in the form of a question;

[0064] Taking the text matching prediction task as an example, the first data input to the pre-trained model can be:

[0065] "[X1].Is this paragraph the same as the next:[X2]? It was[MASK]."

[0066] Among them, “[X1]” and “[X2]” are two sentences that need to be predicted for coherence;

[0067] “It was [MASK]” is a prompt, which provides a masking mark;

[0068] “Is this paragraph the same as the next” is an option, which lists two candidate options “is” and “not” in the form of a question.

[0069] The self-supervised task mainly uses auxiliary tasks to mine its own supervisory information from large-scale unsupervised data. The network is trained through this constructed supervisory information, so that it can learn representations that are valuable for downstream tasks. The core lies in how to automatically generate labels for data. The traditional MLM is to give a sentence, randomly select one or more positions and replace them with [MASK], and let the model predict the word (or sub word) of each [MASK] position through the MLM head. For example:

[0070] Given a sentence:

[0071] "Disney movies are so wonderful that I insist on watching two everyweek.", randomly mask a word:

[0072] “Disney movies are so [MASK] that I insist on watching two every week.”, and then let the model predict the possible word in that position.

[0073] As mentioned above, the above self-supervision task brings great difficulty to the training of the prediction ability of the model. However, the design of the first data in this embodiment can efficiently implement the self-supervision task. As an example, a data set can be automatically constructed using unlabeled data for model training. In this embodiment, the first data is obtained in the following way:

[0074] Obtain unlabeled text, perform word segmentation on the unlabeled text to obtain a plurality of words, identify adjectives from the plurality of words, and replace one of the adjectives with a masking mark to obtain.

[0075] This embodiment uses adjectives for masking because adjectives are used to modify nouns and are strongly associated with other words in the training text. This makes it easier for the model to understand the semantics of other words in the training text to predict the masked words. In addition, it is also easier to automatically construct the at least two candidate items based on the adjective. For example, the aforementioned at least two candidate items based on the adjective and the antonym of the adjective can be quickly and automatically constructed, reducing the difficulty of automatically constructing labels in self-supervised tasks.

[0076] As an example, this embodiment can be applied to PromptMLM. For example, given an unlabeled text, a self-supervised task can be constructed as follows:

[0077] Select the mask position: You can use spacy word segmentation tools to segment the unlabeled text and obtain the part of speech of each word. You can further determine all the adjectives in the text and the position of each adjective, so as to count all the adjectives in the text.

[0078] Construct the input data to the model based on this text, for example:

[0079] Given a sentence X

[0080] "Disney movies are so wonderful that I insist on watching two every week.",

[0081] Select the position of the adjective "wonderful" and mask the adjective, that is, replace the adjective with the mask mark. The new sentence X =

[0082] “Disney movies are so[MASK]that I insist on watching two every week.”

[0083] Construct a self-supervised task, that is, provide at least two candidates in a new sentence. The sentence input to the model can be:

[0084] "Disney movies are so[MASK]that I insist on watching two every week. Is it wonderful or bad?"

[0085] Among them, "Is it wonderful or bad" is two candidate items provided in the text, wherein a candidate item indicating the word "wonderful" and a candidate item indicating the word "bad" are provided.

[0086] The model obtained by using the model training embodiment of this specification can support small sample learning when used for downstream tasks, thereby providing users with a better experience at the user level without the need for users to provide more training data. As an example, the solution of this embodiment can be applied to a machine learning platform, such as Figure 2AAs shown, this specification shows a schematic diagram of an application scenario of model training according to an exemplary embodiment. The machine learning platform in this embodiment is used to provide machine learning services to users, such as providing machine learning full-process services from data uploading, data preprocessing, feature engineering, model training, model evaluation to model publishing, etc. The machine learning platform can be deployed with one or more servers, and the above services are implemented through the servers. Among them, the platform can obtain one or more pre-trained models in advance, and train one or more pre-trained models using the aforementioned model training embodiments. The pre-trained models obtained by training can be stored and provided to one or more users. Optionally, the machine learning platform can adopt a small-scale pre-trained model, so as to reduce storage space, improve the prediction efficiency of the model, and allow users to provide less data and quickly experience the capabilities of the model in a specific scenario through fewer training steps.

[0087] like Figure 2B FIG. 1 is a schematic diagram of another model training method according to an exemplary embodiment of the present specification, comprising the following steps:

[0088] In step 202, a pre-trained model is obtained;

[0089] In step 204, a first data set is obtained;

[0090] In step 206, the pre-trained model is trained using the first data set; wherein the first data in the first data set is text, the first data is provided with a masking mark and at least two candidate items, one of the at least two candidate items is used to prompt a word corresponding to the masking mark, so that the pre-trained model, under the prompt of the at least two candidate items, selects from the at least two candidate items when predicting the word corresponding to the masking mark;

[0091] In step 208, the trained model is stored, and the trained model is applied to downstream tasks.

[0092] The method of this embodiment can be applied to the aforementioned machine learning platform, and the existing pre-trained model can be used to train the pre-trained model again, and the trained model can be applied to downstream tasks. Among them, the embodiment of the first data set in the first data set can refer to the description of the aforementioned embodiment. Relative to the way in which the existing pre-trained model directly performs downstream tasks, this embodiment can be understood as an auxiliary task for the pre-trained model, and the prediction efficiency and accuracy of the trained model are significantly improved. During training, the first data set may not be limited to a data set in one field, and data sets in multiple related fields may be prepared for training, so that the model can learn knowledge in multiple related fields, and can use the common information of training texts in multiple related fields, thereby improving the generalization ability of the model, and the trained model can be applied to downstream tasks in multiple related fields at the same time. In addition, since the model training method of this embodiment can train a model with higher accuracy, a small-scale pre-trained model can be used, thereby reducing storage space and improving prediction efficiency.

[0093] Optionally, the obtained high-accuracy model can support the implementation of small-sample learning, that is, the trained model can be used in small-sample learning scenarios for downstream tasks, so that downstream tasks do not need to provide more data sets.

[0094] Optionally, when retraining the pre-trained model, data sets from multiple related fields can be used; for example, for sentiment analysis tasks, data sets from the field of news reviews, data sets from the field of movie reviews, and data sets from the field of product usage evaluation. Obviously, there will be certain differences in user emotions in the data of each data set. In traditional technology, due to the high difficulty of model prediction and low prediction efficiency, different models are usually designed for different fields and trained separately, and the models of each field need to be stored; but the scheme of this embodiment significantly reduces the difficulty of model learning due to the design of candidate items. Therefore, the first data set used for retraining the pre-trained model of this embodiment can come from multiple related fields. Therefore, the model can provide data from multiple related fields to learn knowledge from multiple related fields, so that one model can be applicable to multiple different fields, and the model has stronger generalization ability.

[0095] As mentioned above, the scheme of this embodiment can be applied to a machine learning platform, and the machine learning platform can use this embodiment to store multiple trained models for use by different downstream tasks of different users. Based on this, in this embodiment, the method may also include: receiving a model training request initiated by a user, the model training request includes a second data set provided by the user; the amount of data in the second data set is less than a preset threshold; selecting a model from the stored models; using the second data set, training the selected model and providing it to the user. Among them, the preset threshold can be flexibly set according to actual needs, and the preset threshold indicates that the user can provide a smaller data set, so that the user can experience the ability of small sample learning. For example, for a machine learning platform, different users have different downstream task requirements. The machine learning platform can provide a model training service to the user, and the user can initiate a model training request through the model training service. The user can provide a second data set, and the machine learning platform can select a model from one or more stored models according to the user's needs; training is performed using the second data set provided by the user, and the trained model can be provided to the user for use.

[0096] Since the model training method of this embodiment can train a model with high accuracy, a small-scale pre-trained model can be used, thereby reducing storage space and improving prediction efficiency; and the obtained high-accuracy model can support the implementation of small sample learning, so that downstream tasks do not need to provide more data sets. For example, the second data set of this embodiment can be small, and the amount of data can be less than a preset threshold, so that users can provide less data to quickly experience the capabilities of the model in a specific scenario. As an example, the machine learning platform can pre-train different categories of models according to the characteristics of existing downstream tasks, such as sentiment analysis models, text matching models, or security risk control models, etc. Different types of models can be used for similar downstream tasks. When used in downstream tasks, small sample fine-tuning can be achieved to obtain a better model for downstream tasks.

[0097] In actual applications, when the model is retrained based on downstream tasks, the data input into the model can be obtained using traditional methods or the model training method of this embodiment, that is, the model selected by the machine learning platform can be used as the model to be trained in the aforementioned step 102, and the first data input into the model adopts the aforementioned design, which is provided with a masking mark and at least two candidate items; wherein, the first data input into the model can be provided by the user, that is, the second data set provided by the user is equivalent to the first data set.

[0098] Optionally, in order to facilitate the user to understand the characteristics of the second data set that he needs to provide, in this embodiment, the method also includes: displaying data prompt information, and the data prompt information is used to prompt the user: the second data in the second data set provides a masking mark and at least two candidate items, and one of the at least two candidate items is used to prompt the word corresponding to the masking mark; as an example, the prompt information can be displayed in the user interface of the machine learning platform, and the prompt information can be used in a variety of ways such as text, image or video to prompt the user, and can also provide one or more data examples as mentioned above for the user to understand, so that the user can provide an accurate second data set according to the prompt.

[0099] In other examples, the machine learning platform may obtain the first data set after processing the second data set provided by the user, that is, the first data set provided by the user may be traditional data, which may be labeled text or unlabeled text. For labeled text, if it has a masking mark, the machine learning platform may generate data with a masking mark and at least two candidate items based on the label and the masking mark. If it does not have a masking mark, the machine learning platform may generate data with a masking mark and at least two candidate items based on the label based on the needs of the user's downstream tasks. For unlabeled text, as described in the aforementioned embodiment, the machine learning platform may perform word segmentation on the unlabeled text to obtain multiple words, identify adjectives from the multiple words, replace one of the adjectives with a masking mark, and generate at least two candidate items based on the masked adjective, thereby obtaining data with a masking mark and at least two candidate items.

[0100] Corresponding to the embodiments of the aforementioned model training method, this specification also provides embodiments of a model training apparatus and a computer device used therein.

[0101] The model training device of this specification may include one or more modules for implementing the aforementioned steps 102, 104 and 106, or include one or more modules for implementing the aforementioned steps 202, 204, 206 and 208. The present model training device embodiment can be applied to a computer device, such as a server or a terminal device. The device embodiment can be implemented by software, or by hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, it is formed by the processor in which it is located reading the corresponding computer program instructions in the non-volatile memory into the memory and running them.

[0102] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the aforementioned steps 102, 104, and 106, or implements the aforementioned steps 202, 204, and 206 when executing the program. Figure 3 As shown, it is a structural diagram of a computer device according to an exemplary embodiment of the present specification. The computer device may include a processor 310 and a memory 320. In addition, it may also include other hardware according to the actual function of the computer device, which will not be described in detail.

[0103] As an example, the processor in this embodiment may implement the following steps when executing the program:

[0104] Get the pre-trained model;

[0105] Obtaining a first data set;

[0106] The pre-trained model is trained using the first data set; wherein the first data in the first data set is text, a masking mark and at least two candidate items are provided in the first data, and one of the at least two candidate items is used to prompt a word corresponding to the masking mark, so that the pre-trained model selects from the at least two candidate items when predicting the word corresponding to the masking mark under the prompt of the at least two candidate items;

[0107] The trained model is stored and applied to downstream tasks.

[0108] In some examples, the trained model is applied to small sample learning scenarios for downstream tasks.

[0109] In some examples, the processor may also perform:

[0110] Receiving a model training request initiated by a user, wherein the model training request includes a second data set provided by the user, and the amount of data in the second data set is less than a preset threshold;

[0111] Select a model from the stored models;

[0112] The selected model is trained using the second data set provided by the user and then provided to the user.

[0113] In some examples, the processor may also perform:

[0114] Display data prompt information, wherein the data prompt information is used to prompt the user: the second data in the second data set provides a masking mark and at least two candidate items, and one of the at least two candidate items is used to prompt a word corresponding to the masking mark.

[0115] In some examples, the at least two candidate items are provided in the form of a question, so that the model selects from the at least two candidate items when predicting the word corresponding to the masked token based on the question.

[0116] In some examples, one of the at least two candidates is used to suggest: an antonym of the word corresponding to the masking mark.

[0117] In some examples, the first data and / or the second data are obtained by:

[0118] Obtain unlabeled text, perform word segmentation on the unlabeled text to obtain a plurality of words, identify adjectives from the plurality of words, and replace one of the adjectives with a masking mark to obtain the result.

[0119] Alternatively, the processor may further implement the following steps when executing the program:

[0120] Get the model to be trained;

[0121] Obtaining a first data set;

[0122] The model to be trained is trained using the first data set; wherein the first data in the first data set is text, a masking mark and at least two candidate items are provided in the first data, and one of the at least two candidate items is used to prompt a word corresponding to the masking mark, so that the model to be trained can select from the at least two candidate items when predicting the word corresponding to the masking mark under the prompt of the at least two candidate items.

[0123] In some examples, the first data is provided with the at least two candidate items in the form of a question, so that the model to be trained selects from the at least two candidate items when predicting the word corresponding to the masked token based on the question.

[0124] In some examples, one of the at least two candidates is used to suggest: an antonym of the word corresponding to the masking mark.

[0125] In some examples, the first data is obtained by:

[0126] Obtain unlabeled text, perform word segmentation on the unlabeled text to obtain a plurality of words, identify adjectives from the plurality of words, and replace one of the adjectives with a masking mark to obtain the result.

[0127] In some examples, the at least two candidates are determined by:

[0128] An antonym of the masked adjective is obtained, and the at least two candidate items are determined based on the masked adjective and the antonym.

[0129] The implementation process of the above-mentioned computer device is specifically described in the implementation process of the corresponding steps in the above-mentioned model training method, which will not be repeated here.

[0130] For the device embodiment, since it basically corresponds to the method embodiment, the relevant parts can refer to the partial description of the method embodiment. The device embodiment described above is only schematic, wherein the modules described as separate components may or may not be physically separated, and the components displayed as modules may or may not be physical modules, that is, they may be located in one place, or they may be distributed on multiple network modules. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this specification. A person of ordinary skill in the art can understand and implement it without paying creative labor.

[0131] The above is a description of a specific embodiment of the specification. Other embodiments are within the scope of the appended claims. In some cases, the actions or steps recorded in the claims can be performed in an order different from that in the embodiments and still achieve the desired results. In addition, the processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.

[0132] The step division of the above methods is only for the purpose of clear description. When implemented, they can be combined into one step or some steps can be split and decomposed into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent; adding insignificant modifications to the algorithm or process or introducing insignificant designs without changing the core design of the algorithm and process are all within the scope of protection of this patent.

[0133] Those skilled in the art will readily appreciate other embodiments of the specification after considering the specification and practicing the invention claimed herein. The specification is intended to cover any variations, uses or adaptations of the specification that follow the general principles of the specification and include common knowledge or customary techniques in the art that are not claimed in the specification. The specification and examples are to be considered exemplary only, and the true scope and spirit of the specification are indicated by the following claims.

[0134] It should be understood that the present description is not limited to the precise structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present description is limited only by the appended claims.

[0135] The above description is only a preferred embodiment of this specification and is not intended to limit this specification. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of this specification should be included in the scope of protection of this specification.

Claims

1. A model training method, the method include: Get the pre-trained model; Obtaining a first data set; The pre-trained model is trained using the first data set; wherein the first data in the first data set is text, and the first data provides a masking mark and at least two candidate items, one of the at least two candidate items is used to prompt a word corresponding to the masking mark, and the other candidate item is a word, so that the pre-trained model, under the prompt of the at least two candidate items, selects from the at least two candidate items when predicting the word corresponding to the masking mark; The trained model is stored and applied to downstream tasks.

2. According to the method of claim 1, the trained model is applied to small sample learning scenarios of downstream tasks.

3. The method according to claim 1, further comprising: include: Receiving a model training request initiated by a user, wherein the model training request includes a second data set provided by the user, and the amount of data in the second data set is less than a preset threshold; Select a model from the stored models; The selected model is trained using the second data set provided by the user and then provided to the user.

4. The method according to claim 3, further comprising: include: Display data prompt information, wherein the data prompt information is used to prompt the user: the second data in the second data set provides a masking mark and at least two candidate items, and one of the at least two candidate items is used to prompt a word corresponding to the masking mark.

5. According to the method of claim 1 or 3, the at least two candidate items are provided in the form of a question so that the model selects from the at least two candidate items when predicting the word corresponding to the masked tag based on the question.

6. The method according to claim 1 or 3, wherein one of the at least two candidate items is used to prompt: an antonym of the word corresponding to the masking mark.

7. According to the method of claim 1 or 3, the first data and / or the second data are obtained by: Obtain unlabeled text, perform word segmentation on the unlabeled text to obtain a plurality of words, identify adjectives from the plurality of words, and replace one of the adjectives with a masking mark to obtain the result.

8. A model training method, include: Get the model to be trained; Obtaining a first data set; The model to be trained is trained using the first data set; wherein the first data in the first data set is text, a masking mark and at least two candidate items are provided in the first data, one of the at least two candidate items is used to prompt the word corresponding to the masking mark, and the other candidate item is a word, so that the model to be trained can select from the at least two candidate items when predicting the word corresponding to the masking mark under the prompt of the at least two candidate items.

9. The method according to claim 8, wherein the first data is provided with the at least two candidate items in the form of a question, so that the model to be trained selects from the at least two candidate items when predicting the word corresponding to the masked tag based on the question; and / or The first data is obtained by: obtaining unlabeled text, performing word segmentation on the unlabeled text to obtain a plurality of words, identifying adjectives from the plurality of words, and replacing one of the adjectives with a masking mark; and / or, One of the at least two candidate items is used to prompt: an antonym of the word corresponding to the masking mark.

10. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, in, When the processor executes the program, the method according to any one of claims 1 to 9 is implemented.

11. A computer-readable storage medium, wherein a plurality of computer instructions are stored on the computer-readable storage medium, and when the computer instructions are executed, the steps of the method according to any one of claims 1 to 9 are implemented.