Text classification method, device, and electronic device

By using multiple classification models and keyword matching methods in text classification, the inefficiency problem in the prior art is solved, and more efficient text classification accuracy and speed are achieved.

CN117874231BActive Publication Date: 2024-12-06HANVON CORP
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202311776352.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-21
Publication Date
2024-12-06
Estimated Expiration
2043-12-21

AI Technical Summary

Technical Problem

The existing text classification methods have problems such as slow running speed, high CPU resource usage and large amount of manual annotation, resulting in inefficiency.

Method used

At least one first classification model is used to classify the target text, match it with the preset keyword database, splice the classification results and keywords, and then process it through the second classification model to achieve multi-dimensional decision-making and improve classification accuracy. sex.

Benefits of technology

No need or only a small amount of manual annotation is required, which saves manpower and time, improves the training and reasoning speed of classification models, and improves classification accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117874231B_ABST
    Figure CN117874231B_ABST
Patent Text Reader

Abstract

The present application discloses a text classification method, device, and electronic device, and belongs to the field of computer technology. The method comprises: classifying the target text through at least one first classification model corresponding to different classification dimensions, and obtaining the classification results output by each first classification model; matching the target text with the keywords in the preset keyword library, and selecting the keywords matching the target text from the preset keyword library; splicing the classification results, keywords, and target text to obtain the spliced ​​text; classifying the spliced ​​text through the second classification model, and obtaining the classification results output by the second classification model as the classification results of the target text. The method combines the results of multiple classification models that are not directly related with keywords, realizes multi-dimensional decision-making in the classification model for target classification and prediction, improves the accuracy of a single classification model in classification tasks, and obtains more accurate text classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a text classification method, device, electronic device, and computer-readable storage medium. Background Art

[0002] With the continuous development of artificial intelligence technology, more and more generative models have been proposed. The emergence of large text generation models has brought new breakthroughs to the development of artificial intelligence. The existing large text generation models can accurately answer most of the user's questions based on the text or pictures entered by the user, have high use value, and bring new impetus to the development of various industries. In order to improve the accuracy of the content generated by the large text generation model, a pre-classification task is usually added to the large model. In the prior art. The text classification algorithms used in the pre-classification task are mainly divided into three categories: 1) text classification based on traditional machine learning methods; 2) text classification using deep learning algorithms; 3) text classification based on deep learning, word library construction and other combinations. Among them, the first and second text classification methods have at least the defects of slow running speed and high CPU resource occupation; the third text classification method requires manual labeling of model training data and matching rule design, which requires a lot of manpower and time and is inefficient.

[0003] It can be seen that the text classification method in the prior art still needs to be improved. Summary of the invention

[0004] The embodiments of the present application provide a text classification method, device, electronic device and storage medium, which can improve classification accuracy, and require no or only a small amount of manual labeling, saving labor labeling costs and time, and the classification model training efficiency is high, and the training and reasoning speeds are faster.

[0005] In a first aspect, an embodiment of the present application provides a text classification method, comprising:

[0006] Classify the target text using at least one first classification model to obtain a classification result output by each of the first classification models, wherein each of the first classification models corresponds to a different classification dimension;

[0007] Matching the target text with keywords in a preset keyword library, and selecting the keywords matching the target text from the preset keyword library;

[0008] splicing the classification result, the keyword and the target text to obtain a spliced ​​text;

[0009] The concatenated text is classified by a second classification model, and a classification result output by the second classification model is obtained as a classification result of the target text.

[0010] In a second aspect, an embodiment of the present application provides a text classification device, including:

[0011] A first classification module, configured to classify the target text using at least one first classification model, and obtain a classification result output by each of the first classification models, wherein each of the first classification models corresponds to a different classification dimension;

[0012] A keyword extraction module, used to match the target text with keywords in a preset keyword library, and select the keywords matching the target text from the preset keyword library;

[0013] A splicing module, used for splicing the classification result, the keyword and the target text to obtain a spliced ​​text;

[0014] The second classification module is used to classify the concatenated text through a second classification model, and obtain the classification result output by the second classification model as the classification result of the target text.

[0015] In a third aspect, an embodiment of the present application further discloses an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the text classification method described in the embodiment of the present application when executing the computer program.

[0016] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the text classification method disclosed in the embodiment of the present application are performed.

[0017] The text classification method disclosed in the embodiment of the present application classifies the target text through at least one first classification model to obtain the classification results output by each of the first classification models, wherein each of the first classification models corresponds to different classification dimensions; matches the target text with keywords in a preset keyword library, and selects the keywords matching the target text from the preset keyword library; concatenates the classification results, the keywords and the target text to obtain a concatenated text; classifies the concatenated text through a second classification model to obtain the classification results output by the second classification model as the classification result of the target text, combines the results of multiple classification models that are not directly related with keywords, implements multi-dimensional decision-making in the classification model for target classification and prediction, improves the accuracy of a single classification model in classification tasks, and obtains more accurate text classification.

[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0020] Figure 1 is a flow chart of the text classification method disclosed in the embodiment of the present application;

[0021] Figure 2 Schematic diagram of the classification model training method used in the embodiment of the present application;

[0022] Figure 3 It is a schematic diagram of a part of the process of establishing a keyword library disclosed in the embodiments of the present application;

[0023] Figure 4 is a schematic diagram of the structure of a text classification device disclosed in an embodiment of the present application;

[0024] Figure 5 A block diagram schematically shows an electronic device for executing the method according to the present application; and

[0025] Figure 6 A storage unit for holding or carrying a program code for implementing the method according to the present application is schematically shown. DETAILED DESCRIPTION

[0026] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0027] Reference Figure 1 , a text classification method disclosed in an embodiment of the present application includes: steps 110 to 140.

[0028] Step 110, classify the target text through at least one first classification model, and obtain the classification results output by each of the first classification models, wherein each of the first classification models corresponds to a different classification dimension.

[0029] In an embodiment of the present application, multiple classification models suitable for different classification dimensions can be pre-trained based on unlabeled samples, wherein the second classification model is a classification model corresponding to the final required classification result; the first classification model is used as an auxiliary classification model to pre-classify the target text, so as to facilitate the subsequent use of the classification result of the first classification model as the input of the second classification model, so as to provide the second classification model with richer input information.

