Tag library construction method and device, text classification method and device, electronic device, and storage medium

By constructing a tag lexicon using the mT5 model and performing text classification, the problems of high cost and difficulty in creating tag lexicons are solved, and efficient classification of multilingual texts is achieved.

CN115982367BActive Publication Date: 2026-02-27BEIJING TOPSEC NETWORK SECURITY TECH +2
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202310205874.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-03
Publication Date
2026-02-27
Estimated Expiration
2043-03-03

AI Technical Summary

Technical Problem

In existing technologies, the creation of tag libraries is costly, difficult, and of questionable quality. The accuracy of text classification models is insufficient to meet industrial requirements, and the interpretability of the models is poor.

Method used

The mT5 model is used for label extraction. A label extraction model is generated based on labeled data, a label lexicon is constructed, and weighted decision scores are calculated using cosine similarity and word frequency for text classification.

Benefits of technology

It reduces the cost of data annotation and model training, improves the stability and generalization ability of the model, and can effectively classify texts in 101 languages, adapting to texts of different lengths.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115982367B_ABST
    Figure CN115982367B_ABST
Patent Text Reader

Abstract

The application provides a label word library construction method and device, a text classification method and device, an electronic equipment and a storage medium. The label word library construction method comprises the following steps: generating a label extraction model based on annotation data and an mT5 model, wherein the annotation data comprises labels of first positive class texts and labels of negative class texts; extracting labels of second positive class texts based on the label extraction model to obtain first labels and word vectors of the first labels; and counting word frequencies of the first labels, and constructing a label word library based on the word vectors of the first labels and the word frequencies of the first labels. The application can solve the technical problem of high cost, high difficulty and difficult quality guarantee of word library creation, and can be used for classifying texts.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computers, in particular to a label vocabulary construction method and device, a text classification method and device, an electronic device and a storage medium. BACKGROUND

[0002] With the development of NLP (Natural Language Processing) technology, the text classification task has experienced the stages of rule-based division, machine learning model-based classification and deep learning model-based classification. Rule-based division has very limited applicability and poor generalization ability; the accuracy of the model based on machine learning model is difficult to reach the level of current industrial demand; due to the improvement of hardware level and business demand, the current industry mainly adopts deep learning model for text classification, and the mainstream text classification idea is FastText, Bert, LSTM and various varieties thereof, which are completed in one step, and the cost of data acquisition, labeling and training of the model is higher, and the model has poor interpretability. SUMMARY

[0003] The purpose of the embodiments of the present application is to provide a label vocabulary construction method and device, a text classification method and device, an electronic device and a storage medium, which are used to solve the technical problem of high cost, high difficulty and difficult quality guarantee of vocabulary creation, and are used to classify text.

[0004] In a first aspect, the present application provides a label vocabulary construction method, which comprises:

[0005] generating a label extraction model based on labeled data and an mT5 model, wherein the labeled data comprises labels of first positive class text and labels of negative class text;

[0006] extracting labels of second positive class text based on the label extraction model to obtain first labels and word vectors of the first labels;

[0007] statistically counting the word frequency of the first labels, and constructing a label vocabulary based on the word vectors of the first labels and the word frequency of the first labels.

[0008] In this embodiment, the label extraction model is generated based on labeled data and the mT5 model. The mT5 model only requires fine-tuning with a few thousand data points to reach industrial application levels, thus reducing data labeling costs. Furthermore, compared to the weeks of training time required for other large-scale models, the mT5 model can be deployed in half a week, thus offering the advantage of low training costs. Moreover, a label extraction model can be obtained based on the mT5 model, which can then be used to construct a vocabulary. Compared to manual labeling, this model possesses more stable judgment capabilities and stronger generalization abilities, while saving on the costs of manual labeling and maintenance.

[0009] Secondly, the present invention provides a text classification method, the method comprising:

[0010] Based on the label extraction model in the first aspect of this application, the labels of the text to be classified are extracted, and the second label and the word vector of the second label are obtained;

