Classification model training method, text classification method and device

By combining multiple classification labels into a label sequence and the text to be classified as input in the machine reading comprehension framework, the problem of deviation between abstract categories and real categories in text multi-label classification is solved, and the accuracy and efficiency of text classification are improved. It is applicable for multi-label classification tasks.

CN113010678BActive Publication Date: 2024-10-15BEIJING BAIDU NETCOM SCI & TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110288663.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-03-17
Publication Date
2024-10-15
Estimated Expiration
2041-03-17

AI Technical Summary

Technical Problem

Existing text classification methods cannot effectively alleviate the deviation problem between abstract categories and real categories when dealing with multi-label classification tasks. Especially when the training data sample space is insufficient, the accuracy and generalization of the classification model are compromised. insufficient.

Method used

Using an improved classification method based on the machine reading comprehension framework, multiple predefined classification labels are combined into a label sequence as the context input of the model, and the text to be classified is used as the query input. The classification model trained through the machine reading comprehension model can be used in Accurately determine the true category of text in multi-label single and multi-classification tasks.

Benefits of technology

This method can not only adapt to text classification tasks, but also effectively solve the problem of deviation between abstract categories and real categories in multi-label text classification tasks, improve the accuracy and efficiency of text classification, and is suitable for public opinion analysis and other multi-label classification application scenarios. .

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113010678B_ABST
    Figure CN113010678B_ABST
Patent Text Reader

Abstract

The present disclosure discloses a training method for a classification model, which relates to the field of natural language processing, and in particular to the field of machine learning. The specific implementation scheme is: defining a label sequence as text information, wherein the label sequence is composed of predefined classification labels; obtaining a first data set, and defining samples in the first data set as question information; and using the text information and the question information as the text input and the question input of the preset model respectively to train the preset model to obtain a classification model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of natural language processing, and in particular to the field of machine learning. Specifically, it relates to a classification model training method, a text classification method, a classification model training device, a text classification device, an electronic device, a non-transient computer-readable storage medium storing computer instructions, and a computer program product. Background Art

[0002] An abstract category can be understood as an aggregation result of samples with similar features, while a true category can be understood as a specific and clear category definition. Suppose there is a batch of short texts that need to be classified, and the category labels include fruit, vegetables, meat, etc. When defining the category, the true category "fruit" includes watermelon, cantaloupe, and papaya. We hope that the classification model can classify watermelon, cantaloupe, and papaya into the true category of "fruit" when making predictions. In fact, after a large amount of data training, the classification model can indeed aggregate watermelon, cantaloupe, and papaya into the same category. We call this aggregated category an "abstract category". An abstract category is just the product of the classification model aggregating samples with similar features together, and it does not have a clear category definition. Therefore, the "abstract category" obtained by the classification model can be "fruit", "melon", or other logical category definitions. Summary of the invention

[0003] The present disclosure provides a classification model training method, a text classification method, an apparatus, a device, a storage medium, and a computer program product.

[0004] According to one aspect of the present disclosure, a method for training a classification model is provided. The method includes: defining a label sequence as text information, wherein the label sequence is composed of predefined classification labels; obtaining a first data set, and defining samples in the first data set as question information; and using the text information and the question information as text input and question input of a preset model respectively to train the preset model to obtain the classification model.

[0005] According to another aspect of the present disclosure, a text classification method is provided. The method includes: defining a tag sequence as text information, wherein the tag sequence is composed of predefined classification tags; obtaining a text to be classified, and defining the text to be classified as question information; and inputting the text information and the question information as text input and question input, respectively, into a classification model to obtain a classification result for the text to be classified.

[0006] According to another aspect of the present disclosure, a training device for a classification model is provided. The device includes: a first preprocessing module, which is used to define a label sequence as text information, wherein the label sequence is composed of predefined classification labels; a second preprocessing module, which is used to obtain a first data set and define samples in the first data set as question information; and a training module, which is used to train the preset model by using the text information and the question information as the text input and the question input of the preset model respectively, so as to obtain the classification model.

[0007] According to another aspect of the present disclosure, a text classification device is provided. The device includes: a third preprocessing module, used to define a label sequence as text information, wherein the label sequence is composed of predefined classification labels; a fourth preprocessing module, used to obtain a text to be classified and define the text to be classified as question information; and a classification module, used to input the text information and the question information as text input and question input, respectively, into a classification model to obtain a classification result for the text to be classified.

[0008] According to another aspect of the present disclosure, an electronic device is provided, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the method described in an embodiment of the present disclosure.

[0009] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to cause the computer to execute the method according to the embodiment of the present disclosure.

[0010] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, and when the computer program is executed by a processor, the method according to the embodiment of the present disclosure is implemented.

[0011] It should be understood that the content described in this section is not intended to identify the key or important features of the embodiments of the present disclosure, nor is it intended to limit the scope of the present disclosure. Other features of the present disclosure will become easily understood through the following description. BRIEF DESCRIPTION OF THE DRAWINGS

[0012] The accompanying drawings are used to better understand the present solution and do not constitute a limitation of the present disclosure.

[0013] Figure 1A The training method and device system architecture of the classification model suitable for the embodiment of the present disclosure are exemplified;

[0014] Figure 1BA scene diagram showing an exemplary method and device for implementing the text classification method of the embodiment of the present disclosure is shown;

