Text classification model training method, device, storage medium and electronic device

By obtaining semantically similar text sets from the database to train the text classification model, the problem of existing methods relying on high-quality labels is solved, and a text classification model with efficient training and classification effects is achieved.

CN116204632BActive Publication Date: 2025-09-09JILIN UNIVERSITY
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211522057.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-30
Publication Date
2025-09-09
Estimated Expiration
2042-11-30

AI Technical Summary

Technical Problem

Existing text classification model training methods rely on high-quality labels and take a long time to train, resulting in poor training and classification results, and requiring a large amount of data resources.

Method used

By obtaining at least one label and unlabeled text, a semantically similar text set is obtained from the database, and these text sets are used to train the text classification model until the model converges, avoiding dependence on label quality and reducing the amount of training data.

Benefits of technology

It achieves efficient training of text classification models with small data volumes, ensures training and classification effects, shortens training time, and is independent of label quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116204632B_ABST
    Figure CN116204632B_ABST
Patent Text Reader

Abstract

The present application discloses a training method, device, storage medium, and electronic device for a text classification model, relating to the field of natural language learning technology. The training method for a text classification model includes: obtaining at least one label and at least one first unlabeled text; obtaining a target text set corresponding to each label from a database based on the at least one label and the at least one first unlabeled text; and training the text classification model based on each label and the target text set corresponding to the label until the text classification model converges. The present application no longer relies on the quality of the label and guarantees the training effect of the text classification model, and even the classification effect of the text classification model after training.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of natural language learning technology, and in particular to a training method, device, storage medium, and electronic device for a text classification model. Background Art

[0002] Text classification is a major research area in machine learning, used to classify text by matching labels to the text being classified. Traditional supervised learning methods require sufficient labeled text to train text classification models. Weakly supervised learning, on the other hand, can train text classification models using both unlabeled data and class labels. Therefore, weakly supervised learning can address the problem of insufficient labeled data during text classification model training.

[0003] In related technologies, weakly supervised learning methods use keywords as a driver to expand the given initial keywords to obtain a keyword set, further assign the keyword set as a pseudo-label for each given unlabeled text data, and finally use these pseudo-labeled text data to train a text classification model. Summary of the Invention

[0004] This application provides a training method, device, storage medium, and electronic device for a text classification model that no longer relies on the quality of labels and guarantees the training effect of the text classification model, and even the classification effect of the text classification model after training. The technical solution is as follows:

[0005] In a first aspect, the present application provides a method, apparatus, storage medium, and electronic device for training a text classification model, the method comprising:

[0006] Obtain at least one label and at least one first unlabeled text;

[0007] According to at least one of the tags and at least one of the first unlabeled texts, acquiring a target text set corresponding to each of the tags from a database;

[0008] The text classification model is trained according to each of the labels and the target text set corresponding to the label until the text classification model converges.

[0009] In a second aspect, the present application provides a training device for a text classification model, the device comprising:

[0010] A first acquisition module, configured to acquire at least one label and at least one first unlabeled text;

[0011] A second acquisition module is configured to acquire a target text set corresponding to each tag from a database according to at least one tag and at least one first unlabeled text;

[0012] The model training module is used to train the text classification model according to each label and the target text set corresponding to the label until the text classification model converges.

[0013] In a third aspect, the present application provides a computer storage medium, wherein the computer storage medium stores a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the above-mentioned method steps.

[0014] In a fourth aspect, the present application provides an electronic device, which may include: a processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the above-mentioned method steps.

[0015] The beneficial effects of the technical solutions provided by some embodiments of the present application include at least:

[0016] This application obtains a target text set corresponding to each label from a database based on at least one label and at least one first unlabeled text provided for a training task of a text classification model, thereby training a text classification model through multiple unlabeled texts in the target text set and the corresponding labels. Compared with the method of expanding each label and training the text classification model based on the expanded label and at least one first unlabeled text, the training method proposed in this application no longer depends on the quality of the label, and guarantees the training effect of the text classification model, and even the classification effect of the text classification model after the training is completed; at the same time, this application does not require large-scale training data, and only achieves better training effects through a small number of databases, and shortens the training time. BRIEF DESCRIPTION OF THE DRAWINGS

[0017] In order to more clearly illustrate the technical solutions in the present application or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.

[0018] Figure 1 This is a schematic diagram of the architecture of a text classification model training method provided in this application;

[0019] Figure 2 This is a flowchart of a training method for a text classification model provided in this application;

[0020] Figure 3 This is a flowchart of another text classification model training method provided by this application;

[0021] Figure 4This is a flowchart of obtaining a target text set based on a label provided by this application;

[0022] Figure 5 This is a flowchart of a training method for a text classification model provided in this application;

[0023] Figure 6 This is a structural diagram of a training device for a text classification model provided by this application;

[0024] Figure 7 This is a structural diagram of an electronic device provided by this application. DETAILED DESCRIPTION