[0011] Calculate the matching similarity between the word vector of the second tag and each word vector in the tag lexicon, wherein the tag lexicon is constructed based on the method described in the foregoing embodiments;

[0012] Based on the similarity between the word vector of the second tag and each word vector in the tag lexicon and the word frequency of all matching tags, a weighted decision score is calculated;

[0013] Based on the weighted decision score and the preset decision threshold, the text category of the text to be classified is determined.

[0014] In the second aspect of this application, since the label extraction model is based on the mT5 model, and the mT5 model uses multilingual text in the pre-training stage, this application can classify texts in 101 languages ​​compared to the prior art. Since the decision of this application is mainly based on the label extraction results rather than the text to be classified itself, it can achieve good classification results for texts of different lengths.

[0015] In an optional implementation, calculating the similarity between the word vector of the second tag and each word vector in the tag lexicon includes:

[0016] The similarity between the word vector of the second tag and each word vector in the tag lexicon is calculated based on the cosine similarity formula.

[0017] The above-described optional implementation can calculate the matching similarity between the word vector of the second tag and each word vector in the tag lexicon based on the cosine similarity calculation formula.

[0018] In an optional implementation, the cosine similarity is calculated as follows:

[0019]

[0020] wherein, Sim(X, Y) represents the matching similarity of the word vector of the second label and the word vector in the label word library, represents the word vector of the second label, represents the word vector in the label word library.

[0021] The optional implementation can accurately calculate the matching similarity of the word vector of the second label and the word vector in the label word library through the calculation formula of the cosine similarity.

[0022] In the optional implementation, the calculation formula corresponding to the calculation of the weighted decision score based on the matching similarity of the word vector of the second label and each word vector in the label word library and the word frequency of all matching labels is:

[0023]

[0024] wherein, C represents the weighted decision score, Sim(X, Y) represents the matching similarity of the word vector of the second label and the word vector in the label word library, F represents the word frequency of the matching label, m represents the number of word vectors in the label word library, and i represents the subscript of the word vector in the label word library. i represents the matching similarity of the word vector of the second label and the word vector in the label word library, F i represents the word frequency of the matching label, m represents the number of word vectors in the label word library, and i represents the subscript of the word vector in the label word library.

[0025] The optional implementation can calculate the weighted decision score through the calculation formula corresponding to the calculation of the weighted decision score based on the matching similarity of the word vector of the second label and each word vector in the label word library and the word frequency of all matching labels.

[0026] In the optional implementation, the determination of the text category of the text to be classified based on the weighted decision score and the preset decision threshold comprises:

[0027] when the weighted decision score is greater than or equal to the preset decision threshold, determining that the text category of the text to be classified is a positive class;

[0028] when the weighted decision score is less than the preset decision threshold, determining that the text category of the text to be classified is a negative class.

[0029] The optional implementation can determine that the text category of the text to be classified is a positive class when the weighted decision score is greater than or equal to the preset decision threshold, and determine that the text category of the text to be classified is a negative class when the weighted decision score is less than the preset decision threshold, by comparing the weighted decision score with the preset decision threshold.

[0030] In a third aspect, the present application provides a label library construction device, which comprises:

[0031] a generating module configured to generate a label extraction model based on annotated data and an mT5 model, wherein the annotated data comprises labels of first positive class texts and labels of negative class texts;

[0032] a first extracting module configured to extract labels of second positive class texts based on the label extraction model to obtain first labels and word vectors of the first labels;

[0033] a constructing module configured to count word frequencies of the first labels and construct a label library based on the word vectors of the first labels and the word frequencies of the first labels.