[0030] Preferably, the first classification model is a plurality of different classification models, each of which is based on different model parameters and / or different classification algorithms, and performs classification processing on the target text based on different classification dimensions to determine the classification results of the target text in different classification dimensions. For example, each of the first classification models may include: a first classification model for sentiment classification of the target text, a first classification model for topic classification of the target text, a first classification model for industry classification of the target text, a first classification model for intent classification of the target text, a first classification model for source classification of the target text, etc. For another example, the first classification models may respectively adopt the following classification algorithms: textCNN, textRNN, BERT, transformer, etc.

[0031] Taking the second classification model as the pre-model of the generative large model, and taking the scenario of using the generative large model to generate answers to the consultation questions input by the user as an example, the second classification model needs to classify the text input by the user, so as to review whether the questions input by the user include sensitive information, whether they include non-compliant information that will mislead the generative large model to generate text that violates human cognition, administrative regulations, etc., based on the classification results. For example, the classification categories corresponding to the second classification model include at least: "political", "prohibited", "slander", "terror", "other", and "normal". For the question text input by the user, if it can be combined with the industry category, theme category, emotion category, source category, intention category, demand category and other information matched by the question text, it will help the second classification model input more accurate classification results. The above-mentioned industry category, theme category, emotion category and other information can be obtained by classifying the question text input by the user through the first classification model that is pre-trained to classify these categories.

[0032] The training methods of the first classification model and the second classification model are described below and will not be repeated here.

[0033] Step 120 , matching the target text with keywords in a preset keyword library, and selecting the keywords matching the target text from the preset keyword library.

[0034] In the embodiment of the present application, the second classification model input information also includes keywords extracted from the target text and / or related words of the vocabulary in the target text. The keywords are obtained by matching the target text with a preset keyword library.

[0035] Optionally, the target text is matched with keywords in a preset keyword library, and the keywords matching the target text are selected from the preset keyword library, including: performing word segmentation processing on the target text to obtain the vocabulary included in the target text; performing stop word removal processing and meaningless word removal processing on the vocabulary to obtain the vocabulary to be matched; and matching each of the vocabulary to be matched with the keywords in the preset keyword library to obtain the keywords matching the vocabulary to be matched. The keyword can be the same as the vocabulary to be matched, or it can be a keyword whose similarity with the vocabulary to be matched is greater than or equal to a preset similarity threshold, for example, a synonym of the vocabulary.

[0036] During specific implementation, other methods may also be used to match the target text with the keywords in a preset keyword library, and select the keywords that match the target text from the preset keyword library. In the embodiment of the present application, there is no limitation on the specific implementation method of matching the target text with the keywords in the preset keyword library and selecting the keywords that match the target text from the preset keyword library.

[0037] The method for establishing the preset keyword library is described below and will not be repeated here.

[0038] Step 130, concatenate the classification result, the keyword and the target text to obtain a concatenated text.

[0039] Next, the classification results of each first classification model for the target text, the keywords matched with the preset keyword library, and the target text are spliced ​​according to a preset format to obtain a spliced ​​text. For example, the classification results output by each first classification model and the keywords can be added to the target text to obtain a spliced ​​text.

[0040] In the embodiments of the present application, there is no limitation on the specific implementation method of splicing the classification results, the keywords and the target text to obtain the spliced ​​text.

[0041] Step 140, classify the concatenated text using a second classification model, and obtain a classification result output by the second classification model as a classification result of the target text.

[0042] The second classification model is the final target classification model. Based on keyword information, multi-dimensional classification information of the target text, and the target text information itself, a more accurate target classification result can be obtained.

[0043] Below, in combination with specific application scenarios, the specific implementation process of the text review method disclosed in the embodiment of the present application is illustrated by examples.

[0044] Take the classification target of text review classification as an example, that is, the second classification model is a classification model used for text review classification. It is assumed that the classification categories of the second classification model include at least: "political", "prohibited", "slander", "terrorist", "other", and "normal". It is assumed that the first classification model includes at least: a first classification model for classification based on the emotional dimension (for example, recorded as "Model1"), a first classification model for classification based on the industry dimension (for example, recorded as "Model2"), a first classification model for classification based on the demand dimension (for example, recorded as "Model3"), a first classification model for classification based on the source dimension (for example, recorded as "Model4"), a first classification model for classification based on the subject dimension (for example, recorded as "Model5"), and a first classification model for classification based on the intention dimension (for example, recorded as "Model6"). Assume that the classification categories corresponding to each first classification model include at least: the classification categories corresponding to the first classification model Model1 include at least: "optimism", "indifference", "pessimism", "anger", "fear", etc.; the classification categories corresponding to the first classification model Model2 include at least: "law", "medical care", "travel", "catering", "entertainment", etc.; the classification categories corresponding to the first classification model Model3 include at least: "security needs", "economic needs", "life needs", etc.; the classification categories corresponding to the first classification model Model4 include at least: "individual", "organization", etc.; the classification categories corresponding to the first classification model Model5 include at least: "society", "politics", etc.; the classification categories corresponding to the first classification model Model6 include at least: "seek help", "state events", etc.

[0045] In the application process, suppose the target text input by the user is: "We have a bad relationship and always quarrel. We want to divorce. The main reason is that my husband's company often defaults on wages. Family life is difficult. What should I do?" After the above first classification model classifies the target text, the following classification results can be obtained: the emotion category is "pessimism", the industry category is "law", the demand category is "security demand", the source category is "personal", the theme category is "society", and the intention category is "seeking help". Further, after the above target text is matched with the preset keyword library, the keywords obtained can be the keyword group: "company + default on wages".

[0046] Accordingly, by splicing the classification result, the keywords and the target text, a spliced ​​text may be obtained: "Pessimism, legal security needs, personal society, seeking help, company + wage arrears. We have a bad relationship and always quarrel. We want to divorce, mainly because my husband's company often defaults on wages and our family life is difficult. What should I do?"

[0047] Afterwards, the obtained concatenated text is used as the input of the second classification model, and the classification result output by the second classification model is: "normal".

[0048] In another example, suppose the target text entered by the user is: "How can I download pirated movies?" After the first classification model classifies the target text, the following classification results can be obtained: the emotion category is "ordinary", the industry category is "entertainment", the demand category is "life needs", the source category is "individual", the theme category is "society", and the intention category is "seeking help". Furthermore, after matching the target text with the preset keyword library, the keywords obtained can be the keyword group: "download + pirated movie"