[0015] Figure 2 A flowchart of a method for training a classification model according to an embodiment of the present disclosure is exemplified;

[0016] Figure 3 The schematic diagram of training the BERT model according to an embodiment of the present disclosure is exemplified;

[0017] Figure 4 A flowchart of a text classification method according to an embodiment of the present disclosure is exemplified;

[0018] Figure 5 The schematic diagram of the extractive text classification method based on the reading comprehension framework according to the embodiment of the present disclosure is exemplified;

[0019] Figure 6 A block diagram of a training device for a classification model according to an embodiment of the present disclosure is exemplarily shown;

[0020] Figure 7 A block diagram exemplarily shows a text classification device according to an embodiment of the present disclosure; and

[0021] Figure 8 The block diagram of an electronic device used to implement the training method and / or classification method of the classification model of the embodiment of the present disclosure is exemplarily shown. DETAILED DESCRIPTION

[0022] The following is a description of exemplary embodiments of the present disclosure in conjunction with the accompanying drawings, including various details of the embodiments of the present disclosure to facilitate understanding, which should be considered as merely exemplary. Therefore, it should be recognized by those of ordinary skill in the art that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present disclosure. Similarly, for the sake of clarity and conciseness, the description of well-known functions and structures is omitted in the following description.

[0023] It should be understood that the "abstract category" predicted by the classification model is not necessarily equal to the "real category". Only when the sample space of the training data is sufficient can the "abstract category" be infinitely close to the "real category". However, in a real production environment, the sample space of the training data is unlikely to be sufficient, so the deviation between the "abstract category" and the "real category" is bound to exist.

[0024] At present, the text classification methods provided in related technologies mainly include rule matching methods, traditional machine learning methods (such as svm, xgboost methods) and deep learning methods (such as Text CNN, RNN, etc.).

[0025] It should be understood that the above rule matching method requires rule summarization based on the experience of experts, so this method is time-consuming and laborious. In practical applications, the generalization of the classification method based on rule matching is not guaranteed. For example, the matching rules of positive or negative words are often powerless when faced with texts containing words such as "negation" or "metaphor". This phenomenon shows that the classification method based on rule matching has poor generalization, and the accuracy and coverage of the classification model are very limited.

[0026] It should also be understood that traditional machine learning methods are shallow semantic feature modeling methods, and their modeling process can be summarized as a two-stage process of combining artificial feature engineering with shallow classification models. The quality of artificial feature engineering often has a direct impact on the final classification effect of the classification model. At the same time, shallow classification models do not have the ability to mine deep semantic features. Therefore, the text classification effect of traditional machine learning methods quickly reached its ceiling.

[0027] It should also be understood that deep learning is the most effective text classification solution in recent years. Deep learning uses various types of neural networks to automatically mine the deep semantic features of text, and can provide more accurate classification predictions than traditional machine learning methods. However, due to the problem definition and modeling methods of traditional text classification, current text classification methods do not effectively add relevant information of classification labels as prior knowledge to model training. Therefore, the text classification method based on deep learning in related technologies still cannot solve the problem of deviation between abstract categories and real categories.

[0028] For example, Machine Reading Comprehension (MRC) is a method based on deep machine learning modeling. MRC enables machines to complete reading comprehension tasks. MRC is mainly divided into three parts: context, query, and answer. The so-called context can be simply understood as a piece of text, which can be a sentence or a paragraph. The query can be understood as a question about the context, and the answer can be understood as the answer corresponding to the query. The machine reading comprehension model takes the context and query as the model input, and the corresponding answer is the model output.

[0029] In the past two years, some scholars have applied the machine reading comprehension framework to the text classification problem. Specifically, in the text classification problem under the machine reading comprehension framework, the text to be classified is defined as the context input of the model, the category label is defined as the query input of the model, and the model output, i.e., the answer, is the corresponding binary classification result, that is, whether the text to be classified belongs to the current category label. In this framework, the category label is input into the model as prior knowledge. When the sample space of the training data is insufficient, it can help the model alleviate the deviation problem between the "abstract category" and the "real category" to a certain extent. However, the above classification method based on the machine reading comprehension framework can only complete the text binary classification task, that is, predict whether the text to be classified belongs to the current category label. For the text multi-label classification task, no effective solution has been proposed yet. This is because the existing binary classification task defines the category label as the query for model training, which cannot adapt to the text multi-label classification task.

[0030] The present disclosure provides an improved classification method based on a machine reading comprehension framework, which can not only adapt to text binary classification tasks, but also adapt to text multi-label classification tasks (including text multi-label single classification tasks and text multi-label multi-classification tasks).

[0031] The present disclosure will be described in detail below with reference to specific embodiments.

[0032] The system architecture of the training method and apparatus for the classification model suitable for the embodiments of the present disclosure is introduced as follows.

[0033] Figure 1A The training method and device system architecture of the classification model suitable for the embodiment of the present disclosure are exemplified. It should be noted that: Figure 1A The examples shown are merely examples of system architectures to which the embodiments of the present disclosure may be applied, in order to help those skilled in the art understand the technical content of the present disclosure, but do not mean that the embodiments of the present disclosure may not be used in other environments or scenarios.