[0034] In the embodiments of the present application, the label extraction model is generated based on annotated data and an mT5 model. The mT5 model only needs to be fine-tuned with several thousand data to reach the industrial application level, thereby reducing the data annotation cost. On the other hand, compared with the training time of several weeks of other large-scale models, the mT5 model can be landed in half a week, thereby having the advantage of low model training cost. On the other hand, the label extraction model can be obtained based on the mT5 model, so that the label library can be constructed using the label extraction model. Compared with manual annotation, the model has more stable judgment ability and stronger summarization ability, and can save the cost of manual annotation and maintenance.

[0035] In a fourth aspect, the present application provides a text classification device, which comprises:

[0036] a second extracting module configured to extract labels of a text to be classified based on the label extraction model in the method of the foregoing embodiments to obtain second labels and word vectors of the second labels;

[0037] a calculating module configured to calculate matching similarities between the word vectors of the second labels and each word vector in a label library, wherein the label library is constructed based on the method of the foregoing embodiments;

[0038] a matching module configured to calculate a weighted decision score based on the matching similarities between the word vectors of the second labels and each word vector in the label library and word frequencies of all matching labels;

[0039] a determining module configured to determine a text category of the text to be classified based on the weighted decision score and a preset decision threshold.

[0040] In the present application, since the label extraction model is obtained based on the mT5 model, and the mT5 model uses multilingual text in the pre-training stage, compared with the prior art, the present application can classify the text to be classified in 101 languages. Since the decision of the present application is mainly based on the label extraction result, rather than the text to be classified itself, the present application can have good classification effect on text of different lengths.

[0041] In a fifth aspect, the present application provides an electronic device, comprising:

[0042] a processor; and

[0043] a memory configured to store machine-readable instructions, which, when executed by the processor, perform the label vocabulary construction method and the text classification method according to any one of the preceding embodiments.

[0044] The electronic device of the present application can classify text by performing the label vocabulary construction method and the text classification method, and can solve the technical problem of high cost, high difficulty and difficult quality guarantee in vocabulary creation.

[0045] In a sixth aspect, the present application provides a storage medium, which stores a computer program, and the computer program performs the label vocabulary construction method and the text classification method according to any one of the preceding embodiments when executed by a processor.

[0046] The storage medium of the present application can classify text by performing the label vocabulary construction method and the text classification method, and can solve the technical problem of high cost, high difficulty and difficult quality guarantee in vocabulary creation. BRIEF DESCRIPTION OF DRAWINGS

[0047] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings needed to be used in the embodiments of the present application. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as a limitation on the scope. For those skilled in the art, other related drawings can also be obtained without creative labor.

[0048] Figure 1 is a flowchart of a label vocabulary construction method disclosed by the embodiments of the present application;

[0049] Figure 2 is a flowchart of a text classification method disclosed by the embodiments of the present application;

[0050] Figure 3 is a structural diagram of a label vocabulary construction device disclosed by the embodiments of the present application;

[0051] Figure 4 is a structural schematic diagram of a text classification device disclosed by an embodiment of the present application;

[0052] Figure 5 is a structural schematic diagram of an electronic device disclosed by an embodiment of the present application. DETAILED DESCRIPTION

[0053] The technical solutions in the embodiments of the present application will be described below with reference to the drawings in the embodiments of the present application.

[0054] Embodiment one

[0055] Please refer to Figure 1 , Figure 1 is a flowchart of a label corpus construction method disclosed by an embodiment of the present application, as shown in the figure, the method of the present embodiment includes the following steps: Figure 1

[0056] 101. Generating a label extraction model based on annotated data and an mT5 model, wherein the annotated data includes labels of first positive class texts and labels of negative class texts;

[0057] 102. Extracting labels of second positive class texts based on the label extraction model to obtain first labels and word vectors of the first labels;

[0058] 103. Counting the word frequency of the first labels, and constructing a label corpus based on the word vectors of the first labels and the word frequency of the first labels.