[0025] The following will be combined with the accompanying drawings to clearly and completely describe the technical solutions in this application. Obviously, the embodiments described are only some of the embodiments of this application, not all of them. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.

[0026] In the description of this application, it should be understood that the terms "first", "second", etc. are used for descriptive purposes only and should not be understood to indicate or imply relative importance. In the description of this application, it should be noted that, unless otherwise expressly specified and limited, "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units that are not listed, or may optionally include other steps or units inherent to these processes, methods, products or devices. For those of ordinary skill in the art, the specific meanings of the above terms in this application can be understood according to the specific circumstances. In addition, in the description of this application, unless otherwise specified, "multiple" refers to two or more. "and / or" describes the association relationship of associated objects, indicating that three relationships can exist. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects before and after are in an "or" relationship.

[0027] The present application is described in detail below with reference to specific embodiments.

[0028] Artificial intelligence is an interdisciplinary subject that covers a wide range of fields, including both hardware-level and software-level technologies. The basic technologies of artificial intelligence generally include technologies such as sensors, dedicated artificial intelligence chips, cloud computing, distributed storage, big data processing technologies, operating / interactive systems, and mechatronics. Artificial intelligence software technologies mainly include computer vision technology, speech processing technology, natural language processing technology, and machine learning / deep learning. In natural language processing technology, artificial intelligence can be used to process text and reasonably interpret the words in the text. The training method of the text classification model and the text processing method provided in the embodiments of the present application belong to the field of natural language processing technology.

[0029] Natural language processing (NLP) is a key area of ​​research in computer science and artificial intelligence. It studies the theories and methods that enable effective communication between humans and computers using natural language. Natural language processing (NLP) integrates linguistics, computer science, and mathematics. Therefore, research in this field involves natural language—the language we use in everyday life—and thus has close ties to linguistics. Natural language processing technologies typically include text processing, semantic understanding, machine translation, robotic question-answering, and instruction graphs.

[0030] It can be understood that in the specific implementation of this application, the data related to the first unlabeled text and the second unlabeled text, when the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards of relevant countries and regions.

[0031] For training text classification models, existing methods combine weakly supervised text classification with graph neural networks. First, a keyword graph is constructed based on the initial labels and a set of unlabeled text. If a word and the initial label appear in the same text, an edge exists between the word and the label. This creates a very large keyword graph, and each unlabeled text becomes a subgraph within the keyword graph. Therefore, the task of assigning labels to unlabeled texts becomes a subgraph annotation task. Next, a self-supervised task is designed based on the keyword graph to train a high-quality subgraph annotator. This is an iterative process. Initially, some unlabeled texts contain the initial labels. These unlabeled texts are directly assigned the initial labels as label texts to train the subgraph annotator. New labels are then obtained for all unlabeled texts. A keyword extraction algorithm is then designed to re-extract labels, and the above process is repeated until the label changes are minimal. The resulting subgraph annotator is then used to assign labels to all unlabeled texts. This means that unlabeled texts are annotated with the initial labels, resulting in an annotated unlabeled text. A text classification model is then trained using the annotated unlabeled texts until training is complete, resulting in the final text classification model.

[0032] The selection of initial labels and the subsequent label expansion strategy are key to the success of this method. However, initial labels are often directly based on the class labels given by the task. If the class labels are not of good quality, it will directly affect the training and even classification results. Therefore, people have to manually change the class labels and use some synonyms as initial labels to manually improve the training effect of text classification models.

[0033] However, if the classification task cannot provide high-quality labels, the training effect of the text classification model will be greatly reduced. In addition, another problem with this method is that the training time of the text classification model is very long. With the development of new technologies, it often takes a lot of time to train a high-quality text classification model, which is also a waste of training resources.

[0034] like Figure 1 1 is a schematic diagram of a scenario for a text classification model training method provided in an embodiment of the present application. The application scenario includes a server 102 and an electronic device 101. The electronic device 101 and the server 102 can communicate via a communication network. In one embodiment, the communication network is a wired network or a wireless network. The server 102 and the electronic device 101 can be directly or indirectly connected via wired or wireless communication, which is not limited in this application.

[0035] In an embodiment of the present application, the electronic device 101 is an electronic device used by a user to train a text classification model. The electronic device 101 can be a personal computer, a mobile phone, a tablet computer, a notebook, an e-book reader, or other computer device with certain computing capabilities and running instant messaging software and websites or social software and websites, but is not limited to this.

[0036] Server 102 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), as well as big data and artificial intelligence platforms.

[0037] The text classification model is deployed on the electronic device 101 for training. The database of the server 102 may store a large amount of unlabeled text for the electronic device 101 to obtain and train the text classification model. Optionally, after the text merging judgment model is trained based on the training method in this application, the trained text classification model can be directly deployed on the server 102 or the electronic device 101. Generally, the text classification model is directly deployed on the electronic device 101. In the embodiment of this application, the text classification model is often used to analyze the text to be classified input by the user, so as to classify the text to be classified by outputting at least one label.