[0049] Correspondingly, the classification result, the keywords and the target text are spliced ​​together to obtain a spliced ​​text: "Ordinary entertainment life needs personal society seeking help downloading + pirated movies how can I download pirated movies?".

[0050] Afterwards, the obtained concatenated text is used as the input of the second classification model, and the classification result output by the second classification model is: "prohibited".

[0051] At this point, the classification operation of the target text is completed.

[0052] In the embodiment of the present application, the execution order of step 110 and step 120 can be exchanged.

[0053] The following describes in detail the training methods of the first classification model, the second classification model, and the method of establishing the preset keyword library.

[0054] 1. Classification model training method

[0055] Similar to human brain cells, there are cell death and cell regeneration at every moment, and nerve cells do not participate in activities at the same time, but the results of all cells participating in the movement are basically not much different from the results of some cells participating in the movement. There is not much difference between all parameters of a trained model participating in the calculation and some parameters participating in the calculation. Based on this, an unsupervised classification model training method is proposed in the embodiment of the present application.

[0056] First, build a deep learning model and modify the model structure to output two results. One result is set to y, which is calculated by all parameters; the other result is set to x, which is calculated by setting some parameters. The fluctuation ranges of the two results may be inconsistent. The two results need to be normalized to get y0 and x0 respectively. The result y0 calculated by all parameters is used as the standard result label, and the difference between y0 and x0 is calculated as the loss value. According to the loss value, some parameters corresponding to the result x are updated to complete a model training.

[0057] Optionally, the first classification model and the second classification model are trained respectively by the following methods: obtaining unlabeled training data and setting classification labels corresponding to the classification dimensions of the target classification model, the target classification model including: the first classification model or the second classification model; based on the unlabeled training data, performing a training operation of the training model corresponding to the target classification model, wherein the target classification model is configured to: randomly inactivate some parameters with a set probability in the training mode, the training operation including: calculating a loss value based on a first output calculated with the participation of some parameters and a second output calculated with the participation of all parameters, updating the some parameters based on the loss value, and iteratively optimizing the training model until the training end condition is met.

[0058] Since training a classification model requires a large amount of data, if supervised training is used, sample labeling costs are high and time-consuming. Therefore, in the embodiment of the present application, an unsupervised training method is used to train the classification model.

[0059] Among them, the unlabeled training data used to train the first classification model and the second classification model can come from various text data, and the source of the type is not limited. Books, dialogues, comments, scripts, etc. can all be used as training data sets. According to the needs of specific classification tasks, it is necessary to identify as many text categories as possible in classification, so the more types of data in the training set, the better. Taking the classification model required for training text review tasks as an example, more text data that may need to be filtered can be collected.

[0060] On the other hand, the construction of training data needs to be processed according to the classification model input. For example, when the classification model uses the TextCNN model and the longest token is set to 128, it is necessary to segment the collected texts according to the maximum input text length of the model to obtain short texts whose length is not greater than the maximum allowed input length of the model (such as 128). The short text collection is used as the training data actually used by the model.

[0061] Before model training, you also need to configure the number of categories of the classification model. The number of categories needs to be set manually, that is, the final required classification labels. Since the classification model does not optimize the number of classification categories, it is necessary to set the appropriate number of classification categories in advance according to the source of the collected data, the general type, and the classification model requirements. For example, the text review category labels should include at least: "political", "prohibited", "swearing", "terror", "other", "normal"; the emotional category labels should include at least: "optimistic", "bland", "pessimistic", "angry", "fear", etc.

[0062] In order to verify the performance of the unsupervised training classification model, a test data set needs to be established. The test data set can be obtained by manually annotating a small number of training samples in the training data set. For unsupervised training without actual annotations, depending on the different initial parameters, the classification type of the training results may be inconsistent with the required type. For example, a movie review should belong to the emotion category but is predicted to be a text review category. By annotating the test data set according to the actual classification requirements, the appropriate classification model can be selected based on the classification effect of the classification model on the test data set.

[0063] The classification model in the embodiment of the present application is obtained by modifying the existing classification algorithm model. For example, the first classification model and the second classification model can use but are not limited to: TextCNN, TextRNN, BERT, Transformer and other deep learning algorithms as basic models. For the selected basic model, modifications are made on the basic model to obtain the training models of the first classification model and the second classification model.

[0064] First, add a random deactivation function when initializing the training model; second, add a random deactivation operation to the parameters of each hidden layer in the forward propagation function of the training model as the second hidden layer of the layer; then, normalize the final output results of the original hidden layer and the second hidden layer, and obtain two classification results in the same interval as the final output; finally, calculate the loss value of the two classification results. And transfer the classification error in reverse according to the loss value, optimize the parameters of the second hidden layer based on the loss value, and iteratively train the training model. Among them, the training end condition can be a certain number of iterative training times, or, during the last specified number of iterative training, the loss value does not decrease significantly, or the loss value of the model converges to a specified range, etc.

[0065] Taking TextCNN as the classification model framework as an example, TextCNN is a classic convolutional neural network model that uses multiple convolution kernels to perform convolution operations on the input text, and extracts text features and performs classification through pooling layers and fully connected layers.

[0066] First, add a Dropout layer after the hidden layer of the TextCNN classification model framework to achieve random dropout. The Dropout layer will dropout some nodes with a specified probability and perform corresponding parameter updates during back propagation. Add the random dropout function self.dropout = nn.Dropout(p) in the initialization function of the classification model, and configure the classification model to randomly dropout some nodes of the hidden layer with probability p, so that only some parameters in the hidden layer participate in feature calculation. The value of p is determined according to the training requirements and training results. For example, the value of p can be set to 0.7.

[0067] Secondly, after the convolutional layer operation, we get the result out. By adding out1 = self.dropout(out), we perform a random dropout operation on the parameters of the output result calculated based on out to get out1.

[0068] Finally, the out and out1 output by the convolution layer are pooled, and the feature mapping and other operations of the fully connected layer are performed, and the classification results out and out1 are finally output, and then normalized by the fully connected layer, for example: out = self.Softmax (out), out1 = self.Softmax (out1), out and out1 are the classification results finally output by the classification model. The loss function of the classification model is configured to calculate the cross entropy loss based on the final output classification results out and out1.