[0059] In the present embodiment, the label extraction model is generated based on annotated data and an mT5 model, wherein the mT5 model only needs to be fine-tuned with a few thousand data to reach the level of industrial application, thereby reducing the data annotation cost. On the other hand, compared with the training time of several weeks of other large-scale models, the mT5 model can be put into use in half a week, thus having the advantage of low model training cost. On the other hand, based on the mT5 model, the label extraction model can be obtained, so that the label extraction model can be used to constitute a word library. Compared with manual annotation, the model has more stable judgment ability and stronger summarization ability, and can save the cost of manual annotation and maintenance.

[0060] In the present embodiment, for step 101, the first positive class text is a text of a target domain, for example, the first positive class text can be a text of the news field. It should be noted that the target domain can also be other fields such as sports news.

[0061] In the present embodiment, when the domain of the first positive class text is adjusted, only the corresponding domain positive class text content needs to be supplemented in an appropriate amount, and the remaining content can be directly used as negative class text.

[0062] ​In the embodiment of the present application, for step 101, the negative class text refers to the text of a non-target field. For example, when the target field is the field of news, the negative class text is the text of sports news and other fields.

[0063] In the embodiment of the present application, for step 101, the labeled data includes labels generated based on the plurality of first positive class texts and labels generated based on the plurality of negative class texts. For example, 60 labels are generated based on 20 first positive class texts, and 90 labels are generated based on 30 negative class texts.

[0064] In the embodiment of the present application, for step 101, the lengths of the plurality of first positive class texts can also be the same, and the lengths of the plurality of negative class texts can also be different.

[0065] In the embodiment of the present application, for step 101, the labels of the first positive class texts and the labels of the negative class texts can be manually labeled, wherein the number of labels of each text is 3-5.

[0066] In the embodiment of the present application, the mT5 model is a pre-training model provided by Transformers, wherein Transformers is an open source natural language processing library. It should be noted that for Transformers, please refer to the prior art, and the embodiment of the present application will not be repeated here.

[0067] In the embodiment of the present application, for step 101, one specific way of generating the label extraction model based on the labeled data and the mT5 model is:

[0068] Fine-tune the mT5 model using the labeled data to obtain the label extraction model.

[0069] In the embodiment of the present application, fine-tuning the mT5 model using the labeled data refers to adjusting a small number of parameters in the mT5 model.

[0070] In the embodiment of the present application, one specific way of constructing the label word library based on the word vector of the first label and the word frequency of the first label is:

[0071] The first label, the word vector of the first label and the word frequency of the first label are used as library data to construct the label word library, wherein the first label can have a unique identifier, and the word vector of the first label and the word frequency of the first label are bound to the unique identifier.

[0072] In the embodiment of the present application, the method of the present application can further include the following steps:

[0073] The labels with poor extraction effect and little association with the target field in the label word library are screened out, thereby improving the quality of the label word library.

[0074] Embodiment two

[0075] Referring to Figure 2 , Figure 2 is a flowchart of a text classification method disclosed in an embodiment of the present application, as shown in Figure 2 The method of the embodiment of the present application comprises the following steps:

[0076] 201. Extracting a label of the text to be classified based on a label extraction model and obtaining a second label and a word vector of the second label, wherein the label extraction model is the label extraction model in the label word bank construction method;

[0077] 202. Calculating the matching similarity of the word vector of the second label and each word vector in the label word bank, wherein the label word bank is constructed based on the label word bank construction method of the foregoing embodiment;

[0078] 203. Calculating a weighted decision score based on the matching similarity of the word vector of the second label and each word vector in the label word bank and the word frequency of all matching labels;

[0079] 204. Determining the text category of the text to be classified based on the weighted decision score and a preset decision threshold.

[0080] In the embodiment of the present application, since the label extraction model is obtained based on the mT5 model, and the mT5 model uses multilingual text in the pre-training stage, compared with the prior art, the present application can classify the text to be classified in 101 languages. Since the decision of the present application is mainly based on the label extraction result, rather than the text to be classified itself, the present application has good classification effect on texts of different lengths.