[0038] In one possible application scenario, to reduce communication latency, servers 102 can be deployed in various regions. Alternatively, for load balancing, different servers 102 can serve the regions corresponding to different electronic devices 101. Servers 102 can share data through blockchain, and multiple servers 102 function as a data sharing system comprised of multiple servers 102. For example, electronic device 101 at location a communicates with server 102, while electronic device 101 at location b communicates with other servers 101.

[0039] In one embodiment, Figure 2 The figure below is a flow chart of a text classification model training method proposed in this application. This method can be implemented using a computer program and run on a training device for a text classification model based on the von Neumann architecture. The computer program can be integrated into an application or run as a standalone tool application.

[0040] Specifically, the training method of the text classification model includes:

[0041] S101: Acquire at least one label and at least one first unlabeled text.

[0042] Based on a training task for a text classification model, an initial training set corresponding to the training task is obtained. The initial training set includes at least one label and at least one first unlabeled text. The first unlabeled text can be understood as unclassified text to be classified. Text refers to a text segment composed of Chinese or foreign characters that can express meaning, including any type of text such as sentences, paragraphs, and articles, and any language such as English, Chinese, and German.

[0043] Accordingly, different training samples are used for different training tasks. Taking the medical scenario as an example, the first unlabeled text in the initial training set is a patient-doctor question-and-answer pair, and at least one label is a case. Similarly, when using a trained text classification model for text classification, the labels used and the corresponding unlabeled text are different in different scenarios. For example, in a medical scenario, the text to be classified input by the user is a judgment question entered by the patient containing the names of various diseases, and the labels output by the text classification model are various case studies.

[0044] S102: Acquire a target text set corresponding to each tag from a database according to at least one tag and at least one first unlabeled text.

[0045] This application no longer uses the idea of ​​the label-driven method to assign pseudo labels to unlabeled texts by expanding labels to obtain a label set. Instead, it uses at least one label and at least one first unlabeled text to search for a second unlabeled text with high semantic relevance to the at least one label and the at least one first unlabeled text from at least one second unlabeled text included in the database based on semantic similarity as the text in the target text set, and then trains a text classification model based on the target text set.

[0046] It can be understood that the database refers to any text data platform other than the initial training set corresponding to the training task of the text classification model, and the electronic device can obtain the text data in the database through any known method.

[0047] According to the similarity parameters between each second unlabeled text and the first unlabeled text in the database, the semantic similarity value between the second unlabeled text and the first unlabeled text is obtained based on the BERT model, and the second unlabeled text whose semantic similarity value meets the preset conditions is used as the text in the target text set.

[0048] The similarity parameter representing the relationship between the first unlabeled text and the second unlabeled text includes: a similarity matrix between the first unlabeled text and the second unlabeled text; or a computational model for generating a similarity matrix. For example, the first unlabeled text and the second unlabeled text are sentence 1 "I am a student" and sentence 2 "you are not a teacher", respectively. Sentence 1 includes 5 words and sentence 2 includes 6 words. Based on the semantic relationship in the prior knowledge Word Net, the similarity of each word pair (W1, W2) in sentence 1 and sentence 2 is calculated, for example, the similarity of the word pair (I, you) is 0.5, and the similarity of the word pair (a, a) is 1. Based on the above semantic relationship, a 5×6 similarity matrix is ​​constructed for sentences 1 and 2. The similarity matrix is ​​the similarity parameter. The computational model for generating the similarity matrix is ​​a computational model established based on the Word Net semantic relationship database, and is used to generate the similarity matrix between the first unlabeled text and the second unlabeled text. It is understandable that this application does not limit how to obtain similarity parameters and calculation models. Using other calculation models or calculation methods to obtain similarity parameters between the first unlabeled text and the second unlabeled text still falls within the scope of protection of this application.

[0049] S103: training a text classification model according to each label and the target text set corresponding to each label until the text classification model converges.

[0050] According to the probability of the labels output by the text classification model to be trained based on the target text set and the known labels corresponding to the target text set, the loss function of the text classification model is determined, and the model parameters of the encoding layer of the text classification model are reversely adjusted according to the loss function. The text classification model is further iterated for multiple rounds to obtain a trained text classification model.

[0051] This application obtains a target text set corresponding to each label from a database based on at least one label and at least one first unlabeled text provided for a training task of a text classification model, thereby training a text classification model through multiple unlabeled texts in the target text set and the corresponding labels. Compared with the method of expanding each label and training the text classification model based on the expanded label and at least one first unlabeled text, the training method proposed in this application no longer depends on the quality of the label, and guarantees the training effect of the text classification model, and even the classification effect of the text classification model after the training is completed; at the same time, this application does not require large-scale training data, and only achieves better training effects through a small number of databases, and shortens the training time.