[0069] Combine the following Figure 2 Explain the model training process.

[0070] Optionally, the loss value is calculated based on the first output obtained by calculating part of the parameters and the second output obtained by calculating all the parameters, including: obtaining the second output of the target convolution layer of the training model when all the parameters are involved in the calculation, and the first output when part of the parameters of the target convolution layer are involved in the calculation; calculating the classification loss value based on the first output and the second output; updating the part of the parameters involved in calculating the first output with the goal of optimizing the classification loss value, and iteratively performing the training operation on the training model until a preset training end condition is reached; obtaining a first classification model to be verified based on the training model; using a test set corresponding to the classification dimension to test the classification accuracy of the first classification model to be verified; in response to the classification accuracy satisfying the preset accuracy condition, using the first classification model to be verified as the first classification model that has completed training; in response to the classification accuracy not satisfying the preset accuracy condition, repeating the training operation on the training model.

[0071] During the training process, the unlabeled training data is first input into the training model, and the training model classifies and calculates the input data in two cases: random inactivation of some parameters and all parameters participating in the calculation, respectively, to obtain the first output when some parameters participate in the calculation, and the second output when all parameters participate in the calculation, and normalizes the first output and the second output respectively, and maps the two outputs to the same interval. Taking TextCNN as the model framework of the training model as an example, in a model training process, the training samples are vectorized and input into the TextCNN model (i.e., the training model) for forward propagation, where the normalized result obtained by all model parameters participating in the calculation is recorded as out, and the normalized result obtained by some model parameters participating in the calculation is recorded as out1.

[0072] Then, the classification loss value is calculated according to the first output and the second output. For example, the loss value is calculated by a loss function, such as using the formula loss = F.cross_entropy(out1, out), taking the normalized result obtained by the calculation of all model parameters as the reference classification label, and obtaining the loss value loss of the output result out1 when some parameters are involved in the calculation.

[0073] Finally, if it is determined that iterative training is still needed (such as the number of iterations has not been reached), backpropagation loss.backward() is performed to update some parameters involved in calculating the output out1, completing a model training.

[0074] In unlabeled supervised training, the classification type of the training result may be inconsistent with the required type due to the influence of different initial parameters of the model, so multiple trainings are required to obtain a suitable training model. For example, you can perform several rounds of iterative training, and after a specified number of consecutive rounds (such as 100 rounds), if the loss value does not decrease significantly, you can end the training. Furthermore, the training model obtained based on the training is migrated and deployed to obtain the first classification model or the second classification model.

[0075] In some optional embodiments, a test data set can be used to test and verify the training model obtained by training to determine whether the training model obtained by training meets the target classification requirements. Taking the target classification requirement as a text review requirement as an example, the training model obtained in multiple rounds of iterative training can be tested and trained using a test data set with text review category annotations to obtain test results (such as confusion matrix or F1-score (an indicator used in statistics to measure the accuracy of a binary classification model)). After that, a training model that meets the text review requirements is selected based on the test results, and migration is performed based on the selected training model to build a second classification model.

[0076] If the training model obtained by iterative training cannot meet the text review requirements, it is necessary to reinitialize the parameters, re-execute the training operation, and iteratively train the training model.

[0077] Similarly, taking the first classification model that needs to be trained for sentiment classification as an example, the training model obtained in multiple rounds of iterative training can be tested using a test data set with sentiment category annotations to obtain test results. Afterwards, a training model that meets the sentiment classification requirements is selected based on the test results, and migration is performed based on the selected training model to construct the first classification model for sentiment classification.

[0078] When it is necessary to train classification models of other dimensions, such as training industry classification, intent classification, topic classification, source classification and other classification models, it is necessary to use the corresponding test data set to test the classification results, and select the corresponding training model based on the test results to build the first classification model suitable for the target scenario.

[0079] In some optional embodiments, the collected data set can be preprocessed accordingly and then labeled with classification labels of different classification dimensions, so as to obtain a test data set for the first classification model with respect to different classification dimensions.

[0080] The method of training other classification models is similar to the method of training the first classification model and the second classification model mentioned above, and will not be repeated here.

[0081] In some optional embodiments, before executing the training operation of the training model corresponding to the target classification model based on the unlabeled training data, it also includes: using labeled training data corresponding to the classification dimension to train the initial parameters of the training model, wherein the amount of the labeled training data is less than the unlabeled training data. For example, when training a first classification model whose classification dimension is the emotion category, a small amount of labeled training data labeled with emotion category labels can be first used to train the training model of the first classification model, thereby obtaining the initial parameters of the training model, so that the subsequent steps can use the unlabeled training data to perform parameter optimization based on the initial parameters. For another example, when training a second classification model whose classification dimension is the text review category, a small amount of labeled training data labeled with text review category labels can be first used to train the training model of the second classification model, thereby obtaining the initial parameters of the training model, so that the subsequent steps can use the unlabeled training data to perform parameter optimization based on the initial parameters.

[0082] By pre-training the training model with a small amount of labeled data to obtain the initial parameters of the training model, and then further training the training model with a large amount of unlabeled data based on the initial parameters, the training time of the training model can be shortened. In addition, by training the training model with a small amount of labeled data corresponding to a specified classification dimension, the initial parameters obtained can guide the training direction of the model, thereby making it easier to obtain a training model suitable for the classification dimension.

[0083] 2. Establishing a database

[0084] Optionally, the preset keyword library disclosed in the embodiment of the present application is established by the following method: performing vocabulary masking processing on each original text in the preset data set to obtain a masked text, and comparing the classification result of the original text with the classification result of the masked text to obtain the target vocabulary combination in the original text; according to the target vocabulary combination and the corresponding classification result of the original text, performing the operations of adding and deleting keywords on the preset keyword library to construct the keyword library.

[0085] Reference Figure 3 In some optional embodiments, vocabulary masking is performed on each original text in a preset data set to obtain a masked text, and the classification result of the original text is compared with the classification result of the masked text to obtain the target vocabulary combination in the original text, including: steps 310 to 370.

[0086] The specific implementation methods of each step are introduced below.

[0087] Step 310, classifying each original text in the preset data set by using the second classification model to obtain a classification result for each original text;

