A text classification method and server

By using unlabeled text data in the server for language model training and prediction template construction, combined with the aggregation and standardization of domain knowledge, the problems of data dependence and label definition deviation in existing text classification methods are solved, and efficient and accurate text classification is achieved. .

CN113961705BActive Publication Date: 2024-08-27JUHAOKAN TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111275404.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-29
Publication Date
2024-08-27
Estimated Expiration
2041-10-29

AI Technical Summary

Technical Problem

Existing text classification methods require a large amount of annotated data for training, and there are deviations in the definition and description of classification labels during zero-pass learning, resulting in low effectiveness and the inability to achieve accurate text classification.

Method used

A server is used to perform language model training by obtaining text to be classified and unlabeled text data, constructing a prediction template for the mask filling position, using the pre-trained language model to predict the probability of different classification labels, and generating the classification label with the highest probability as the target classification Labels, aggregation and normalization through domain knowledge, and optimization of zero-shot learning methods.

Benefits of technology

It reduces data processing efficiency, improves the accuracy and stability of text classification, and achieves accurate text classification without annotated data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113961705B
    Figure CN113961705B
Patent Text Reader

Abstract

The present application discloses a text classification method and server. When classifying a text to be classified, the text to be classified and unlabeled text data are used to train a language model to obtain a pre-trained language model, and a prediction template including a mask filling position is constructed; the pre-trained language model is used to predict the probability of filling in different classification labels in the mask filling position, and the classification label with the maximum probability is used as the target classification label of the text to be classified. The server can reduce data processing efficiency by using unlabeled data. After constructing the prediction template required for the prompt task, the MLM pre-trained language model obtained by unsupervised training is used to infer the domain knowledge words of each category filled in the slot of the template, and finally the inference results are aggregated and normalized, so that the model output effect is more stable and reliable, and accurate text classification results can be obtained.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a text classification method and a server. Background Art

[0002] Artificial intelligence is an emerging technology that has emerged in the past decade and is now present in every aspect of our lives. NLP (Natural Language Processing) is a subfield of artificial intelligence, which refers to the ability of machines to understand and interpret the way humans write and speak. Among the application areas of natural language processing, text classification is a relatively widespread application area. For example, for a certain news text, natural language processing can be used to classify the news text into sports, entertainment, variety shows, etc., so that users can see the news text under a certain label classification.

[0003] When using natural language processing for text classification, it is usually necessary to use labeled data for training and use zero-shot learning methods to perform reasoning and analysis on the text to be classified to achieve text classification. However, this text classification method requires a lot of effort to obtain labeled data, and also requires extra effort to correct the data; there is a deviation in the definition and description of the classification label during zero-shot learning, and the learning effect is poor. It can be seen that the existing text classification methods are ineffective and cannot perform accurate text classification. Summary of the invention

[0004] The present application provides a text classification method and a server to solve the problem that the existing text classification method cannot perform accurate text classification.

[0005] In a first aspect, the present application provides a server, including: a controller, configured to:

[0006] Acquire text to be classified and unlabeled text data, wherein the unlabeled text data refers to text data that does not include label meaning;

[0007] Performing language model training using the text to be classified and unlabeled text data to obtain a pre-trained language model, and constructing a prediction template including a mask filling position, wherein the mask filling position is used to fill in a classification label matching the text to be classified;

[0008] The pre-trained language model is used to predict the probability of the mask filling position when different classification labels are filled in, and the classification label with the maximum probability is used as the target classification label of the text to be classified.

[0009] In a second aspect, the present application also provides a text classification method, the method comprising:

[0010] Acquire text to be classified and unlabeled text data, wherein the unlabeled text data refers to text data that does not include label meaning;

[0011] Performing language model training using the text to be classified and unlabeled text data to obtain a pre-trained language model, and constructing a prediction template including a mask filling position, wherein the mask filling position is used to fill in a classification label matching the text to be classified;

[0012] The pre-trained language model is used to predict the probability of the mask filling position when different classification labels are filled in, and the classification label with the maximum probability is used as the target classification label of the text to be classified.

[0013] In a third aspect, the present application further provides a storage medium, which can store a program, and when the program is executed, it can implement some or all of the steps in each embodiment of the text classification method provided in the present application.

[0014] It can be seen from the above technical solutions that a text classification method and server provided by an embodiment of the present invention, when classifying a text to be classified, uses the text to be classified and unlabeled text data to train a language model to obtain a pre-trained language model, and constructs a prediction template including a mask filling position; uses the pre-trained language model to predict the probability of filling in different classification labels in the mask filling position, and uses the classification label with the maximum probability as the target classification label of the text to be classified. The server uses unlabeled data to reduce data processing efficiency. After constructing the prediction template required for the prompt task, the MLM pre-trained language model obtained by unsupervised training is used to infer the domain knowledge words of each category filled in the slot of the template, and finally the inference results are aggregated and normalized, so that the model output effect is more stable and reliable, and accurate text classification results can be obtained. BRIEF DESCRIPTION OF THE DRAWINGS