[0081] In the embodiment of the present application, as an example, the text classification method of the embodiment of the present application can be applied in the scenario of crawling safety event articles, specifically: determining a list of source sites that may contain safety event article contents, then accessing the source sites in the list, crawling a small part of sub-page contents under the corresponding source sites, and using the text classification method of the embodiment of the present application to determine the category of the small part of sub-page contents, wherein if the classification result is mostly positive, it indicates that there is a large amount of useful information in the current source site, and the current source site is retained; if there is almost no positive class in the classification result, it indicates that the current source site is not the target source site, and the source site is excluded.

[0082] In the optional embodiment, step 202: calculating the matching similarity of the word vector of the second label and each word vector in the label word bank, comprises the following sub-steps:

[0083] Calculating the matching similarity of the word vector of the second label and each word vector in the label word bank based on the cosine similarity calculation formula.

[0084] The optional implementation can calculate the matching similarity of the word vector of the second label and each word vector in the label word library based on the cosine similarity calculation formula.

[0085] In an optional implementation, the cosine similarity calculation formula is:

[0086]

[0087] wherein, Sim(X, Y) represents the matching similarity of the word vector of the second label and the word vector in the label word library, X represents the word vector of the second label, Y represents the word vector in the label word library.

[0088] The optional implementation can accurately calculate the matching similarity of the word vector of the second label and the word vector in the label word library through the cosine similarity calculation formula.

[0089] In the optional implementation, the cosine value of the word vector of the second label and the word vector in the label word library reflects the similarity of the two vectors, and the value range is [-1, 1]. The greater the value, the smaller the angle between the vectors, and the higher the similarity.

[0090] In an optional implementation, based on the matching similarity of the word vector of the second label and each word vector in the label word library and the word frequency of all matching labels, the calculation formula corresponding to the weighted decision score is:

[0091]

[0092] wherein, C represents the weighted decision score, S i Sim(X, Y) represents the matching similarity of the word vector of the second label and the word vector in the label word library, F i represents the word frequency of the matching label, m represents the number of word vectors in the label word library, and i represents the subscript of the word vector in the label word library.

[0093] The optional implementation can calculate the weighted decision score by calculating the calculation formula corresponding to the weighted decision score based on the matching similarity of the word vector of the second label and each word vector in the label word library and the word frequency of all matching labels.

[0094] In an optional implementation, based on the weighted decision score and the preset decision threshold, the text category of the text to be classified is determined, including:

[0095] When the weighted decision score is greater than or equal to the preset decision threshold, the text category of the text to be classified is determined as a positive class;

[0096] When the weighted decision score is less than the preset decision threshold, the text category of the text to be classified is determined as a negative class.

[0097] The optional implementation can determine the text category of the text to be classified as a positive class when the weighted decision score is greater than or equal to the preset decision threshold, and determine the text category of the text to be classified as a negative class when the weighted decision score is less than the preset decision threshold, by comparing the weighted decision score with the preset decision threshold.

[0098] In the embodiment of the application, the preset decision threshold can be adjusted, thereby better adapting to actual business.

[0099] Embodiment three

[0100] Please refer to Figure 3 , Figure 3 is a structural schematic diagram of a label library construction device disclosed in an embodiment of the application, as Figure 2 shown, the device of the embodiment of the application comprises the following functional modules:

[0101] The generating module 301 is configured to generate a label extraction model based on the annotation data and the mT5 model, wherein the annotation data comprises labels of the first positive class text and labels of the negative class text.

[0102] The first extracting module 302 is configured to extract the label of the second positive class text based on the label extraction model to obtain the first label and a word vector of the first label.

[0103] The construction module 303 is configured to count the word frequency of the first label, and construct a label library based on the word vector of the first label and the word frequency of the first label.