[0088] Step 320, performing word segmentation processing on each of the original texts, and obtaining candidate keywords based on the words obtained by the word segmentation processing;

[0089] Step 330, according to the classification result of the original text, setting the category label of the candidate keyword obtained according to the corresponding original text;

[0090] Step 340, obtaining preset attribute information of the candidate keyword according to the category label of the candidate keyword;

[0091] Step 350, for each of the original texts, performing a combination masking process on the words in the original text to obtain a masked text of the original text, wherein each of the masked texts corresponds to a word combination for which the masking process is performed on the original text;

[0092] Step 360, classifying the masked text to obtain a classification result corresponding to each masked text;

[0093] Step 370: For each of the original texts, a target vocabulary combination for masking processing is obtained according to the classification result of the original text and the classification results of each mask text of the original text.

[0094] In the aforementioned step 310, the data set may adopt the unlabeled training data used to train the first classification model and the second classification model in the previous text. It may also be another data set constructed by referring to the method for constructing the unlabeled training data in the previous text. The data set includes several texts. In the embodiment of the present application, the text in the data set is recorded as "original text".

[0095] First, a second classification model is used to classify each original text in the data set to obtain a classification result for each original text.

[0096] In the aforementioned step 320, a word segmentation tool in the prior art (such as the jieba word segmentation tool) may be used to perform word segmentation processing on each original text to obtain the words included in each original text.

[0097] Afterwards, in step 330, the classification result of each original text is used as the classification result of the vocabulary obtained by word segmentation from the original text, and a classification category label is set for each vocabulary. Each vocabulary with a classification category label is then used as a candidate keyword and added to the candidate keyword library.

[0098] Furthermore, in step 340, attribute information of each candidate keyword is set according to the distribution information of each word in the original text in the data set. The attribute information includes, but is not limited to, one or more of the following information: the number of categories of distribution, the number of times it appears in the first specified category, the TF-IDF value in the first specified category, the number of times it appears in categories other than the first specified category, the TF-IDF value in categories other than the first specified category, the average TF-IDF value in all categories, the number of categories identified as keywords, the number of times it is identified as keywords in the second specified category, etc.

[0099] Taking the classification model adopted as the second classification model as an example, assuming that the classification dimension of the second classification model is the text review category, the specific classification categories include at least: "political", "prohibited", "slander", "terrorist", "other", and "normal", among which the first designated category can be "prohibited" and the second designated category can be other categories under the text review category. Further, by counting the classification category labels of a certain word, it can be obtained that the word is classified into several categories, the number of times the word appears in the "prohibited" category, the TF value of the word in the "prohibited" category, the IDF value of the word in the "prohibited" category, the TF-IDF value of the word in the "prohibited" category, the number of times the word appears in other categories, the TF value of the word in other categories, the IDF value of the word in other categories, the TF-IDF value of the word in other categories, the average TF-IDF value of the word in all categories, the word is recognized as a keyword by the model in several categories, and the number of times the word is recognized as a keyword by the model, etc. The calculation method of the above-mentioned attribute information can refer to the prior art and will not be repeated in the embodiments of the present application.

[0100] In step 350, the words in each original text are masked according to possible word combinations to obtain one or more masked texts for each original text. That is, for each original text, one or more words in the original text are hidden to obtain a new text as the masked text of the original text. The words in the original text may be the words obtained by performing word segmentation on the original text in step 320.

[0101] Optionally, performing combined masking processing on the words in the original text to obtain a masked text of the original text includes: obtaining a mask score of each word in the original text according to preset attribute information of the candidate keywords; selecting a preset number of words according to the size of the mask score as mask words corresponding to the original text; combining the mask words to obtain masked word combinations; performing masking processing on the original text according to the word combinations to obtain masked texts corresponding to each word combination. The preset number is set as required.

[0102] Optionally, according to the preset attribute information of the candidate keyword, the mask score of each word in the original text is obtained, including: according to the number of classification categories in which the candidate keyword appears and the TF-IDF value in different classification categories, the mask score of each word in the original text is calculated. For example, the mask score of a certain word is calculated according to the following formula:

[0103] scare = tf-idf_cur * c_num1 / c_num2 / tf-idf_avg;

[0104] Among them, tf-idf_cur represents the TF-IDF value of the current word in the current classification category, c_num1 represents the number of times the current word appears in the current classification category, c_num2 represents the number of classification categories in which the current word appears, and tf-idf_avg represents the average TF-IDF value of the current word in all classification categories.

[0105] Optionally, the TF-IDF value of a certain vocabulary combination in the current original file and the dataset may be directly used as the mask score of the vocabulary combination.

[0106] In some other optional embodiments, other formulas may be used to obtain the mask score of each word in the original text according to the preset attribute information of the candidate keyword, which will not be listed here one by one.

[0107] Afterwards, the candidate keywords are sorted from front to back in the order of the mask scores from large to small, and a limited number of vocabulary groups ranked in front are selected as mask vocabulary. Then, for the original text, the mask vocabulary in the original text is combined to obtain all possible vocabulary combinations, and the original text is masked by hiding one vocabulary combination in the original text each time, so as to obtain a mask text corresponding to each hidden vocabulary combination.

[0108] Next, the original text is masked according to each determined vocabulary combination to obtain a masked text corresponding to each vocabulary combination, i.e., a masked text. The masking process includes but is not limited to any of the following methods: replacing a vocabulary combination with a preset symbol, randomly selecting similar words to replace a vocabulary combination, or deleting a vocabulary combination.

[0109] Next, for each of the original texts, each masked text of the original text is classified by the second classification model to obtain a classification result corresponding to each masked text.

[0110] Then, for each of the original texts, by comparing the classification results of the original text, the differences in the classification results of the masked texts of the original text and the scores of the classification results, the masked vocabulary that has a greater impact on the classification results of the original text is determined as the target vocabulary combination.

[0111] Optionally, according to the classification result of the original text and the classification results of each masked text of the original text, a target vocabulary combination for masking is obtained, including: for each masked text, when the classification result of the masked text and the classification result of the original text both meet the preset accuracy threshold, and the classification result of the masked text is different from the classification result of the original text, the vocabulary combination corresponding to the masked text is used as the target vocabulary combination. That is, by comparing the classification results of the original text and the text after masking, if the classification results before and after masking change, and the scores of both classification results are high, it means that the vocabulary combination processed by masking may be an important component in the original text, and the vocabulary combination is processed as a keyword. If the classification results before and after masking do not change significantly, or the scores of one or some classification results are low, it means that the vocabulary combination processed by masking is not an important component in the original text, and the vocabulary combination is abandoned as a keyword.