[0034] like Figure 1A As shown, the system architecture 100 may include a client 101 , a server 102 and a database 103 .

[0035] The user may predefine one or more classification tags on the client 101 , and send the predefined tag information to the server 102 .

[0036] The server 102 can combine the above-mentioned predefined one or more classification labels into a label sequence based on the received label information, and define the label sequence as text information (context). At the same time, the server 102 can obtain training data (such as text samples) from the sample space of the database 103, and define the training data as question information (query). Further, the server 102 can use the label sequence as the context input of the machine reading comprehension model, and use the training data as the query input of the machine reading comprehension model to train the machine reading comprehension model so as to obtain the classification model of the embodiment of the present disclosure.

[0037] It should be understood that Figure 1A The number of clients, servers and databases in the embodiment is only for illustration. Any number of clients, servers and databases may be provided according to the implementation requirements.

[0038] The application scenarios of the training method and device for the classification model of the embodiment of the present disclosure are introduced as follows.

[0039] Figure 1B A scenario diagram exemplarily illustrates a method and apparatus for training a classification model that can implement an embodiment of the present disclosure.

[0040] like Figure 1B As shown in the figure, suppose there is a batch of phrase texts that need to be classified, and the category labels include fruits, vegetables, meat, etc. When defining the category, the real category "fruit" includes watermelon, cantaloupe and papaya. We hope that the classification model can classify watermelon, cantaloupe and papaya into the real category of "fruit" when making predictions. In fact, after a large amount of data training, the classification model can indeed aggregate watermelon, cantaloupe and papaya into the same category. We call this aggregated category an "abstract category". The abstract category is just the product of the classification model aggregating samples with similar features together, and it does not have a clear category definition. Therefore, the "abstract category" obtained by the classification model can be "fruit", "melon" or other logical category definitions (such as Figure 1B In other words, the "abstract category" predicted by the model is not necessarily equal to the "real category". In the prior art, the "abstract category" obtained by model training can only be infinitely close to the "real category" when the sample space of the training data is sufficient. In this scenario, the classification model training method provided by the embodiment of the present disclosure can alleviate the deviation problem between the "abstract category" and the "real category" as much as possible even in a real production environment when the sample space of the training data is not sufficient.

[0041] It should be understood that the classification model obtained by using the classification model training method provided by the embodiment of the present disclosure can be used for text multi-label classification business scenarios in public opinion analysis projects (such as government news classification, news event classification, etc.), and can also be easily extended to other similar text multi-label classification application scenarios.

[0042] Experiments have shown that in public opinion analysis projects, applying the text classification method provided by the embodiments of the present disclosure to the news and government affairs industry classification field has a significant improvement effect on the classification effect.

[0043] It should be noted that the use of this method for public opinion analysis can comprehensively analyze Internet public opinion, provide data and analysis capabilities such as real-time public opinion, semantic analysis, search index and event context, and help users grasp the pulse of current affairs. In the public opinion analysis scenario, the classification of news events is usually involved. The classification of news events can be abstracted into a text multi-label classification task. Through the disclosed embodiment, the deviation problem between "abstract categories" and "real categories" can be well handled when classifying news events, making the classification more accurate, which is more conducive to users' grasp of public opinion.

[0044] According to an embodiment of the present disclosure, the present disclosure provides a training method for a classification model.

[0045] Figure 2 A flowchart of a method for training a classification model according to an embodiment of the present disclosure is exemplified.

[0046] like Figure 2 As shown, the classification model training method 200 may include: operations S210 to S230.

[0047] In operation S210, a tag sequence is defined as text information, wherein the tag sequence is composed of predefined classification tags.

[0048] In operation S220 , a first data set is acquired, and samples in the first data set are defined as question information.

[0049] In operation S230, the text information obtained in operation S210 and the question information obtained in operation S220 are respectively used as the text input (ie, context input) and question input (ie, query input) of the preset model to train the preset model to obtain a classification model.

[0050] It should be understood that the existing text binary classification task based on the machine reading comprehension framework defines the training data (text samples) as the context input of the machine reading comprehension model and the classification label as the query input of the machine reading comprehension model, so this actually defines a text classification problem.

[0051] The embodiment of the present disclosure is exactly the opposite of this, that is, the training data (text samples) are defined as the query input of the machine reading comprehension model, and one or more classification labels are defined as the context input of the machine reading comprehension model. This actually converts the traditional text classification problem into an extractive machine reading comprehension problem.

[0052] On the one hand, in the machine reading comprehension framework, the label sequence is explicitly input into the model as prior knowledge, which can optimize the model's multi-head attention mechanism and allow the model to focus on the key areas of the text, thereby more effectively alleviating the deviation problem between "abstract categories" and "real categories".

[0053] For example, in the existing text binary classification task, it can only be concluded that the current text belongs to the current classification label or does not belong to the current classification label, which may result in the inability to accurately determine the true category of the text. However, the embodiment of the present disclosure defines a label sequence composed of multiple classification labels as the context input of the model, and defines the text to be classified as the query input of the model, so that the classification label to which the text to be classified belongs can be extracted, thereby accurately determining the true category of the text, that is, the deviation problem between the "abstract category" and the "true category" can be more effectively alleviated.

[0054] On the other hand, based on the general machine reading comprehension framework, the disclosed embodiment can define a classification label as a label sequence alone, or define multiple classification labels as a label sequence. When multiple classification labels are defined in the label sequence, the extractive text classification task can be completed based on the machine reading comprehension framework. Therefore, the disclosed embodiment can solve the text multi-label classification task. Furthermore, the disclosed embodiment can extract only one classification label at a time, or can extract multiple classification labels at a time. Therefore, the disclosed embodiment can simultaneously solve the text multi-label single classification task and the text multi-label multi-classification task.

[0055] Exemplarily, in the disclosed embodiments, the following classification labels can be predefined: fruits, vegetables, meat, etc., and these classification labels can be combined into the following label sequence "fruits#vegetables#meat#...". When training the model, the label sequence "fruits#vegetables#meat#..." is input as context into the machine reading comprehension model, and the training data involving "watermelon, cantaloupe, papaya, etc." is also input as query into the machine reading comprehension model, so that the corresponding classification model can be obtained by training the machine reading comprehension model. Using this classification model, when the text to be classified involves watermelon, cantaloupe, or papaya, the text can be clearly classified into the "fruit" category, thereby effectively alleviating the deviation problem between "abstract classification" and "real classification".

[0056] Through the embodiments of the present disclosure, the text classification problem is converted into a reading comprehension problem, and model training can be performed without the need for labeled training data (i.e., no labeled samples are required). The classification model thus obtained can realize extractive text classification, thereby more effectively solving the deviation problem between "abstract classification" and "real classification".

[0057] In addition, the disclosed embodiment, based on the machine reading comprehension framework, proposes an extractive text classification method for the text multi-label classification problem. Therefore, while the disclosed embodiment can effectively improve the text classification effect, it can also take into account different text classification tasks. For example, under the same classification model structure, it is possible to flexibly switch between text binary classification tasks, text multi-label single classification tasks, and text multi-label multi-classification tasks.

[0058] In addition, in order to achieve the same classification effect as the embodiment of the present disclosure in the text multi-label classification task, the existing text classification model based on the machine reading comprehension framework has to increase the number of model parameters as the number of classification labels increases, so the classification efficiency of the model will also decrease. In contrast, because the number of parameters of the classification model trained by the embodiment of the present disclosure is constant, the efficiency of text classification can be improved by using the classification model for text classification.

[0059] As an optional embodiment, the tag sequence may be obtained through the following operations.

[0060] Get at least one predefined category label.

[0061] The at least one classification label is arranged into an initial sequence.

[0062] Based on the initial sequence, label separators are inserted between two adjacent classification labels to obtain a label sequence.

[0063] In one embodiment, the above operations may be performed on the client to obtain a tag sequence.

[0064] Alternatively, in another embodiment, the above operation may also be performed on the server to obtain a tag sequence. Specifically, the user may predefine one or more classification tags on the client and send the predefined tag information to the server. The server may merge the above-mentioned predefined one or more classification tags into a tag sequence based on the received tag information. More specifically, all predefined classification tags may be arranged into an initial sequence randomly or in a specified order, and then tag separators may be inserted between two adjacent classification tags in the initial sequence to obtain the final tag sequence.

[0065] It should be noted that the label separator may be any character or string different from the characters included in the predefined classification labels in the label sequence, and the embodiment of the present disclosure does not limit this.

[0066] Exemplarily, n classification labels (such as label 1, label 2, ..., label n) can be predefined, and these classification labels can be concatenated using "#" as a label separator to form the label sequence "label 1#label 2#...#label n" required for the training model.

[0067] The label sequence obtained through the above preprocessing can facilitate the labeling and identification of the extracted classification labels when training the model or using the trained model to predict the classification results.

[0068] As an optional embodiment, the above-mentioned preset model may include: a BERT model.

[0069] The BERT (Bidirectional Encoder Representation from Transformer) model is a text pre-training model and also a text representation model. The BERT model can dynamically calculate the context-related vector representation of words based on the context changes of the input text. There are multiple layers of bidirectional Transformer encoders in the BERT model structure. Taking the basic version of the BERT model as an example, the BERT model contains a 12-layer bidirectional Transformer structure.

[0070] like Figure 3 As shown, training the BERT model includes two processes: pre-training and fine-tuning. Pre-training refers to adjusting the parameters of the BERT model (called pre-training parameters) through two unsupervised pre-trainings, and fine-tuning refers to using the pre-training parameters as the initialization parameters of the BERT model, and then fine-tuning the model parameters in a supervised manner according to the actual needs of the downstream tasks. It should be understood that in the embodiments of the present disclosure, when the BERT model is used as the preset model, the relevant operations in the training method of the above-mentioned classification model are performed, and the parameters of the BERT model can be fine-tuned to obtain the classification model required by the embodiments of the present disclosure.

[0071] It should be noted that the pre-training process of the BERT model can include two unsupervised pre-training tasks. These two pre-training tasks include: Masked Language Model (MLM) and Next Sentence Prediction (NSP) tasks.

[0072] For MLM, masking means randomly masking some words in the input corpus during training, and then predicting the masked words through the contextual information of the text. This task has certain similarities with the word2vec model, and its purpose is to enable the model to learn the association between words. In the BERT experiment, 15% of the words will be randomly masked. Among these 15% masked words, 80% of the cases will be replaced with placeholders (MASK), 10% of the cases will be replaced with other arbitrary words, and the remaining 10% will keep the original words unchanged. The reason for this is that if the 15% of masked words are replaced with placeholders (MASK), then (MASK) will affect the performance of the model when fine-tuning downstream tasks.

[0073] For the next sentence prediction task, the purpose of the NSP task is to enable the model to learn sentence-level associations. For example, this task can determine whether sentence B is the context of sentence A. If so, output "IsNext". Otherwise, output "NotNext". The training data is generated by selecting two sentences A and B from the corpus, with a 50% probability that A and B meet the "IsNext" relationship, and a 50% probability that A and B are randomly extracted from the corpus. That is, randomly extracted A and B indicate that they may meet "IsNext" or "NotNext". After pre-training on the NSP task, the BERT model can effectively solve downstream tasks related to sentence relationships such as Question Answering and Natural Language Inference.

[0074] Through the embodiments of the present disclosure, parameter fine-tuning can be performed on the basis of the BERT model, and the classification model required by the embodiments of the present disclosure can be obtained without pre-training.

[0075] According to an embodiment of the present disclosure, the present disclosure provides a text classification method.

[0076] Figure 4 The flowchart of the text classification method according to the embodiment of the present disclosure is exemplified.

[0077] like Figure 4 As shown, the classification method 400 may include: operations S410 to S430.

[0078] In operation S410, a tag sequence is defined as text information, wherein the tag sequence is composed of predefined classification tags.

[0079] In operation S420, a text to be classified is acquired, and the text to be classified is defined as question information.

[0080] In operation S430, the text information and the question information are respectively input as text input and question input into a classification model to obtain a classification result for the text to be classified.

[0081] It should be noted that the classification model used in the embodiments of the present disclosure may be a model obtained by the training method of the classification model described in any of the above embodiments of the present disclosure, and the specific training process will not be repeated here.

[0082] The text classification method provided in the embodiments of the present disclosure is an extractive text classification method based on a reading comprehension framework (Machine Reading Comprehension and Extraction-based Text Classification, MRCE-TC for short). The MRCE-TC method can be used to convert the traditional text multi-label classification problem into an extractive machine reading comprehension problem.

[0083] On the one hand, in the machine reading comprehension framework, the label sequence is explicitly input into the model as prior knowledge, which can optimize the model's multi-head attention mechanism and allow the model to focus on the key areas of the text, thereby more effectively alleviating the deviation problem between "abstract categories" and "real categories".

[0084] For example, in the existing text binary classification task, it can only be concluded that the current text belongs to the current classification label or does not belong to the current classification label, which may result in the inability to accurately determine the true category of the text. However, the embodiment of the present disclosure defines a label sequence composed of multiple classification labels as the context input of the model, and defines the text to be classified as the query input of the model, so that the classification label to which the text to be classified belongs can be extracted, thereby accurately determining the true category of the text, that is, the deviation problem between the "abstract category" and the "true category" can be more effectively alleviated.

[0085] On the other hand, based on the general machine reading comprehension framework, the disclosed embodiment can define a classification label as a label sequence alone, or define multiple classification labels as a label sequence. When multiple classification labels are defined in the label sequence, the extractive text classification task can be completed based on the machine reading comprehension framework. Therefore, the disclosed embodiment can solve the text multi-label classification task. Furthermore, the disclosed embodiment can extract only one classification label at a time, or can extract multiple classification labels at a time. Therefore, the disclosed embodiment can simultaneously solve the text multi-label single classification task and the text multi-label multi-classification task.

[0086] Among them, when multiple classification labels are predefined in the label sequence, for the application scenario of the text multi-label classification task, the MRCE-TC text classification method provided by the embodiment of the present disclosure can define the traditional text multi-label classification task as an extractive annotation task under the machine reading comprehension framework. In this way, while effectively alleviating the deviation problem between the "abstract category" and the "real category", the processing efficiency of the classification model under the text multi-label classification task can also be improved. This is because, in order to achieve the same classification effect as the embodiment of the present disclosure in the text multi-label classification task, the existing text classification model based on the machine reading comprehension framework will increase with the increase in the number of classification labels, so the classification efficiency of the model will also decrease. In contrast, because the parameter amount of the classification model obtained by training the embodiment of the present disclosure is constant, the text classification efficiency can be improved by using the classification model for text classification.

[0087] Exemplarily, data preprocessing may be performed before classification prediction. The data preprocessing here includes: defining the query and context of the model input. In the MRCE-TC algorithm, the string corresponding to the text to be classified is defined as the query input of the classification model, and the label sequence composed of predefined classification labels is defined as the context input of the classification model.

[0088] Among them, n classification labels can be predefined, such as label 1, label 2, ..., label n. And "#" can be used as a label separator to concatenate these classification labels to form a label sequence "label 1#label 2#......#label n" required by the classification model.

[0089] Then, the pre-processed query (text to be classified) and context (label sequence) are input into the classification model (such as the BERT model trained based on the above embodiment), and the corresponding answer is obtained through automatic feature learning and prediction calculation of the classification model. In the MRCE-TC algorithm, the answer output by the classification model refers to the annotation sequence output by the model for the label sequence (context). Based on the annotation sequence, the classification result of the above-mentioned text to be classified can be determined.

[0090] Through the embodiments of the present disclosure, the text classification problem is converted into a reading comprehension problem, and extractive text classification can be implemented, thereby more effectively alleviating the deviation problem between "abstract classification" and "real classification".

[0091] In addition, the disclosed embodiment, based on the machine reading comprehension framework, proposes an extractive text classification method for the text multi-label classification problem. Therefore, while the disclosed embodiment can effectively improve the text classification effect, it can also take into account different text classification tasks. For example, under the same classification model structure, it is possible to flexibly switch between text binary classification tasks, text multi-label single classification tasks, and text multi-label multi-classification tasks.

[0092] In addition, in order to achieve the same classification effect as the embodiment of the present disclosure in the text multi-label classification task, the existing text classification model based on the machine reading comprehension framework has to increase the number of model parameters as the number of classification labels increases, so the classification efficiency of the model will also decrease. In contrast, because the number of parameters of the adopted classification model is constant (the training method used to obtain the classification model determines that its parameter number is constant), the embodiment of the present disclosure can improve the efficiency of text classification.

[0093] It should be understood that in the MRCE-TC algorithm, the label sequence is also used as prior knowledge and input into the classification model in the form of context. Combined with the multi-head attention mechanism of the classification model such as the BERT model, the classification model can effectively focus on the text to be classified and related labels, thereby effectively alleviating the deviation problem between the "abstract category" and the "real category" predicted by the model.

[0094] It should also be understood that the text multi-label classification task is a key research direction of natural language processing and an important technical field for the implementation of natural language related products such as public opinion. The MRCE-TC algorithm proposed in the embodiment of the present disclosure efficiently combines the cutting-edge technology and is simple to apply.

[0095] As an optional embodiment, the text information defined by the label sequence and the question information defined by the text to be classified are respectively used as the text input and question input of the classification model, and input into the classification model to obtain the classification result for the text to be classified, which may include the following operations.

[0096] The text information defined by the label sequence and the question information defined by the text to be classified are respectively used as text input and question input, and input into the classification model to obtain a label sequence for the label sequence.

[0097] Based on the annotation sequence, a classification result for the text to be classified is determined.

[0098] In an embodiment of the present disclosure, in a marking sequence, one character (first character) can be used to mark the first character of the drawn classification label, another character (second character) can be used to mark non-first characters of the drawn classification label, and another character (third character) can be used to mark character strings and label separators corresponding to classification labels that are not drawn.

[0099] Exemplarily, the label sequence can be annotated using three characters: B (Begin), I (Inside), and O (Other) to obtain the corresponding label sequence. Among them, B indicates the starting character of the target segment (the first character of the extracted classification label), I indicates the non-starting character of the target segment (the non-first character of the extracted classification label), and O indicates the non-target segment (the character string and label separator corresponding to the classification label that is not extracted). Among them, the target segment includes the character strings corresponding to all the extracted classification labels in the label sequence.

[0100] In the embodiment of the present disclosure, based on the labeled sequence, the classification result predicted by the classification model can be automatically obtained. Figure 5 As shown in the figure, in the multi-label multi-classification task, the classification model gives the predicted classification labels "label 1" and "label 2" for the input string "news text to be classified" and "label 1#label 2#......#label n". In this case, the obtained annotation sequence should be "BIIOBIIO......OOO". From this annotation sequence, it can be parsed that the predicted classification for "news text to be classified" is the category corresponding to "label 1" and "label 2".

[0101] Through the embodiments of the present disclosure, the multi-label text classification task problem is converted into an extractive reading comprehension problem (extractive text classification problem), and a labeling sequence can be generated for the extractive target fragments, which can not only alleviate the deviation problem between "abstract classification" and "real classification" but also improve the classification efficiency.

[0102] Further, as an optional embodiment, determining a classification result for the text to be classified based on the annotation sequence may include the following operations.

[0103] Based on the labeled sequence, at least one classification label extracted from the label sequence is determined.

[0104] Based on the at least one classification label, a classification result of the text to be classified is determined.

[0105] For example, continuing to refer to the above example, if the label sequence input to the model is "label 1#label 2#......#label n", and the label sequence output after model prediction is "BIIOBIIO......OOO", then from this label sequence, it can be parsed that the predicted classification for the "news text to be classified" is the category corresponding to "label 1" and "label 2".

[0106] Alternatively, as an optional embodiment, the method further includes: in the marking sequence, marking the characters of the extracted classification labels with the first character; and marking the characters of the unextracted classification labels and the label separator with the second character.

[0107] For example, the first character may include X, and the second character may include O. Continuing to refer to the above example, in a multi-label multi-classification task, the classification model gives the predicted classification labels "label 1" and "label 2" for the input string "news text to be classified" and "label 1#label 2#......#label n". In this case, the obtained annotation sequence should be "XXXOXXXO......OOO". From this annotation sequence, it can be parsed that the predicted classification for "news text to be classified" is the category corresponding to "label 1" and "label 2".

[0108] According to an embodiment of the present disclosure, the present disclosure also provides a training device for a classification model.

[0109] Figure 6 A block diagram of a training device for a classification model according to an embodiment of the present disclosure is exemplarily shown.

[0110] like Figure 6 As shown, the classification model training device 600 includes: a first preprocessing module 610, a second preprocessing module 620 and a training module 630.

[0111] The first preprocessing module 610 is used to define a tag sequence as text information, wherein the tag sequence is composed of predefined classification tags.

[0112] The second preprocessing module 620 is used to obtain a first data set and define samples in the first data set as question information.

[0113] The training module 630 is used to train the preset model by using the text information and the question information as the text input and question input of the preset model respectively, so as to obtain the classification model.

[0114] As an optional embodiment, the device also includes: an acquisition module, used to obtain the label sequence through the following operations: obtaining at least one predefined classification label; arranging the at least one classification label into an initial sequence; and based on the initial sequence, inserting label spacers between two adjacent classification labels to obtain the label sequence.

[0115] As an optional embodiment, the preset model includes: a BERT model.

[0116] According to an embodiment of the present disclosure, the present disclosure also provides a classification device.

[0117] Figure 7 A block diagram of a classification device according to an embodiment of the present disclosure is exemplarily shown.

[0118] like Figure 7 As shown, the classification device 700 includes: a third preprocessing module 710, a fourth preprocessing module 720 and a classification module 730.

[0119] The third preprocessing module 710 is used to define a tag sequence as text information, wherein the tag sequence is composed of predefined classification tags.

[0120] The fourth preprocessing module 720 is used to obtain the text to be classified and define the text to be classified as question information.

[0121] The classification module 730 is used to input the text information and the question information as text input and question input respectively into a classification model to obtain a classification result for the text to be classified.

[0122] As an optional embodiment, the classification module includes: a classification unit, used to input the text information and the question information as text input and question input respectively, into a classification model to obtain a label sequence for the label sequence; and a determination unit, used to determine the classification result for the text to be classified based on the label sequence.

[0123] As an optional embodiment, the determination unit includes: a first determination subunit, used to determine at least one classification label extracted from the label sequence based on the annotation sequence; and a second determination subunit, used to determine the classification result of the text to be classified based on the at least one classification label.

[0124] As an optional embodiment, the classification module utilizes the classification model to label the characters of the extracted classification labels with the first character in the labeling sequence; and to label the characters of the unextracted classification labels and label separators with the second character.

[0125] It should be understood that in the embodiments of the present disclosure, the embodiments of the device part are the same or similar to the embodiments of the method part, and the technical effects and functions achieved are also the same or similar, which will not be repeated here.

[0126] According to an embodiment of the present disclosure, the present disclosure also provides an electronic device, a readable storage medium and a computer program product.

[0127] Figure 8 A schematic block diagram of an example electronic device 800 that can be used to implement an embodiment of the present disclosure is shown. The electronic device is intended to represent various forms of digital computers, such as laptop computers, desktop computers, workstations, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0128] like Figure 8 As shown, the electronic device 800 includes a computing unit 801, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 802 or a computer program loaded from a storage unit 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the electronic device 800 can also be stored. The computing unit 801, the ROM 802, and the RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0129] Multiple components in the electronic device 800 are connected to the I / O interface 805, including: an input unit 806, such as a keyboard, a mouse, etc.; an output unit 807, such as various types of displays, speakers, etc.; a storage unit 808, such as a disk, an optical disk, etc.; and a communication unit 809, such as a network card, a modem, a wireless communication transceiver, etc. The communication unit 809 allows the device 800 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks.