[0104] In the embodiment of the application, the label extraction model is generated based on the annotation data and the mT5 model, wherein the mT5 model only needs to be fine-tuned with several thousand data to reach the industrial application level, thereby reducing the data annotation cost. On the other hand, compared with the training time of several weeks of other large-scale models, the mT5 model can be put into use in half a week, thus having the advantage of low model training cost. On the other hand, based on the mT5 model, the label extraction model can be obtained, so as to utilize the label extraction model to constitute the word library. Compared with manual annotation, the model has more stable judgment ability and stronger summarization ability, and can save the cost of manual annotation and maintenance.

[0105] Embodiment four

[0106] Please refer to Figure 4 , Figure 4 is a structural schematic diagram of a text classification device disclosed in an embodiment of the application, as Figure 4 shown, the device of the embodiment of the application comprises the following functional modules:

[0107] The second extraction module 401 is configured to extract a label of the text to be classified based on the label extraction model in the method of the foregoing embodiment, and obtain a second label and a word vector of the second label.

[0108] The calculation module 402 is configured to calculate a matching similarity of the word vector of the second label and each word vector in a label word library, wherein the label word library is constructed based on the label word library construction method of the foregoing embodiment.

[0109] The matching module 403 is configured to calculate a weighted decision score based on the matching similarity of the word vector of the second label and each word vector in the label word library and the word frequency of all matching labels.

[0110] The determination module 404 is configured to determine a text category of the text to be classified based on the weighted decision score and a preset decision threshold.

[0111] In the embodiment of the present application, since the label extraction model is obtained based on the mT5 model, and the mT5 model uses multilingual text in the pre-training stage, compared with the prior art, the present application can classify the text to be classified in 101 languages. Since the decision of the present application is mainly based on the label extraction result, rather than the text to be classified itself, the present application has good classification effect on texts of different lengths.

[0112] Embodiment five

[0113] Please refer to Figure 5 , Figure 5 is a structural schematic diagram of an electronic device disclosed in an embodiment of the present application, as Figure 5 shown, the electronic device of the embodiment of the present application comprises:

[0114] a processor 501; and

[0115] a memory 502 configured to store machine-readable instructions, the instructions being executed by the processor 501 to perform the label word library construction method of the foregoing embodiment and the text classification method of any one of the foregoing embodiments.

[0116] The electronic device of the embodiment of the present application can classify texts by executing the label word library construction method and the text classification method, and can solve the technical problem of high cost, high difficulty and difficult quality guarantee in creating a word library.

[0117] Embodiment six

[0118] The embodiment of the present application provides a storage medium, the storage medium stores a computer program, and the computer program is executed by a processor to perform the label word library construction method of the foregoing embodiment and the text classification method of any one of the foregoing embodiments.

[0119] The storage medium of the embodiment of the application can classify the text by executing the tag library construction method and the text classification method, and can solve the technical problem of high cost, high difficulty and difficult quality guarantee of library creation.

[0120] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other manners. The embodiments described above are merely schematic; for example, the division of the units is only a logical function division, and there can be another division manner in actual implementation; for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed mutual couplings or direct couplings or communication connections can be indirect couplings or communication connections through some communication interfaces, and can be electrical, mechanical or other forms.

[0121] In addition, the units described as separate components can or can not be physically separate, and the components displayed as units can or can not be physical units, i.e., can be located in one place, or can be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purposes of the embodiments.

[0122] Furthermore, the function modules in each of the embodiments of the present application can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.

[0123] It should be noted that if the functions are realized in the form of software function modules and sold or used as independent products, they can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the parts that make contributions to the prior art or parts of the technical solutions can be embodied in the form of a software product. The computer software product is stored in a storage medium, and includes a number of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the methods of the embodiments of the present application. The aforementioned storage medium includes: a U disk, a mobile hard disk, a read-only memory (Read-Only Memory, ROM), a random access memory (Random Access Memory, RAM), a magnetic disk or an optical disk, and various program code storage media.

[0124] In this document, relational terms such as first and second and the like can only be used to distinguish one entity or action from another entity or action, and do not necessarily require or imply that these entities or actions exist in any such actual relationship or order.