[0015] In order to more clearly illustrate the technical solution of the present application, the drawings required for use in the embodiments are briefly introduced below. Obviously, for ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0016] Figure 1 A flowchart of a text classification method according to some embodiments is shown;

[0017] Figure 2 A data flow diagram of a text classification method according to some embodiments is shown. DETAILED DESCRIPTION

[0018] Artificial intelligence is an emerging technology that has emerged in the past decade, and the field of natural language processing (NLP) is a subfield of artificial intelligence. Natural language processing refers to the ability of machines to understand and interpret the way humans write and speak. Among the application fields of natural language processing, text classification is a relatively widespread application field.

[0019] When using natural language processing for text classification, it is usually necessary to use labeled data for model training and use zero-shot learning methods to perform reasoning analysis on the text to be classified to achieve text classification. For example, for a certain news text, natural language processing is used to classify the news text into sports, entertainment, variety shows, etc., so that users can see the news text under a certain label classification.

[0020] However, in this text classification method, a lot of effort is required to obtain labeled data during the model training phase, and additional effort is also required to correct the data and sample the data set; when performing zero-shot learning, it is impossible to explore a sufficiently wide set of anchor points, resulting in deviations in the definition and description of the classification label, making the zero-shot learning effect poor. In addition, the distribution of different anchor points in the model output domain is not the same, and traditional methods do not effectively normalize them, resulting in poor results. It can be seen that the existing text classification methods are ineffective and cannot perform accurate text classification.

[0021] To this end, in order to improve the effect and accuracy of text classification, this application proposes a server that implements a zero-shot learning method for text classification based on domain knowledge when performing text classification. Specifically, the prompting method is introduced to perform zero-shot learning in the field of text classification without the need for any labeled data. The existing prompting ideas are optimized and domain knowledge is introduced to make the description of labels more accurate. The outputs of different anchor points are normalized, and the label anchor points are effectively aggregated to achieve better zero-shot learning results and accurate text classification.

[0022] It can be seen that a server provided by the present application, when executing the text classification method, inputs unlabeled data and a classification system, and can complete the text classification task without any labeled data. Using domain knowledge to obtain the words and word weights of each category can describe each classification type more comprehensively and accurately, making the zero-time learning effect better. Construct the template required for the prompt task, use the MLM pre-trained language model obtained by unsupervised training to infer the domain knowledge words of each category filled in the slot of the template, and finally aggregate and normalize the inference results. Due to the different distribution of domain knowledge words in the pre-training model result set, the traditional method will tend to favor words with higher frequency, resulting in a larger variance in the final result. This situation can be effectively avoided through the normalization method, making the model effect more stable and reliable, and thus accurate text classification results can be obtained.

[0023] Figure 1 A flowchart of a text classification method according to some embodiments is shown; Figure 2 Schematic diagram of a text classification method according to some embodiments. Figure 1 and Figure 2 , a server provided by an embodiment of the present invention includes: a controller, when executing a text classification method, the controller is configured to perform the following steps:

[0024] S1. Obtain text to be classified and unlabeled text data, where unlabeled text data refers to text data that does not include label meaning.

[0025] When classifying a text, get the text data to be classified t The text to be classified can be a news text, and the news text is classified into one of the tags of entertainment, sports, variety shows, music, TV series, animation, etc. For example, the text to be classified "NBA current great players" is classified.

[0026] Since this application uses the prompting method for zero-shot learning in the field of text classification, no labeled data is required. Therefore, when performing text classification, unlabeled text data is obtained. Unlabeled text data is general text data, without adding labels, only text content, and no text data emphasizing the central idea of ​​the text, such as novels. The source of unlabeled text data can be e-books or various news websites.

[0027] S2. Use the text to be classified and the unlabeled text data to train the language model to obtain a pre-trained language model, and construct a prediction template including a mask filling position, where the mask filling position is used to fill in the classification label that matches the text to be classified.

[0028] In order to achieve accurate text classification, a language model needs to be trained first, through which the probability prediction of the label classification of the text to be classified can be achieved.

[0029] To this end, we use the text to be classified and the unlabeled text data to train an unsupervised language model to obtain the MLM pre-trained language model. MLM stands for masked language model. During training, this language model masks a word, allowing the model to predict what the masked word is and output the probability of the predicted word, in order to perform text classification.

[0030] In some embodiments, when the controller performs language model training using the text to be classified and the unlabeled text data to obtain a pre-trained language model, the controller is further configured to perform the following steps:

[0031] Step 21: Use several heterogeneous language models to train the unlabeled text data to obtain an initial pre-trained language model including several different first language models.

[0032] Step 22: Use the initial pre-trained language model to train the text to be classified, and obtain a pre-trained language model including several different second language models.

[0033] In the field of NLP, there are many ways to pre-train language models. In order to use prompting for zero-shot learning, masked language models are usually selected. Therefore, when training the model, we first use a large amount of unlabeled text data (general text data) c Train n heterogeneous masked language models to obtain n different first language models c,1 ……model c,n , as the initial pre-trained language model.

[0034] Language models are used to learn common sense, language rules, words, and the relationship between words. Different first language models can achieve different knowledge learning. For example, in the first language model c If it is a language model trained based on unlabeled text data provided by Google, then the first language model model c Can be used to learn news data to obtain formal text. In the first language model c If it is a language model trained based on unlabeled text data provided by Facebook, then the first language model model c Can be used to study Wikipedia to gain common sense knowledge.

[0035] It can be seen that different first language models can be trained through unlabeled data from different sources, so different first language models are good at learning different knowledge, which is related to the corresponding unlabeled data sources.

[0036] By training and learning a large amount of general unlabeled text data, the initial pre-trained language model can learn general knowledge. However, since the text to be classified may be different from general knowledge, in order to enable the language model finally trained to learn the knowledge of the text to be classified, it is necessary to use the text to be classified for a second language model training.

[0037] When the second language model training is performed, the initial pre-trained language model is used to train the text to be classified, that is, the text data to be classified is used. t Continue on model c,1 ……model c,n Train on it to get n different second language models t,1 ……model t,n , as the final pre-trained language model. The second language model has the same learning ability as the first language model to learn the knowledge in the text to be classified. The specific implementation process is not repeated here.

[0038] The pre-trained language model finally obtained through training is the MLM pre-trained language model, which is used to predict the probability of different classification labels being generated relative to the text to be classified.

[0039] It can be seen that when training the model for the first time, using a large amount of unlabeled text data (general text data, such as news, encyclopedia) to train the pre-trained language model can enable the pre-trained language model to acquire a large amount of general knowledge. After the first training is completed, the pre-trained model is trained for the second time with the text to be classified, so that the final pre-trained language model can acquire the knowledge in the text to be classified. In order to obtain a better model effect, it is possible to choose to train the model on n heterogeneous models at the same time to obtain n language models.

[0040] In some embodiments, the language model uses a large amount of text for unsupervised training and learning. The language model can not only learn language skills, but also learn a lot of common sense. In order to obtain the knowledge contained in the language model, the same method as the "cloze test" used in MLM model training can be used to construct text containing blanks to be filled in, and let the language model fill in the blanks with appropriate words, so as to serve as the basis for classification.

[0041] Therefore, a prediction template including a mask filling position is constructed using the text to be classified and the unlabeled text data. The mask filling position is used to fill in the classification label matching the text to be classified. The prediction template is the prompt template, and the mask filling position is the mask position.

[0042] For example, data c,i = "NBA current great players", the final task of this application is to classify the text into one of m categories such as sports, entertainment, politics, etc. Since n trained heterogeneous MLM models have been obtained in step S2, the MLM model can be used to give recommended words in the positions where the blanks need to be filled in for a given "cloze" text. Therefore, a template "Let's look at articles of type [mask]: [text]" can be constructed, and the text to be classified can be filled in to obtain a prediction template "Let's look at articles of type [mask]: NBA current great players".

[0043] Among them, the template "Let's take a look at articles of type [mask]: [text]" can be constructed based on unlabeled text data, that is, the template can be summarized from a large amount of unlabeled text data, or a suitable template can be selected from artificial templates. [mask] is the mask filling position, and [text] is the text to be classified. Fill the text to be classified "NBA current great players" into the above template to obtain the prediction template "Let's take a look at articles of type [mask]: NBA current great players". [mask] and [text] are both slots of the prompt template. The [text] slot is used to fill in the text to be classified, and the [mask] slot is used to predict the filled words and probabilities by the MLM model.

[0044] Finally, let the MLM pre-trained language model fill in the blanks in the [mask] position to output the probability of the filled words.

[0045] In some embodiments, in order to make the prediction results of the MLM model more accurate, a similar method can be used to construct b prediction templates to form a template set, and n MLM models are used to predict the b prediction templates in the template set respectively. The i-th template is defined as template i .

[0046] For example, see again Figure 2 , the template set can be (1) "Let's look at articles of type [mask]: [text]"; (2) "Articles of type [mask]: [text]"; (3) "[text], the topic of this article is [mask]", etc.