[0052] In one embodiment, Figure 3The figure below is a flow chart of a text classification model training method proposed in this application. This method can be implemented using a computer program and run on a training device for a text classification model based on the von Neumann architecture. The computer program can be integrated into an application or run as a standalone tool application.

[0053] Specifically, the training method of the text classification model includes:

[0054] S201: Acquire at least one label and at least one first unlabeled text.

[0055] See the above S101, which will not be repeated here.

[0056] S202: Acquire a first text set corresponding to each tag according to at least one tag, where the first text set includes at least one first unlabeled text.

[0057] According to the similarity between each label and each first unlabeled text, the first text set corresponding to each label is obtained. Specifically, the similarity between each first unlabeled text and the target label in at least one label is obtained, and according to the similarity between each first unlabeled text and the target label, at least one first unlabeled text whose similarity meets the first preset condition is obtained to form the first text set corresponding to the target label. The first preset condition can be that the similarity is greater than a first preset threshold, or that the sequence number of the first unlabeled text is greater than the first preset sequence number according to the order of similarity from large to small, or other conditions set by relevant personnel as needed.

[0058] For example, the SBERT model is used to obtain the vector embedding representation of the first unlabeled text X and the label D, and then the cosine similarity between each first unlabeled text X and the label D is calculated; according to the value of the cosine similarity between each first unlabeled text X and the label D, at least one first unlabeled text X is sorted in descending order; for each label D, the first labeled text of c = a|X| / k is selected as the first text set S of each label D j , where |X| is the total number of at least one unlabeled text, k is the number of at least one label D, and a is an arbitrary value, for example, a is 0.1.

[0059] S203 . According to at least one first text set, obtain a target text set corresponding to each first text set from a database.

[0060] A target text set corresponding to each first text set is obtained according to the similarity between each first unlabeled text in the first text set and each second unlabeled text in the database.

[0061] Specifically, the similarity between the first target unlabeled text in the first text set and each second unlabeled text in the database is obtained; based on the similarity between each second unlabeled text and the first target unlabeled text, at least one second unlabeled text whose similarity meets the second preset condition is formed into a second text set corresponding to the first target unlabeled text, thereby obtaining at least one second text set corresponding to the first text set; and at least one second unlabeled text in at least one second text set corresponding to the first text set that meets the third preset condition is used as the target text set corresponding to the first text set.

[0062] In one embodiment, the second preset condition may be that the similarity is greater than a second preset threshold, or that the sequence number of the second unlabeled text is greater than the second preset sequence number in descending order of similarity, or other conditions set as needed by relevant personnel; the third preset condition is that it appears simultaneously in at least one second text set corresponding to two or more first text sets, or other conditions set as needed by relevant personnel.

[0063] For example, we also use the SBERT model to obtain the first text set S for each label D j and the vector embedding representation between each second unlabeled text in the database U, where the database U is an available public dataset that is irrelevant to the training task; for each first text set S for each label D j Each first unlabeled text S in ji , use the nearest neighbor algorithm to retrieve each first unlabeled text S ji The n nearest neighbors of , the c nearest neighbor sets corresponding to each label D are obtained as the second text set, and the second unlabeled texts that appear in two or more second text sets are retained as the second unlabeled texts of the target text set.

[0064] In one embodiment, at least one second unlabeled text in at least one second text set corresponding to a first text set that meets a third preset condition is used as a target text set corresponding to the first text set, including: using at least one second unlabeled text in at least one second text set corresponding to the first text set that meets the third preset condition as a third text set corresponding to the first text set, and segmenting the third text set at different granularities according to the similarity between each second unlabeled text in the third text set and other unlabeled texts, to obtain at least one target text set corresponding to the first text set.

[0065] The second unlabeled text retrieved from database U may contain (close to) the first unlabeled text. For example, many news media may report the same story, but the narrative style may be different. Duplicate documents may lead to overfitting because they overemphasize a few documents and reduce the overall diversity of pseudo-labeled training data. Therefore, this application applies the facility location function to quantify the diversity of a target text set.

[0066] Specifically, the c nearest neighbor sets corresponding to each label D are used as the second text set, and the second unlabeled texts that appear in two or more second text sets are retained as the third text set R. j , that is, the neighbor set R j , each third text set R will be obtained through the facility function j The corresponding subsets L of different granularities j :

[0067]

[0068] Where s is the cosine similarity between the first unlabeled text and the second unlabeled text in the third text set, and x is a manually set parameter that represents the size of the subset. By setting the size of x, multiple subsets L can be obtained. j , multiple subsets L j As the target text set corresponding to each label.

[0069] like Figure 4 As shown, Figure 4 This is a schematic diagram of a process for obtaining a target text set based on a label, provided in this application. Based on label 201, multiple first unlabeled texts 301 corresponding to label 201 are obtained through semantic similarity. For example, label 201 corresponds to first unlabeled text 301, first unlabeled text 302, and first unlabeled text 303, and the multiple first unlabeled texts serve as first text set 300.