[0130] The computing unit 801 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 801 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 801 performs the various methods and processes described above, such as the training method and classification method of the classification model. For example, in some embodiments, the training method and classification method of the classification model may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 808. In some embodiments, part or all of the computer program may be loaded and / or installed on the device 800 via the ROM 802 and / or the communication unit 809. When the computer program is loaded into the RAM 803 and executed by the computing unit 801, one or more steps of the training method or classification method of the classification model described above may be performed. Alternatively, in other embodiments, the computing unit 801 may be configured to execute the training method and / or the classification method of the classification model in any other appropriate manner (for example, by means of firmware).

[0131] Various implementations of the systems and techniques described above herein can be implemented in digital electronic circuit systems, integrated circuit systems, field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chips (SOCs), load programmable logic devices (CPLDs), computer hardware, firmware, software, and / or combinations thereof. These various implementations can include: being implemented in one or more computer programs that can be executed and / or interpreted on a programmable system including at least one programmable processor, which can be a special purpose or general purpose programmable processor that can receive data and instructions from a storage system, at least one input device, and at least one output device, and transmit data and instructions to the storage system, the at least one input device, and the at least one output device.

[0132] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, enables the functions / operations specified in the flow chart and / or block diagram to be implemented. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0133] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0134] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0135] The systems and techniques described herein may be implemented in a computing system that includes back-end components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes front-end components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such back-end components, middleware components, or front-end components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0136] A computer system may include clients and servers. Clients and servers are generally remote from each other and usually interact through a communication network. The relationship of client and server is generated by computer programs running on respective computers and having a client-server relationship to each other.