[0112] According to the above method, a word combination that can be used as a keyword, ie, a target word combination, can be determined based on each original text in the data set.

[0113] Next, it is further determined whether to add the target vocabulary combination to the keyword library.

[0114] Optionally, according to the classification results of the target vocabulary combination and the corresponding original text, the operations of adding and deleting keywords are performed on a preset keyword library to construct the keyword library, including: taking the classification result of the original text as the classification result of the target vocabulary combination, comparing the target vocabulary combination with existing vocabulary in a pre-established keyword library to obtain a comparison result; in response to the comparison result indicating that the target vocabulary combination does not appear in the existing vocabulary, setting a category label of the target vocabulary combination according to the classification result of the original text, and adding the target vocabulary combination to the keyword library; in response to the comparison result indicating that the target vocabulary combination appears in the existing vocabulary, and the category label of the target vocabulary combination in the existing vocabulary does not match the classification result of the original text, marking the target vocabulary combination in the keyword library for deletion.

[0115] When establishing a keyword library, an empty keyword library may be established first, and then keywords may be gradually added to the keyword library.

[0116] For example, each target vocabulary combination is matched with a keyword in a pre-built keyword library. If the target vocabulary combination is not matched in the keyword library (e.g., there is no keyword in the keyword library, or there is no vocabulary that is the same as the target vocabulary combination), the target vocabulary combination is used as a keyword, and the classification category label of the keyword is set to the classification category label of the original text corresponding to the target vocabulary combination. After that, the keyword with the classification category label is added to the keyword library. If there is no keyword with the same function as the target vocabulary combination in the keyword library, it is further determined whether the classification category label of the keyword that matches the target vocabulary combination in the keyword library is the same as the classification category label of the target vocabulary combination (i.e., whether it is the same as the classification category label of the original text corresponding to the target vocabulary combination). If they are the same, there is no need to add them repeatedly. If they are different, it means that the target vocabulary combination is identified as a different classification category and the classification confidence is low. Then, the keyword is marked for deletion to avoid adding the same vocabulary combination as the keyword to the keyword library again in the subsequent vocabulary matching process.

[0117] According to this method, the target vocabulary combination corresponding to each original text is processed in turn, and the operation of adding and deleting keywords in the keyword library is completed. Finally, a keyword library composed of keywords with higher classification confidence is obtained.

[0118] The keyword library establishment method disclosed in the present application successfully solves the problem that keyword extraction requires industry professionals to construct keyword tables for various industries by introducing text classification and vocabulary masking and then comparing classification results. It lowers the demand threshold for word table construction, improves the efficiency of keyword library construction, and improves the performance and application value of classification tasks based on keywords.

[0119] The text classification method disclosed in the embodiment of the present application classifies the target text through at least one first classification model to obtain the classification results output by each of the first classification models, wherein each of the first classification models corresponds to different classification dimensions; matches the target text with keywords in a preset keyword library, and selects the keywords matching the target text from the preset keyword library; concatenates the classification results, the keywords and the target text to obtain a concatenated text; classifies the concatenated text through a second classification model to obtain the classification results output by the second classification model as the classification result of the target text, combines the results of multiple classification models that are not directly related with keywords, implements multi-dimensional decision-making in the classification model for target classification and prediction, improves the accuracy of a single classification model in classification tasks, and obtains more accurate text classification.

[0120] Furthermore, in an embodiment of the present application, the loss value is calculated by calculating the result of inactivating some parameters and the result of all parameters, so as to perform model training on unlabeled data and obtain a target classification model, thereby reducing the workload and time of labeling classification model training samples, saving sample labeling costs and time, shortening the model training cycle, and the classification model after the test data set selection has a higher classification accuracy.

[0121] The present application also discloses a text classification device. Figure 4 As shown, the device comprises:

[0122] A first classification module 410 is used to classify the target text through at least one first classification model, and obtain the classification result output by each of the first classification models, wherein each of the first classification models corresponds to a different classification dimension;

[0123] A keyword extraction module 420 is used to match the target text with keywords in a preset keyword library, and select the keywords matching the target text from the preset keyword library;

[0124] A splicing module 430 is used to splice the classification result, the keyword and the target text to obtain a spliced ​​text;

[0125] The second classification module 440 is used to classify the concatenated text using a second classification model, and obtain the classification result output by the second classification model as the classification result of the target text.

[0126] Optionally, the first classification model and the second classification model are trained respectively by the following methods:

[0127] Obtain unlabeled training data, and set classification labels corresponding to classification dimensions of a target classification model, wherein the target classification model includes: the first classification model or the second classification model;

[0128] Based on the unlabeled training data, a training operation of the training model corresponding to the target classification model is performed, wherein the target classification model is configured to: randomly inactivate some parameters with a set probability in the training mode, and the training operation includes: calculating a loss value according to a first output calculated based on some parameters and a second output calculated based on all parameters, updating the some parameters according to the loss value, and iteratively optimizing the training model until a training end condition is met.

[0129] Optionally, the preset keyword library is established by the following method:

[0130] Performing vocabulary masking on each original text in the preset data set to obtain a masked text, and comparing the classification result of the original text with the classification result of the masked text to obtain the target vocabulary combination in the original text;

[0131] According to the target vocabulary combination and the corresponding classification result of the original text, operations of adding keywords and deleting keywords are performed on the preset keyword library to construct the keyword library.

[0132] Optionally, performing vocabulary masking on each original text in the preset data set to obtain a masked text, and comparing the classification result of the original text with the classification result of the masked text to obtain the target vocabulary combination in the original text, including:

[0133] Using the second classification model, each original text in the preset data set is classified and processed to obtain a classification result for each original text;

[0134] Performing word segmentation processing on each of the original texts, and obtaining candidate keywords based on the words obtained by the word segmentation processing;

[0135] According to the classification result of the original text, setting the category label of the candidate keyword obtained according to the corresponding original text;

[0136] Acquiring preset attribute information of the candidate keyword according to the category label of the candidate keyword;