[0070] Furthermore, based on the phonetic similarity between each first unlabeled text and the second unlabeled text in the database, a second text set 401 corresponding to each first unlabeled text is obtained, for example, the first unlabeled text 301 corresponds to the second text set 401, the first unlabeled text 302 corresponds to the second text set 402, and the first unlabeled text 303 corresponds to the second text set 403.

[0071] Furthermore, the second unlabeled text that satisfies the third preset condition, that is, appears in two or more second text sets at the same time, is used as the text of the target text set 500, thereby obtaining the target text set 500 corresponding to the label 201. Figure 4The process shown is to obtain the target text set corresponding to each label.

[0072] In one embodiment, based on Figure 4 In the process shown, after obtaining the second text set corresponding to each label, at least one second unlabeled text in at least one second text set corresponding to the first text set that meets the third preset condition is also used as a third text set corresponding to the first text set. Based on the similarity between each second unlabeled text in the third text set and other unlabeled texts, the third text set is segmented at different granularities to obtain at least one target text set corresponding to the first text set. For example, label 201 corresponds to three target text sets, the first target text set includes the second unlabeled text 501, the second target text set includes the second unlabeled text 503, and the third target text set includes the second unlabeled text 501 and the second unlabeled text 503.

[0073] S204: training a text classification model according to each label and the target text set corresponding to each label until the text classification model converges.

[0074] When there are multiple target text sets corresponding to each label, and at least one second unlabeled text included in each target text set corresponding to the label is not completely identical to other target text sets, how to select a target text set of appropriate size to train the text classification model is also a problem that needs to be solved.

[0075] This application uses the maximum entropy method combined with grid search to complete the training of the final target text set and text classification model. The maximum entropy principle means that when learning a probability model, the model with the largest entropy is the best model among all possible probability models (i.e., probability distribution). Specifically, a text classification model is trained based on each label and multiple target text sets corresponding to the label to obtain multiple text classification models that have been trained to convergence; the target text classification model among the multiple text classification models that have been trained to convergence is determined by the maximum entropy method.

[0076] For example, using grid search, setting different nearest neighbor numbers n and target text set granularity x will yield n × x combinations. By training n × x text classification models, the entropy of the classification results obtained by each text classification model is calculated. The text classification model with the highest entropy value, corresponding to n and x, is selected as the optimal target text set. This text classification model is then used as the target text classification model to obtain the final classification result. For example, setting n = {100, 200, 300} and x = {300, 500, 800} for a total of nine combinations. The text classification model with the highest entropy obtained from training text classification models is then used as the target text classification model.

[0077] like Figure 5 As shown, Figure 5It is a flowchart of a training method for a text classification model provided by the present application. According to the Semantic Similarity between the label Class Descriptions and the first unlabeled text Unlabeled Documents, a first text set (seed text set) Seed Documents corresponding to each label Class Descriptions is obtained; further, according to the Semantic Similarity between the first text set (seed text set) Seed Documents, a second text set (nearest neighbor text set) Pseudo-LabeledDocuments corresponding to the first text set (seed text set) Seed Documents is obtained from the database (external text) External Documents; further, the second text set (nearest neighbor text set) Pseudo-LabeledDocuments is subjected to Subset Selection processing of different granularities to obtain multiple target text sets (nearest neighbor text sets) Pseudo-LabeledDocuments, that is, multiple target text sets (nearest neighbor text sets) Pseudo-LabeledDocuments corresponding to the label Class Descriptions. Documents; further, the text classification model is trained based on multiple target text sets (nearest neighbor text sets) Pseudo-LabeledDocuments to obtain multiple text classification models CandidateClassifiers, and the text classification model Classifiers with the highest entropy is selected as the training result through the maximum entropy method Entropy maximization.

[0078] This application obtains a target text set corresponding to each label from a database based on at least one label and at least one first unlabeled text provided for a training task of a text classification model, thereby training a text classification model through multiple unlabeled texts in the target text set and the corresponding labels. Compared with the method of expanding each label and training the text classification model based on the expanded label and at least one first unlabeled text, the training method proposed in this application no longer depends on the quality of the label, and guarantees the training effect of the text classification model, and even the classification effect of the text classification model after the training is completed; at the same time, this application does not require large-scale training data, and only achieves better training effects through a small number of databases, and shortens the training time.

[0079] The following are device embodiments of the present application, which can be used to implement the method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.

[0080] See Figure 6 , which shows a schematic diagram of the structure of a text classification model training device provided by an exemplary embodiment of the present application. The text classification model training device can be implemented as all or part of the device through software, hardware, or a combination of both. The text classification model training device includes a first acquisition module 601, a second acquisition module 602, and a model training module 603.