[0047] S3. Use the pre-trained language model to predict the probability of filling in different classification labels at the mask filling position, and use the classification label with the maximum probability as the target classification label of the text to be classified.

[0048] Since the pre-trained language model has the ability to predict words in different mask positions, and the prediction template is a template that needs to be filled with predicted words based on the text to be classified, the pre-trained language model can be used to infer the words that need to be filled in the mask filling position in the prediction template, and output the probability of each filled-in word, and the word is the classification label that needs to be filled in the mask filling position.

[0049] In existing text classification, multiple preset classification labels are used. Each classification label is filled into the mask filling position in the prediction template in turn. The pre-trained language model predicts the probability of the classification label filled in the mask filling position to obtain the probability of each classification label.

[0050] Since n heterogeneous MLM pre-trained language models can be obtained when training the model, and b different prediction templates can be obtained when building the prediction template, in order to ensure the accuracy of the prediction probability of each classification label, that is, the matching degree between each classification label and the text to be classified, n trained MLM models can predict b templates in turn.

[0051] For example, using n trained MLM models, predicting b templates in turn (filling the mask position of the template with the label domain knowledge word), we get predict i,j,w , which represents the probability of the word w when the i-th model predicts the j-th model. i,j,nba =0.2 means "Let's look at an article of type [mask]: great current NBA players", and the probability of filling in the word NBA is 02.

[0052] See again Figure 2 , when template 1 is "Let's look at the article of type [mask]: NBA great players in action", the classification labels predicted by model A are movies, NBA and basketball, and their respective probabilities are represented by bar graphs, among which NBA has the highest probability; the classification labels predicted by model B are basketball, variety shows and animation, and their respective probabilities are represented by bar graphs, among which animation has the highest probability; the classification labels predicted by model C are basketball, NBA and documentary, and their respective probabilities are represented by bar graphs, among which NBA has the highest probability. The prediction results of models A, B and C corresponding to template 2 can refer to the above method, which will not be repeated here.

[0053] Based on the above method, the probability of filling in different classification labels in the mask filling position is predicted through the pre-trained language model, and different probability values ​​are generated. The generated probability values ​​are sorted, and the classification label with the maximum probability is used as the target classification label of the text to be classified. For example, the probability of the classification label NBA predicted by the A model and the C model is the highest in each group. Therefore, NBA is used as the target classification label for the text to be classified "NBA current great players".

[0054] In some embodiments, when using the prompting method for zero-shot learning in the field of text classification, it is impossible to explore a sufficiently wide set of anchor points, resulting in deviations in the definition and description of the classification labels, which leads to poor results in zero-shot learning. In addition, the distribution of different anchor points (slots) in the model output domain is not the same, and traditional methods do not effectively normalize them, resulting in poor results.

[0055] To this end, this application can use domain knowledge to obtain the words and word weights of each category, which can describe each classification type more comprehensively and accurately, making zero-shot learning more effective. After building the template required for the prompt task, the MLM pre-trained language model obtained by unsupervised training is used to infer the domain knowledge words of each category filled in the slots of the template, and finally the inference results are aggregated and normalized. Due to the different distribution of domain knowledge words in the pre-training model result set, traditional methods will tend to favor words with higher frequency, resulting in a larger variance in the final result. This situation can be effectively avoided through the normalization method, making the model effect more stable and reliable, and thus accurate text classification results can be obtained.

[0056] To this end, when performing text classification, in order to improve the accuracy of text classification, after the MLM model predicts the probability, the controller is further configured to perform the following steps:

[0057] Step 41: After using the pre-trained language model to predict the probability of filling in the mask filling position with different classification labels, obtain the related words of each classification label, and construct the domain knowledge words corresponding to each classification label based on the related words.

[0058] Step 42: Based on the pre-trained language model, the prediction template and the domain knowledge words corresponding to each classification label, data processing is performed on the probability of each classification label, and the classification label with the maximum probability generated after data processing is used as the target classification label of the text to be classified.

[0059] Since this application is to classify the text to be classified into one of m categories such as sports, entertainment, politics, etc., if the category word is directly used as an anchor point and MLM is used to obtain its probability, it is ambiguous, cannot cover all meanings, and has a large variance.

[0060] At the semantic level that cannot cover all, the categories are very complex and usually have extremely many semantics, which cannot be covered by a single word. For example, "Let's look at the article of type [mask]: NBA great players in action." The existing language model does not know the preset classification system, but when the model sees that NBA and active players appear in the following text, it tends to fill in the word NBA in the mask position and give a relatively low probability to sports words.

[0061] In terms of ambiguity and variance, natural language contains a lot of ambiguity, because each word may have extremely many meanings, which is often called polysemous words. Similarly, a sample may also have many meanings. It may be best classified as sports, but it also makes sense to classify it as entertainment.