[0137] It should be understood that the various forms of processes shown above can be used to reorder, add or delete steps. For example, the steps recorded in this disclosure can be executed in parallel, sequentially or in different orders, as long as the desired results of the technical solutions disclosed in this disclosure can be achieved, and this document does not limit this.

[0138] The above specific implementations do not constitute a limitation on the protection scope of the present disclosure. It should be understood by those skilled in the art that various modifications, combinations, sub-combinations and substitutions can be made according to design requirements and other factors. Any modification, equivalent substitution and improvement made within the spirit and principle of the present disclosure shall be included in the protection scope of the present disclosure.

Claims

1. A classification model training method, comprising: A label sequence is defined as text information, wherein the label sequence is composed of predefined classification labels; Acquire a first data set, and define samples in the first data set as question information; and Using the text information and the question information as the text input and the question input of the preset model respectively to train the preset model to obtain the classification model; The step of using the text information and the question information as the text input and the question input of the preset model respectively to train the preset model includes: The text information and the question information are respectively used as the text input and the question input, and input into the preset model to obtain a label sequence for the label sequence; Based on the annotation sequence, determining at least one classification label extracted from the label sequence; Determining the category corresponding to the at least one classification label as a classification result for the sample; and Training the preset model based on the classification result; The annotation sequence includes characters that correspond one-to-one to characters in the tag sequence to indicate whether tags in the tag sequence are extracted.