[0081] A first acquisition module 601 is configured to acquire at least one label and at least one first unlabeled text;

[0082] A second acquisition module 602 is configured to acquire a target text set corresponding to each tag from a database according to at least one tag and at least one first unlabeled text;

[0083] The model training module 603 is configured to train the text classification model according to each of the labels and the target text set corresponding to the labels until the text classification model converges.

[0084] In one embodiment, the second acquisition module 602 includes:

[0085] A first acquiring unit is configured to acquire, based on at least one of the tags, a first text set corresponding to each of the tags, wherein the first text set includes at least one of the first unlabeled texts;

[0086] The second acquiring unit is configured to acquire, from the database according to each of the first text sets, a target text set corresponding to each of the first text sets.

[0087] In one embodiment, the first acquiring unit includes:

[0088] A first acquisition subunit, configured to acquire a similarity between each first unlabeled text and a target label in the at least one label;

[0089] The second acquisition subunit is configured to obtain, based on the similarity between each first unlabeled text and the target label, at least one first unlabeled text whose similarity satisfies a first preset condition to form a first text set corresponding to the target label.

[0090] In one embodiment, the second acquiring unit includes:

[0091] A third acquisition subunit is configured to acquire a similarity between a first target unlabeled text in the first text set and each second unlabeled text in the database;

[0092] A fourth acquisition subunit is configured to, based on the similarity between each second unlabeled text and the first target unlabeled text, group at least one second unlabeled text whose similarity satisfies a second preset condition into a second text set corresponding to the first target unlabeled text, thereby obtaining at least one second text set corresponding to the first text set;

[0093] The fifth acquiring subunit is configured to use at least one second unlabeled text that meets a third preset condition in at least one second text set corresponding to the first text set as a target text set corresponding to the first text set.

[0094] In one embodiment, the third preset condition is that the third preset condition appears simultaneously in at least one second text set corresponding to two or more first text sets.

[0095] In one embodiment, the fourth acquiring subunit is specifically configured to:

[0096] taking at least one second unlabeled text that meets a third preset condition in at least one second text set corresponding to the first text set as a third text set corresponding to the first text set;

[0097] The third text set is segmented at different granularities according to the similarity between each second unlabeled text and other unlabeled texts in the third text set to obtain at least one target text set corresponding to the first text set.

[0098] In one embodiment, there are multiple target text sets corresponding to each of the labels, and at least one second unlabeled text included in each of the target text sets corresponding to the label is not completely identical to that in the other target text sets;

[0099] The model training module 603 includes:

[0100] A first training unit is configured to train the text classification model according to each of the labels and a plurality of target text sets corresponding to the labels, to obtain a plurality of text classification models trained to convergence;

[0101] The second training unit is used to determine a target text classification model among multiple text classification models trained to convergence by using a maximum entropy method.

[0102] This application obtains a target text set corresponding to each label from a database based on at least one label and at least one first unlabeled text provided for a training task of a text classification model, thereby training a text classification model through multiple unlabeled texts in the target text set and the corresponding labels. Compared with the method of expanding each label and training the text classification model based on the expanded label and at least one first unlabeled text, the training method proposed in this application no longer depends on the quality of the label, and guarantees the training effect of the text classification model, and even the classification effect of the text classification model after the training is completed; at the same time, this application does not require large-scale training data, and only achieves better training effects through a small number of databases, and shortens the training time.

[0103] It should be noted that the text classification model training device provided in the above embodiment only uses the division of the above functional modules as an example when executing the text classification model training method. In actual applications, the above functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above. In addition, the text classification model training device provided in the above embodiment and the text classification model training method embodiment are based on the same concept. The implementation process is detailed in the method embodiment and will not be repeated here.

[0104] The above serial numbers of this application are for description only and do not represent the advantages or disadvantages of the embodiments.

[0105] The present application also provides a computer storage medium, which can store multiple instructions, which are suitable for being loaded and executed by a processor as described above. Figure 1-Figure 5 The training method of the text classification model in the embodiment shown, the specific execution process can be found in Figure 1-Figure 5 The detailed description of the illustrated embodiment will not be repeated here.

[0106] The present application also provides a computer program product, which stores at least one instruction, and the at least one instruction is loaded and executed by the processor as described above. Figure 1-Figure 5 The training method of the text classification model in the embodiment shown, the specific execution process can be found in Figure 1-Figure 5 The detailed description of the illustrated embodiment will not be repeated here.

[0107] See Figure 7 , provides a structural diagram of an electronic device for this application. Figure 7 As shown, the electronic device 700 may include: at least one processor 701 , at least one network interface 704 , a user interface 703 , a memory 705 , and at least one communication bus 702 .

[0108] The communication bus 702 is used to implement the connection and communication between these components.

[0109] The user interface 703 may include a display screen (Display) and a camera (Camera). Optionally, the user interface 703 may also include a standard wired interface and a wireless interface.