[0062] Therefore, in order to avoid the above problems when the MLM model predicts the appropriate words to be filled in the masked position, the present application constructs domain knowledge words for each classification label to more comprehensively and accurately describe each classification type, so that the zero-shot learning effect is better, and the MLM model can more accurately predict the probability of the words filled in the masked position to infer the classification label of the text to be classified.

[0063] In some embodiments, when constructing the domain knowledge words corresponding to each classification label, the related words of each classification label preset may be obtained and constructed based on the related words. Specifically, when executing the process of obtaining the related words of each classification label, the controller is further configured to perform the following steps:

[0064] Step 411: Based on the knowledge base, obtain the initial domain knowledge words of each classification label.

[0065] Step 412: Generate the nearest neighbor knowledge word corresponding to each classification label through the open source word2vec model.

[0066] Step 413: Obtain synonyms, hypernyms, and hyponyms of each classification label through an open source dictionary.

[0067] Step 414: Based on the definition of each classification label, a corresponding prediction template including a mask filling position is constructed, and the pre-trained language model is used to predict the keywords filled in the mask filling position to obtain a vocabulary including keywords corresponding to each classification label.

[0068] Step 415: Use the initial domain knowledge words, synonyms, hypernyms, hyponyms, nearest neighbor knowledge words and vocabulary as related words corresponding to each classification label.

[0069] Related words of a classification label refer to words that are semantically identical or related to the classification label, including but not limited to initial domain knowledge words, synonyms, hypernyms, hyponyms, nearest neighbor knowledge words, and vocabularies.

[0070] For each category label (e.g., sports), the initial domain knowledge words of each category label word can be obtained through crawlers or internal knowledge bases. init Each classification label generates the nearest neighbor knowledge words through the open source word2vec model vec . Find synonyms, hypernyms and hyponyms of the classification tag words through open source dictionaries or wordnet net Among them, the nearest neighbor knowledge word refers to a word that is semantically close to the classification label word, the synonym refers to a word that has the same semantics as the classification label word, the hypernym refers to the word at the upper level of the classification label word, and the hyponym refers to the word at the lower level of the classification label word. For example, style belongs to the hypernym, and its hyponym is sports, etc. The hyponym of sports is baseball or NBA, etc.

[0071] The vocabulary refers to the words related to the classification label words. When determining the vocabulary, the definition of each classification label is obtained. For example, "sports is a complex social and cultural phenomenon. It takes physical and intellectual activities as basic means, according to the laws of human growth and development, skill formation and function improvement, to promote all-round development, improve physical quality and overall education level, enhance physical fitness and improve athletic ability, improve lifestyle and improve the quality of life. It is a conscious, purposeful and organized social activity."

[0072] Construct a prediction template including the mask filling position corresponding to the definition of sports, that is, mask the two words "sports" in the definition, and get the prediction template as "[mask] is a complex social and cultural phenomenon. It uses physical and intellectual activities as basic means, according to the laws of human growth and development, skill formation and function improvement, to promote all-round development, improve physical quality and overall education level, enhance physical fitness and improve athletic ability, improve lifestyle and improve quality of life. A conscious, purposeful and organized social activity". The [mask] position is a mask filling position, which is used to fill in the keywords that meet the content of this definition.

[0073] Let the MLM pre-trained language model predict the keywords filled in the [mask] position, and use the predicted keywords to form a vocabulary word 1m Finally, the inaccurate words in each vocabulary are filtered out manually, and then the words init 、words vec 、words net 、words lmMerge to get the relevant words of the corresponding classification labels, and then construct the final domain knowledge words.

[0074] For example, domain knowledge words related to sports may be running, track and field, gymnastics, basketball, NBA, CBA, athlete, etc. Domain knowledge words related to entertainment may be movies, TV series, variety shows, documentaries, animation, etc.

[0075] In some embodiments, due to the different distribution of domain knowledge words in the pre-trained language model result set, traditional methods tend to favor words with higher frequencies, resulting in a larger variance in the final result. In order to effectively avoid this situation and make the model effect more stable and reliable, the present application can normalize the outputs of different anchor points and effectively aggregate the classification label anchor points, that is, normalize and aggregate the probabilities of each classification label predicted by the MLM model, so that the effect of zero-shot learning is better and accurate text classification is achieved.

[0076] It can be seen that when performing zero-shot learning of text classification, different pre-trained language models and prediction templates used will affect the prediction results. To this end, after the MLM model predicts each classification label at the mask filling position in the prediction template, the probability of each classification label is processed based on the pre-trained language model, the prediction template and the domain knowledge words corresponding to each classification label, and the classification label with the maximum probability after data processing is used as the target classification label of the text to be classified.