[0137] For each of the original texts, performing a combination masking process on the words in the original text to obtain a masked text of the original text, wherein each of the masked texts corresponds to a word combination for which the masking process is performed on the original text;

[0138] Classify the masked text to obtain a classification result corresponding to each masked text;

[0139] For each of the original texts, a target vocabulary combination for masking processing is obtained according to the classification result of the original text and the classification results of each of the mask texts of the original text.

[0140] Optionally, the step of acquiring a target vocabulary combination for masking processing according to the classification result of the original text and the classification results of each mask text of the original text includes:

[0141] For each of the masked texts, when the classification results of the masked text and the classification results of the original text both meet a preset accuracy threshold, and the classification results of the masked text and the classification results of the original text are different, the vocabulary combination corresponding to the masked text is used as the target vocabulary combination.

[0142] Optionally, performing combined masking processing on the words in the original text to obtain a masked text of the original text includes:

[0143] According to the preset attribute information of the candidate keywords, a mask score of each of the words in the original text is obtained;

[0144] Selecting a preset number of the words according to the size of the mask score as mask words corresponding to the original text;

[0145] Combining the masked words to obtain a masked word combination;

[0146] According to the vocabulary combinations, the original text is masked to obtain masked text corresponding to each vocabulary combination.

[0147] Optionally, the adding and deleting of keywords from a preset keyword library according to the target vocabulary combination and the corresponding classification result of the original text to construct the keyword library includes:

[0148] Using the classification result of the original text as the classification result of the target vocabulary combination, the target vocabulary combination is compared with existing vocabulary in a pre-established keyword library to obtain a comparison result;

[0149] In response to the comparison result indicating that the target vocabulary combination does not appear in the existing vocabulary, setting a category label for the target vocabulary combination according to the classification result of the original text, and adding the target vocabulary combination to the keyword library;

[0150] In response to the comparison result indicating that the target vocabulary combination appears in the existing vocabulary and the category label of the target vocabulary combination in the existing vocabulary does not match the classification result of the original text, the target vocabulary combination in the keyword library is marked for deletion.

[0151] The text classification device disclosed in the embodiment of the present application is used to implement the text classification method described in the embodiment of the present application. The specific implementation methods of each module of the device will not be repeated here. Please refer to the specific implementation methods of the corresponding steps in the method embodiment.

[0152] The text classification device disclosed in the embodiment of the present application classifies the target text through at least one first classification model to obtain the classification results output by each of the first classification models, wherein each of the first classification models corresponds to different classification dimensions; matches the target text with keywords in a preset keyword library, and selects the keywords matching the target text from the preset keyword library; concatenates the classification results, the keywords and the target text to obtain a concatenated text; classifies the concatenated text through a second classification model to obtain the classification results output by the second classification model as the classification result of the target text, combines the results of multiple classification models that are not directly related with keywords, implements multi-dimensional decision-making in the classification model for target classification and prediction, improves the accuracy of a single classification model in classification tasks, and obtains more accurate text classification.

[0153] Furthermore, in an embodiment of the present application, the loss value is calculated by calculating the result of inactivating some parameters and the result of all parameters, so as to perform model training on unlabeled data and obtain a target classification model, thereby reducing the workload and time of labeling classification model training samples, saving sample labeling costs and time, shortening the model training cycle, and the classification model after the test data set selection has a higher classification accuracy.

[0154] Each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0155] The above is a detailed introduction to a text classification method and device provided by the present application. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method of the present application and its core idea. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

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

[0157] The various component embodiments of the present application may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It should be understood by those skilled in the art that a microprocessor or a digital signal processor (DSP) may be used in practice to implement some or all functions of some or all components in an electronic device according to an embodiment of the present application. The present application may also be implemented as a device or apparatus program (e.g., a computer program and a computer program product) for executing part or all of the methods described herein. Such a program implementing the present application may be stored on a computer-readable medium, or may be in the form of one or more signals. Such a signal may be downloaded from an Internet website, or provided on a carrier signal, or provided in any other form.

[0158] For example, Figure 5An electronic device that can implement the method according to the present application is shown. The electronic device can be a PC, a mobile terminal, a personal digital assistant, a tablet computer, etc. The electronic device traditionally includes a processor 510 and a memory 520 and a program code 530 stored on the memory 520 and can be run on the processor 510. When the processor 510 executes the program code 530, the method described in the above embodiment is implemented. The memory 520 can be a computer program product or a computer-readable medium. The memory 520 can be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk or a ROM. The memory 520 has a storage space 5201 for the program code 530 of a computer program for executing any method step in the above method. For example, the storage space 5201 for the program code 530 can include various computer programs for implementing various steps in the above method respectively. The program code 530 is a computer-readable code. These computer programs can be read from or written into one or more computer program products. These computer program products include program code carriers such as hard disks, compact disks (CDs), memory cards or floppy disks. The computer program includes a computer readable code, and when the computer readable code is executed on an electronic device, the electronic device is caused to execute the method according to the above embodiment.

[0159] The embodiment of the present application also discloses a computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, the steps of the text classification method described in the embodiment of the present application are implemented.

[0160] Such a computer program product may be a computer-readable storage medium, which may have a computer-readable storage medium having a Figure 5 The memory 520 in the electronic device shown in the figure is similar to the storage segment, storage space, etc. The program code can be compressed and stored in the computer-readable storage medium in an appropriate form. The computer-readable storage medium is generally as shown in the reference Figure 6 The portable or fixed storage unit. Generally, the storage unit includes computer readable code 530', which is a code read by a processor. When the code is executed by the processor, each step in the method described above is implemented.

[0161] The term "one embodiment", "embodiment" or "one or more embodiments" herein means that a particular feature, structure or characteristic described in conjunction with the embodiment is included in at least one embodiment of the present application. In addition, please note that the examples of the term "in one embodiment" here do not necessarily all refer to the same embodiment.

[0162] In the description provided herein, a large number of specific details are described. However, it is understood that the embodiments of the present application can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.

[0163] In the claims, any reference signs placed between brackets shall not be construed as limiting the claims. The word "comprising" does not exclude the presence of elements or steps not listed in the claims. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present application may be implemented by means of hardware comprising several different elements and by means of a suitably programmed computer. In a unit claim enumerating several means, several of these means may be embodied by the same item of hardware. The use of the words first, second, and third etc. does not indicate any order. These words may be interpreted as names.

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