[0110] The network interface 704 may optionally include a standard wired interface or a wireless interface (such as a WI-FI interface).

[0111] The processor 701 may include one or more processing cores. The processor 701 utilizes various interfaces and lines to connect the various components within the server 700. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 705, and calling data stored in the memory 705, the processor 701 executes various functions of the server 700 and processes data. Optionally, the processor 701 may be implemented in at least one hardware form of a digital signal processing (DSP), a field-programmable gate array (FPGA), or a programmable logic array (PLA). The processor 701 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the display; and the modem is used to handle wireless communications. It is understood that the modem may not be integrated into the processor 701 and may be implemented separately on a single chip.

[0112] Among them, the memory 705 may include a random access memory (RAM) or a read-only memory (Read-Only Memory). Optionally, the memory 705 includes a non-transitory computer-readable storage medium. The memory 705 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 705 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 705 may also be optionally at least one storage device located away from the aforementioned processor 701. As Figure 7 As shown, the memory 705 as a computer storage medium may include an operating system, a network communication module, a user interface module and an application program.

[0113] exist Figure 7 In the electronic device 700 shown, the user interface 703 is mainly used to provide an input interface for the user and obtain user input data; and the processor 701 can be used to call the training application of the text classification model stored in the memory 705 and specifically perform the following operations:

[0114] Obtain at least one label and at least one first unlabeled text;

[0115] According to at least one of the tags and at least one of the first unlabeled texts, acquiring a target text set corresponding to each of the tags from a database;

[0116] The text classification model is trained according to each of the labels and the target text set corresponding to the label until the text classification model converges.

[0117] In one embodiment, the processor 701 performs the step of obtaining, from a database, a target text set corresponding to each tag based on at least one tag and at least one first unlabeled text, by specifically performing:

[0118] According to at least one of the tags, obtaining a first text set corresponding to each of the tags, wherein the first text set includes at least one of the first unlabeled texts;

[0119] According to each of the first text sets, a target text set corresponding to each of the first text sets is acquired from the database.

[0120] In one embodiment, the processor 701 executes, according to the at least one tag, obtaining the first text set corresponding to each tag, by specifically performing:

[0121] Obtaining a similarity between each first unlabeled text and a target label in the at least one label;

[0122] According to the similarity between each first unlabeled text and the target label, at least one first unlabeled text whose similarity meets a first preset condition is obtained to form a first text set corresponding to the target label.

[0123] In one embodiment, the processor 701 executes the step of obtaining a target text set corresponding to each first text set from the database according to each first text set, specifically executing

[0124] Obtaining a similarity between a first target unlabeled text in the first text set and each second unlabeled text in the database;

[0125] According to the similarity between each second unlabeled text and the first target unlabeled text, at least one second unlabeled text whose similarity meets a second preset condition is combined into a second text set corresponding to the first target unlabeled text, thereby obtaining at least one second text set corresponding to the first text set;

[0126] At least one second unlabeled text in at least one second text set corresponding to the first text set that meets a third preset condition is used as a target text set corresponding to the first text set.

[0127] In one embodiment, the third preset condition is that the third preset condition appears simultaneously in at least one second text set corresponding to two or more first text sets.

[0128] In one embodiment, the processor 701 executes the method of using at least one second unlabeled text that meets the third preset condition in at least one second text set corresponding to the first text set as the target text set corresponding to the first text set, specifically performing:

[0129] taking at least one second unlabeled text that meets a third preset condition in at least one second text set corresponding to the first text set as a third text set corresponding to the first text set;

[0130] The third text set is segmented at different granularities according to the similarity between each second unlabeled text and other unlabeled texts in the third text set to obtain at least one target text set corresponding to the first text set.

[0131] In one embodiment, there are multiple target text sets corresponding to each of the labels, and at least one second unlabeled text included in each of the target text sets corresponding to the label is not completely identical to that in the other target text sets;

[0132] The processor 701 executes the training of the text classification model according to each of the labels and the target text set corresponding to the labels until the text classification model converges, specifically performing:

[0133] Training the text classification model according to each of the labels and the multiple target text sets corresponding to the labels to obtain multiple text classification models trained to convergence;

[0134] A target text classification model is determined among multiple text classification models trained to convergence using the maximum entropy method.

[0135] This application obtains a target text set corresponding to each label from a database based on at least one label and at least one first unlabeled text provided for a training task of a text classification model, thereby training a text classification model through multiple unlabeled texts in the target text set and the corresponding labels. Compared with the method of expanding each label and training the text classification model based on the expanded label and at least one first unlabeled text, the training method proposed in this application no longer depends on the quality of the label, and guarantees the training effect of the text classification model, and even the classification effect of the text classification model after the training is completed; at the same time, this application does not require large-scale training data, and only achieves better training effects through a small number of databases, and shortens the training time.