[0077] In some embodiments, the controller is further configured to perform the following steps when performing data processing on the probability of each classification label based on the pre-trained language model, the prediction template, and the domain knowledge words corresponding to each classification label:

[0078] Step 421: Based on the pre-trained language model, the prediction template and the domain knowledge words, the predicted probability of each classification label is normalized to obtain the normalized probability of the classification label.

[0079] Step 422: Perform weighted aggregation processing on the probability of each normalized classification label, calculate the weight of each classification label relative to the text to be classified, and calculate the probability of the data processed corresponding to the classification label based on the weight.

[0080] The method for data processing the output results of the MLM model includes normalization processing and aggregation processing. When performing text classification, there are multiple preset classification labels, multiple pre-trained language models, and multiple constructed prediction templates. Therefore, under a certain prediction template, there are multiple probabilities of classification labels predicted by the pre-trained language model. Therefore, it is necessary to use multiple pre-trained language models, multiple prediction templates, and domain knowledge words to normalize the probability of each predicted classification label separately to obtain the normalized probability of each classification label.

[0081] During normalization, the model output probability of the pre-trained language model i for predicting template j and filling in the word word conforms to the normal distribution N i,j,word (μ, σ 2 ) In order to accurately describe the estimation of the distribution, the text set data to be classified can be obtained t , data t Includes several text data to be classified to more accurately describe the normal distribution relationship between the model, template and domain knowledge words. Based on the distribution estimation of each model output probability corresponding to multiple texts to be classified, the model output probability output is obtained. i,j,word,k .output i,j,word,k Indicates that for data t In the kth data, model i outputs the probability of the model filling in the word word for template j. Among them, i refers to different heterogeneous pre-trained language models; j refers to different prediction templates; word refers to different domain knowledge words; data t The k-th data refers to the text to be classified that currently needs to be classified.

[0082] According to the maximum likelihood estimation, we can get the mean

[0083] variance

[0084] In the formula, μ i,j,word represents the mean of each word filled in by model i for template j; σ i,j,word Represents the variance of each filled-in word of model i for template j.

[0085] After obtaining the normal distribution, transform it so that all distributions satisfy the standard normal distribution, as follows:

[0086]

[0087] In the formula, Indicates the data after normalization t In the kth data, model i outputs the probability of filling in the word word for template j.

[0088] The output probability of each prediction template of each MLM model is normalized according to the above method to obtain the probability of each normalized classification label. Then, the probability of each normalized classification label is weighted and aggregated to calculate the weight of each classification label relative to the text to be classified, and the weight is used as the probability of the corresponding classification label after data processing.

[0089] During the aggregation process, the "deviation weight method" is used to perform weighted aggregation on the normalized results. To this end, the variance in the normalized probability (i.e., the indicator) is used as the weight. A large variance means that the indicator has a large distinction between the different objects being compared; a small variance means that the indicator has a small distinction between the different objects being compared.

[0090] Then, in weighted aggregation, for data t The kth data in the set of classification labels L i The weight is:

[0091] Based on this method, the weight of each classification label can be obtained, and the softmax function is used to process it to obtain the probability of each classification label for the aggregated text to be classified. Finally, the classification label corresponding to the maximum probability is used as the target classification label of the text to be classified.

[0092] For example, see again Figure 2 ,After normalization and aggregation processing, the probability of sports classification is calculated to be higher than the probability of ,entertainment classification, therefore, sports is used as the target classification label of the ,text to be classified.

[0093] It can be seen that the target classification label selected without data processing (normalization and aggregation) may be different from the target classification label selected after data processing. The target classification label of the text to be classified based on the probability of each classification label without data processing is NBA, while the target classification label of the text to be classified based on the probability of each classification label after data processing is entertainment. Therefore, the probability of each classification label after data processing is more accurate, that is, the output result of the MLM model for the prediction template is more accurate, which can ensure the accuracy of text classification.

[0094] It can be seen from the above technical solutions that a server provided by an embodiment of the present invention, when classifying a text to be classified, uses the text to be classified and unlabeled text data to train a language model to obtain a pre-trained language model, and constructs a prediction template including a mask filling position; uses the pre-trained language model to predict the probability of filling in different classification labels in the mask filling position, and uses the classification label with the maximum probability as the target classification label of the text to be classified. The server can reduce data processing efficiency by using unlabeled data. Using domain knowledge to obtain the words and word weights of each category can more comprehensively and accurately describe each classification type, so that the zero-time learning effect is better. After constructing the prediction template required for the prompt task, the MLM pre-trained language model obtained by unsupervised training is used to infer the domain knowledge words of each category filled in the slot of the template, and finally the inference results are aggregated and normalized, so that the model output effect is more stable and reliable, and accurate text classification results can be obtained.