[0125] The above merely provides an example of the present application, and is not used to limit the protection scope of the present application. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the protection scope of the present application.

Claims

1. A method of text classification, characterized by, The method includes: A label extraction model is generated based on labeled data and an mT5 model, wherein the labeled data includes labels for the first positive class text and labels for the negative class text; Based on the tag extraction model, the tags of the second positive text are extracted to obtain the first tag and the word vector of the first tag; Count the word frequency of the first tag, and construct a tag lexicon based on the word vector of the first tag and the word frequency of the first tag; Furthermore, the method further includes: Based on the label extraction model, the labels of the text to be classified are extracted, and the second label and the word vector of the second label are obtained; Calculate the similarity between the word vector of the second tag and the word vector of each word in the tag lexicon; Based on the similarity between the word vector of the second tag and each word vector in the tag lexicon and the word frequency of all matching tags, a weighted decision score is calculated; Based on the weighted decision score and the preset decision threshold, the text category of the text to be classified is determined; And, determining the text category of the text to be classified based on the weighted decision score and the preset decision threshold includes: When the weighted decision score is greater than or equal to the preset decision threshold, the text category of the text to be classified is determined to be positive. When the weighted decision score is less than the preset decision threshold, the text category of the text to be classified is determined to be negative.

2. The method of claim 1, wherein, The calculation of the similarity between the word vector of the second tag and each word vector in the tag lexicon includes: The similarity between the word vector of the second tag and each word vector in the tag lexicon is calculated based on the cosine similarity formula.

3. The method of claim 2, wherein, The formula for calculating the cosine similarity is: ; wherein Sim(X, Y) represents a matching similarity of a word vector of the second label and a word vector in the label word library, a word vector of the second label, a word vector in the label word library.

4. The method of claim 1, wherein, The formula for calculating the weighted decision score based on the similarity between the word vector based on the second tag and each word vector in the tag lexicon, and the word frequency of all matching tags, is as follows: ; wherein C denotes the weighted decision score, denotes the matching similarity of the word vector of the second label with the word vectors in the label vocabulary, denotes the word frequency of the matching label, m denotes the number of word vectors in the label vocabulary, and i denotes the subscript of the word vector in the label vocabulary.

5. A text classification device, characterized in that, The device includes: A generation module is used to generate a label extraction model based on labeled data and an mT5 model, wherein the labeled data includes labels for a first positive class of text and labels for a negative class of text; The first extraction module is used to extract the tags of the second positive text based on the tag extraction model, and obtain the first tag and the word vector of the first tag; The construction module is used to count the word frequency of the first tag and construct a tag lexicon based on the word vector of the first tag and the word frequency of the first tag; The device also includes: The second extraction module is used to extract the tags of the text to be classified based on the tag extraction model and obtain the second tag and the word vector of the second tag; The calculation module is used to calculate the similarity between the word vector of the second tag and each word vector in the tag lexicon; The matching module is used to calculate a weighted decision score based on the similarity between the word vector of the second tag and each word vector in the tag lexicon and the word frequency of all matching tags; The determination module is used to determine the text category of the text to be classified based on the weighted decision score and the preset decision threshold; And, determining the text category of the text to be classified based on the weighted decision score and the preset decision threshold includes: When the weighted decision score is greater than or equal to the preset decision threshold, the text category of the text to be classified is determined to be positive. When the weighted decision score is less than the preset decision threshold, the text category of the text to be classified is determined to be negative.

6. An electronic device, characterized in that, include: processor; as well as The memory is configured to store machine-readable instructions that, when executed by the processor, perform the text classification method as described in any one of claims 1-4.

7. A storage medium, characterized in that, The storage medium stores a computer program, which is executed by a processor using the text classification method as described in any one of claims 1-4.

Citation Information

Patent Citations

  • Text processing method and device, computer readable storage medium and electronic equipment

    CN111737476A

  • Multi-intention recognition method and system based on BERT language model and TextCNN model

    CN114818703A