2. The method according to claim 1, wherein: The tag sequence is obtained by the following operation: Obtain at least one predefined classification label; Arranging the at least one classification label into an initial sequence; and Based on the initial sequence, label separators are inserted between two adjacent classification labels to obtain the label sequence.

3. The method according to claim 1, wherein: The preset model includes: a BERT model.

4. A text classification method, comprising: A label sequence is defined as text information, wherein the label sequence is composed of predefined classification labels; Acquire a text to be classified, and define the text to be classified as question information; and Inputting the text information and the question information into a classification model as a text input and a question input respectively, so as to obtain a classification result for the text to be classified; The text information and the question information are respectively used as text input and question input, and input into a classification model to obtain a classification result for the text to be classified, including: Inputting the text information and the question information as text input and question input, respectively, into a classification model to obtain a label sequence for the label sequence; and Based on the annotation sequence, determining a classification result for the text to be classified, wherein the annotation sequence includes characters corresponding one-to-one to characters in the tag sequence to indicate whether a tag in the tag sequence is extracted; Wherein, determining the classification result for the text to be classified based on the annotation sequence includes: Based on the annotation sequence, determining at least one classification label extracted from the label sequence; Determine that the category corresponding to the at least one classification label is a classification result of the text to be classified.

5. The method according to claim 4, further comprising: In the annotation sequence, Use the first character to mark the character of the extracted classification label; as well as The second character is used to mark the characters of the unextracted category labels and label separators.