[0095] Figure 1 FIG. 4 is a flowchart showing a text classification method according to some embodiments. Figure 1 , a text classification method provided by an embodiment of the present invention is executed by a controller in the server provided by the above embodiment, and the method includes:

[0096] S1. Obtaining text to be classified and unlabeled text data, wherein the unlabeled text data refers to text data that does not include label meaning;

[0097] S2, using the text to be classified and the unlabeled text data to perform language model training to obtain a pre-trained language model, and constructing a prediction template including a mask filling position, wherein the mask filling position is used to fill in a classification label matching the text to be classified;

[0098] S3. Using the pre-trained language model to predict the probability of the mask filling position when filling in different classification labels, the classification label with the maximum probability is used as the target classification label of the text to be classified.

[0099] In some embodiments of the present application, the language model training is performed using the text to be classified and the unlabeled text data to obtain a pre-trained language model, including:

[0100] Using a plurality of heterogeneous language models to train the unlabeled text data, to obtain an initial pre-trained language model including a plurality of different first language models;

[0101] The text to be classified is trained using the initial pre-trained language model to obtain a pre-trained language model including several different second language models.

[0102] In some embodiments of the present application, the method further includes:

[0103] After using the pre-trained language model to predict the probability of filling in the mask filling position with different classification labels, obtain the related words of each classification label, and construct the domain knowledge words corresponding to each classification label based on the related words;

[0104] Based on the pre-trained language model, the prediction template and the domain knowledge words corresponding to each classification label, data processing is performed on the probability of each classification label, and the classification label with the maximum probability generated after data processing is used as the target classification label of the text to be classified.

[0105] In some embodiments of the present application, obtaining related words for each classification label includes:

[0106] Based on the knowledge base, obtain the initial domain knowledge words for each classification label;

[0107] Generate the nearest neighbor knowledge word corresponding to each classification label through the open source word2vec model;

[0108] Obtain synonyms, hypernyms, and hyponyms for each classification label through open source dictionaries;

[0109] Based on the definition of each classification label, a corresponding prediction template including the mask filling position is constructed, and the pre-trained language model is used to predict the keywords filled in the mask filling position to obtain a vocabulary including keywords corresponding to each classification label;

[0110] The initial domain knowledge words, synonyms, hypernyms, hyponyms, nearest neighbor knowledge words and vocabulary are used as related words corresponding to each classification label.

[0111] In some embodiments of the present application, based on the pre-trained language model, the prediction template and the domain knowledge words corresponding to each classification label, data processing is performed on the probability of each classification label, including:

[0112] Based on the pre-trained language model, prediction template and domain knowledge words, the probability of each predicted classification label is normalized to obtain the normalized probability of the classification label;

[0113] The probability of each normalized classification label is subjected to weighted aggregation processing, the weight of each classification label relative to the text to be classified is calculated, and the probability of the data processed corresponding to the classification label is calculated based on the weight.

[0114] In a specific implementation, the present invention further provides a storage medium, wherein the storage medium may store a program, and when the program is executed, the program may include some or all of the steps in each embodiment of the text classification method provided by the present invention. The storage medium may be a disk, an optical disk, a read-only memory (ROM) or a random access memory (RAM).

[0115] Those skilled in the art can clearly understand that the technology in the embodiments of the present invention can be implemented by means of software plus a necessary general hardware platform. Based on this understanding, the technical solution in the embodiments of the present invention can essentially be embodied in the form of a software product, or the part that contributes to the prior art, and the software product can be stored in a storage medium, such as ROM / RAM, a magnetic disk, an optical disk, etc.

[0116] In this specification, the same or similar parts between the various embodiments can be referred to each other. In particular, for the text classification method embodiment, since it is basically similar to the server embodiment, the description is relatively simple, and the relevant parts can be referred to the description in the server embodiment.

[0117] The above-described embodiments of the present invention do not limit the protection scope of the present invention.

Claims

1. A server, characterized in that: include: The controller is configured as: Acquire text to be classified and unlabeled text data, wherein the unlabeled text data refers to text data that does not include label meaning; Performing language model training using the text to be classified and unlabeled text data to obtain a pre-trained language model, and constructing a prediction template including a mask filling position, wherein the mask filling position is used to fill in a classification label matching the text to be classified; Using the pre-trained language model to predict the probability of the mask filling position when filling in different classification labels; Obtaining related words for each classification label, and constructing domain knowledge words corresponding to each classification label based on the related words; Calculating the normalized probability of each classification label of the pre-trained language model under the prediction template and the domain knowledge word, wherein the normalized probability conforms to a standard normal distribution; Calculate the weight of each classification label relative to the text to be classified, where the weight is the variance corresponding to the standard normal distribution that the normalized probability conforms to; Calculate the weighted aggregation probability of the corresponding classification label based on the weight; The classification label that generates the maximum probability is used as the target classification label of the text to be classified.