[0136] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware through a computer program. The program can be stored in a computer-readable storage medium, and when executed, the program can include the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory, or a random access memory.

[0137] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.

Claims

1. A training method for a text classification model, characterized in that: The method comprises: Obtain at least one label and at least one first unlabeled text; According to at least one of the tags and at least one of the first unlabeled texts, acquiring a target text set corresponding to each of the tags from a database; Training the text classification model according to each of the labels and the target text set corresponding to the label until the text classification model converges; The acquiring, from a database according to at least one of the tags and at least one of the first unlabeled texts, a target text set corresponding to each of the tags includes: According to at least one of the tags, obtaining a first text set corresponding to each of the tags, wherein the first text set includes at least one of the first unlabeled texts; According to each of the first text sets, acquiring a target text set corresponding to each of the first text sets from the database; Wherein, obtaining the first text set corresponding to each tag according to at least one tag includes: Obtaining a similarity between each first unlabeled text and a target label in the at least one label; According to the similarity between each first unlabeled text and the target label, at least one first unlabeled text whose similarity meets a first preset condition is obtained to form a first text set corresponding to the target label; The step of acquiring a target text set corresponding to each first text set from the database according to each first text set includes: Obtaining a similarity between a first target unlabeled text in the first text set and each second unlabeled text in the database; According to the similarity between each second unlabeled text and the first target unlabeled text, at least one second unlabeled text whose similarity meets a second preset condition is combined into a second text set corresponding to the first target unlabeled text, thereby obtaining at least one second text set corresponding to the first text set; At least one second unlabeled text in at least one second text set corresponding to the first text set that meets a third preset condition is used as a target text set corresponding to the first text set.

2. The training method according to claim 1, characterized in that The third preset condition is that the condition appears simultaneously in at least one second text set corresponding to two or more first text sets.

3. The training method according to claim 1, characterized in that The method of using at least one second unlabeled text that meets a third preset condition in at least one second text set corresponding to the first text set as a target text set corresponding to the first text set includes: taking at least one second unlabeled text that meets a third preset condition in at least one second text set corresponding to the first text set as a third text set corresponding to the first text set; The third text set is segmented at different granularities according to the similarity between each second unlabeled text and other unlabeled texts in the third text set to obtain at least one target text set corresponding to the first text set.

4. The training method according to claim 1, characterized in that There are multiple target text sets corresponding to each of the labels, and at least one second unlabeled text included in each of the target text sets corresponding to the label is not completely identical to that in the other target text sets; The step of training the text classification model according to each of the labels and the target text set corresponding to the labels until the text classification model converges includes: Training the text classification model according to each of the labels and the multiple target text sets corresponding to the labels to obtain multiple text classification models trained to convergence; A target text classification model is determined among multiple text classification models trained to convergence using the maximum entropy method.

5. A training device for a text classification model, characterized in that: The device comprises: A first acquisition module, configured to acquire at least one label and at least one first unlabeled text; A second acquisition module is configured to acquire a target text set corresponding to each tag from a database according to at least one tag and at least one first unlabeled text; A model training module, configured to train the text classification model according to each of the labels and the target text set corresponding to the labels until the text classification model converges; The second acquisition module includes: A first acquiring unit is configured to acquire, based on at least one of the tags, a first text set corresponding to each of the tags, wherein the first text set includes at least one of the first unlabeled texts; a second acquiring unit, configured to acquire, from the database, a target text set corresponding to each of the first text sets based on each of the first text sets; The first acquiring unit includes: A first acquisition subunit, configured to acquire a similarity between each first unlabeled text and a target label in the at least one label; A second acquisition subunit is configured to obtain, based on the similarity between each first unlabeled text and the target label, at least one first unlabeled text whose similarity satisfies a first preset condition to form a first text set corresponding to the target label; The second acquiring unit includes: A third acquisition subunit is configured to acquire a similarity between a first target unlabeled text in the first text set and each second unlabeled text in the database; A fourth acquisition subunit is configured to, based on the similarity between each second unlabeled text and the first target unlabeled text, group at least one second unlabeled text whose similarity satisfies a second preset condition into a second text set corresponding to the first target unlabeled text, thereby obtaining at least one second text set corresponding to the first text set; The fifth acquiring subunit is configured to use at least one second unlabeled text that meets a third preset condition in at least one second text set corresponding to the first text set as a target text set corresponding to the first text set.

6. A computer storage medium storing a plurality of instructions, wherein the instructions are suitable for being loaded by a processor and executing the method steps according to any one of claims 1 to 4.

7. An electronic device, characterized in that: include: A processor and a memory; wherein the memory stores a computer program, and the computer program is suitable for being loaded by the processor and executing the method steps according to any one of claims 1 to 4.

Citation Information

Patent Citations

  • Semi-supervised text classification model training method, text classification method, system, device and medium

    CN111723209A

  • Classification model training method and device, electronic equipment and storage medium

    CN112560912A