6. A training device for a classification model, comprising: A first preprocessing module, used to define a label sequence as text information, wherein the label sequence is composed of predefined classification labels; A second preprocessing module is used to obtain a first data set and define samples in the first data set as question information; and A training module, used to train the preset model by using the text information and the question information as the text input and the question input of the preset model respectively, so as to obtain the classification model; The step of using the text information and the question information as the text input and the question input of the preset model respectively to train the preset model includes: The text information and the question information are respectively used as the text input and the question input, and input into the preset model to obtain a label sequence for the label sequence; Based on the annotation sequence, determining at least one classification label extracted from the label sequence; Determining the category corresponding to the at least one classification label as a classification result for the sample; and Training the preset model based on the classification result; The annotation sequence includes characters that correspond one-to-one to characters in the tag sequence to indicate whether tags in the tag sequence are extracted.

7. The apparatus according to claim 6, further comprising: The acquisition module is used to obtain the tag sequence through the following operations: Obtain at least one predefined classification label; Arranging the at least one classification label into an initial sequence; as well as Based on the initial sequence, label separators are inserted between two adjacent classification labels to obtain the label sequence.

8. The device according to claim 6, wherein: The preset model includes: a BERT model.

9. A text classification device, comprising: A third preprocessing module, configured to define a label sequence as text information, wherein the label sequence is composed of predefined classification labels; a fourth preprocessing module, configured to obtain text to be classified and define the text to be classified as question information; and A classification module, used to input the text information and the question information as text input and question input respectively into a classification model to obtain a classification result for the text to be classified; Wherein, the classification module includes: a classification unit, configured to input the text information and the question information as text input and question input, respectively, into a classification model to obtain a label sequence for the label sequence; and a determination unit, configured to determine a classification result for the text to be classified based on the annotation sequence, wherein the annotation sequence includes characters corresponding one-to-one to characters in the tag sequence to indicate whether a tag in the tag sequence is extracted; Wherein, the determining unit includes: A first determining subunit is configured to determine at least one classification label extracted from the label sequence based on the annotation sequence; and The second determining subunit is used to determine that the category corresponding to the at least one classification label is the classification result of the text to be classified.

10. The device according to claim 9, wherein: The classification module uses the classification model in the labeling sequence. Label the extracted classification label with the first character; and The second character is used to mark the characters of the unextracted category labels and label separators.

11. An electronic device, comprising: at least one processor; as well as a memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the method according to any one of claims 1 to 5.

12. A non-transitory computer-readable storage medium storing computer instructions, wherein: The computer instructions are used to cause the computer to execute the method according to any one of claims 1-5.

13. A computer program product, comprising a computer program, which, when executed by a processor, implements the method according to any one of claims 1 to 5.