2. The server according to claim 1, characterized in that: The controller is further configured to: Using a plurality of heterogeneous language models to train the unlabeled text data, to obtain an initial pre-trained language model including a plurality of different first language models; The text to be classified is trained using the initial pre-trained language model to obtain a pre-trained language model including several different second language models.

3. The server according to claim 1, characterized in that: When executing the step of obtaining the related words of each classification label, the controller is further configured to: Based on the knowledge base, obtain the initial domain knowledge words for each classification label; Generate the nearest neighbor knowledge word corresponding to each classification label through the open source word2vec model; Obtain synonyms, hypernyms, and hyponyms for each classification label through open source dictionaries; Based on the definition of each classification label, a corresponding prediction template including the mask filling position is constructed, and the pre-trained language model is used to predict the keywords filled in the mask filling position to obtain a vocabulary including keywords corresponding to each classification label; The initial domain knowledge words, synonyms, hypernyms, hyponyms, nearest neighbor knowledge words and vocabulary are used as related words corresponding to each classification label.

4. The server according to claim 1, characterized in that: The controller is further configured to: The distribution of the model output probability of the pre-trained language model under the prediction template and domain knowledge words is estimated to obtain the model output probability that conforms to the normal distribution; According to the maximum likelihood estimation, the mean and variance corresponding to the normal distribution that the model output probability conforms to are calculated; According to the mean and the variance, the model output probability that conforms to the normal distribution is converted into the model output probability that conforms to the standard normal distribution to obtain the normalized probability of the classification label; Calculate the weighted aggregate value of each classification label relative to the text to be classified, where the weighted aggregate value is the product of the weight of the classification label and the normalized probability; The weighted aggregate values ​​are processed based on the softmax function to obtain the weighted aggregate probability of the classification label.

5. A text classification method, characterized in that: The method comprises: Acquire text to be classified and unlabeled text data, wherein the unlabeled text data refers to text data that does not include label meaning; Performing language model training using the text to be classified and unlabeled text data to obtain a pre-trained language model, and constructing a prediction template including a mask filling position, wherein the mask filling position is used to fill in a classification label matching the text to be classified; Using the pre-trained language model to predict the probability of the mask filling position when filling in different classification labels; Obtaining related words for each classification label, and constructing domain knowledge words corresponding to each classification label based on the related words; Calculating the normalized probability of each classification label of the pre-trained language model under the prediction template and the domain knowledge word, wherein the normalized probability conforms to a standard normal distribution; Calculate the weight of each classification label relative to the text to be classified, where the weight is the variance corresponding to the standard normal distribution that the normalized probability conforms to; Calculate the weighted aggregation probability of the corresponding classification label based on the weight; The classification label that generates the maximum probability is used as the target classification label of the text to be classified.

6. The method according to claim 5, characterized in that The method of using the text to be classified and the unlabeled text data to perform language model training to obtain a pre-trained language model includes: Using a plurality of heterogeneous language models to train the unlabeled text data, to obtain an initial pre-trained language model including a plurality of different first language models; The text to be classified is trained using the initial pre-trained language model to obtain a pre-trained language model including several different second language models.

7. The method according to claim 5, characterized in that The obtaining of related words for each classification label includes: Based on the knowledge base, obtain the initial domain knowledge words for each classification label; Generate the nearest neighbor knowledge word corresponding to each classification label through the open source word2vec model; Obtain synonyms, hypernyms, and hyponyms for each classification label through open source dictionaries; Based on the definition of each classification label, a corresponding prediction template including the mask filling position is constructed, and the pre-trained language model is used to predict the keywords filled in the mask filling position to obtain a vocabulary including keywords corresponding to each classification label; The initial domain knowledge words, synonyms, hypernyms, hyponyms, nearest neighbor knowledge words and vocabulary are used as related words corresponding to each classification label.

8. The method according to claim 5, characterized in that The method further comprises: The distribution of the model output probability of the pre-trained language model under the prediction template and domain knowledge words is estimated to obtain the model output probability that conforms to the normal distribution; According to the maximum likelihood estimation, the mean and variance corresponding to the normal distribution that the model output probability conforms to are calculated; According to the mean and the variance, the model output probability that conforms to the normal distribution is converted into the model output probability that conforms to the standard normal distribution to obtain the normalized probability of the classification label; Calculate the weighted aggregate value of each classification label relative to the text to be classified, where the weighted aggregate value is the product of the weight of the classification label and the normalized probability; The weighted aggregate values ​​are processed based on the softmax function to obtain the weighted aggregate probability of the classification label.