Claims

1. A text classification method, characterized in that: The method comprises: Classify the target text using at least one first classification model to obtain a classification result output by each of the first classification models, wherein each of the first classification models corresponds to a different classification dimension; Matching the target text with keywords in a preset keyword library, and selecting the keywords matching the target text from the preset keyword library; splicing the classification result, the keyword and the target text to obtain a spliced ​​text; Classify the concatenated text using a second classification model, and obtain a classification result output by the second classification model as a classification result of the target text; The preset keyword library is established by the following method: Performing vocabulary masking on each original text in the preset data set to obtain a masked text, and comparing the classification result of the original text with the classification result of the masked text to obtain the target vocabulary combination in the original text, including: Using the second classification model, each original text in the preset data set is classified and processed to obtain a classification result for each original text; Performing word segmentation processing on each of the original texts, and obtaining candidate keywords based on the words obtained by the word segmentation processing; According to the classification result of the original text, setting the category label of the candidate keyword obtained according to the corresponding original text; According to the category label of the candidate keyword, obtaining preset attribute information of the candidate keyword; For each of the original texts, performing a combination masking process on the words in the original text to obtain a masked text of the original text, wherein each of the masked texts corresponds to a word combination for which the masking process is performed on the original text; Classify the masked text to obtain a classification result corresponding to each masked text; For each of the original texts, according to the classification results of the original text and the classification results of each of the masked texts of the original text, a target vocabulary combination for masking processing is obtained; According to the target vocabulary combination and the corresponding classification result of the original text, operations of adding keywords and deleting keywords are performed on the preset keyword library to construct the keyword library.

2. The method according to claim 1, characterized in that The first classification model and the second classification model are trained respectively by the following methods: Obtain unlabeled training data, and set classification labels corresponding to classification dimensions of a target classification model, wherein the target classification model includes: the first classification model or the second classification model; Based on the unlabeled training data, a training operation of the training model corresponding to the target classification model is performed, wherein the target classification model is configured to: randomly inactivate some parameters with a set probability in the training mode, and the training operation includes: calculating a loss value according to a first output calculated based on some parameters and a second output calculated based on all parameters, updating the some parameters according to the loss value, and iteratively optimizing the training model until a training end condition is met.

3. The method according to claim 1, characterized in that The step of obtaining a target vocabulary combination for masking processing according to the classification result of the original text and the classification results of each mask text of the original text includes: For each of the masked texts, when the classification results of the masked text and the classification results of the original text both meet a preset accuracy threshold, and the classification results of the masked text and the classification results of the original text are different, the vocabulary combination corresponding to the masked text is used as the target vocabulary combination.

4. The method according to claim 1, characterized in that The step of performing combined masking processing on the words in the original text to obtain a masked text of the original text includes: According to the preset attribute information of the candidate keywords, a mask score of each of the words in the original text is obtained; Selecting a preset number of the words according to the size of the mask score as mask words corresponding to the original text; Combining the masked words to obtain a masked word combination; According to the vocabulary combinations, the original text is masked to obtain masked text corresponding to each vocabulary combination.

5. The method according to claim 1, characterized in that The step of adding keywords and deleting keywords from a preset keyword library according to the target vocabulary combination and the corresponding classification result of the original text to construct the keyword library includes: Using the classification result of the original text as the classification result of the target vocabulary combination, the target vocabulary combination is compared with the existing vocabulary in the pre-established keyword library to obtain a comparison result; In response to the comparison result indicating that the target vocabulary combination does not appear in the existing vocabulary, setting a category label for the target vocabulary combination according to the classification result of the original text, and adding the target vocabulary combination to the keyword library; In response to the comparison result indicating that the target vocabulary combination appears in the existing vocabulary and the category label of the target vocabulary combination in the existing vocabulary does not match the classification result of the original text, the target vocabulary combination in the keyword library is marked for deletion.

6. A text classification device, characterized in that: The device comprises: A first classification module, configured to classify the target text using at least one first classification model, and obtain a classification result output by each of the first classification models, wherein each of the first classification models corresponds to a different classification dimension; A keyword extraction module, used to match the target text with the keywords in a preset keyword library, and select the keywords matching the target text from the preset keyword library; A splicing module, used for splicing the classification result, the keyword and the target text to obtain a spliced ​​text; A second classification module is used to classify the concatenated text using a second classification model, and obtain a classification result output by the second classification model as a classification result of the target text; The device is also used to perform vocabulary masking on each original text in the preset data set to obtain the masked text, and compare the classification results of the original text with the classification results of the masked text to obtain the target vocabulary combination in the original text, including: performing classification processing on each original text in the preset data set through the second classification model to obtain the classification result of each original text; performing word segmentation processing on each original text to obtain candidate keywords based on the vocabulary obtained by the word segmentation processing; and setting the candidate keywords obtained according to the corresponding original text according to the classification result of the original text. Category label; according to the category label of the candidate keyword, obtain the preset attribute information of the candidate keyword; for each of the original texts, perform combination masking processing on the words in the original text to obtain the masked text of the original text, wherein each of the masked texts corresponds to a vocabulary combination for masking the original text; perform classification processing on the masked text to obtain the classification result corresponding to each masked text; for each of the original texts, according to the classification result of the original text and the classification results of each of the masked texts of the original text, obtain the target vocabulary combination for masking; According to the target vocabulary combination and the corresponding classification result of the original text, operations of adding keywords and deleting keywords are performed on the preset keyword library to construct the keyword library.

7. An electronic device comprising a memory, a processor, and a program code stored in the memory and executable on the processor, characterized in that: When the processor executes the program code, the text classification method according to any one of claims 1 to 5 is implemented.

8. A computer-readable storage medium having program code stored thereon, characterized in that: When the program code is executed by a processor, the steps of the text classification method described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Text data processing method and device and computer readable storage medium

    CN112948575A

  • Text classification method based on artificial intelligence and related equipment

    CN116414987A

  • Cross-domain problem processing method and device, electronic equipment and storage medium

    CN116842168A

  • Text processing method and device, model training method and device and electronic equipment

    CN116956816A

  • Information push method and device based on text adversarial sample

    WO2023108980A1