A method, device and equipment for training a classification model, and a storage medium
By combining N first-type and N second-type texts in pairs to determine the target sample set and train the model, the problem of poor text classification performance is solved, and higher classification accuracy and recall are achieved.
Patent Information
- Application Number
- CN201910770153.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2019-08-20
- Publication Date
- 2026-11-20
- Estimated Expiration
- 2039-08-20
AI Technical Summary
Existing text classification methods suffer from poor classification performance when dealing with massive amounts of text that lack sufficient differentiation between different text types, resulting in low classification accuracy and recall.
By acquiring N texts of type 1 and N texts of type 2, pairwise combinations are formed to create target text pairs. The target sample set is determined based on the text type. Algorithms such as logistic regression, support vector machine, or extreme gradient boosting are used for training to generate a trained target model for classification.
It improves the accuracy and recall of text classification, achieving accurate text classification.
Smart Images

Figure CN110457481B_ABST
Abstract
Description
Technical Field
[0001] This application relates to training model generation technology in the field of computer science, specifically to a method, apparatus, device, and storage medium for training a classification model. Background Technology
[0002] With the development of the internet and the progress of the times, massive amounts of text information are publicly published on platforms for users to search and read. In order to create a good search platform for users, it is necessary to distinguish the text types, that is, to use computers to automatically classify text sets according to a certain classification system or standard and mark each type of text.
[0003] Currently, there is a method for classifying massive amounts of text information. This method treats each text as an independent sample and labels positive and negative samples using two methods: manual annotation and positive unlabeled learning (PU-learning). It then extracts the corresponding features of the positive and negative samples to generate a classification model, which is used to classify new texts.
[0004] However, when there are a massive amount of text types, if the distinction between texts cannot be made by extracting features, the current classification model will not perform well in classifying texts. Summary of the Invention
[0005] This application provides a method, apparatus, device, and storage medium for training a classification model, which can achieve accurate text classification, improving both the accuracy and recall of text classification.
[0006] In a first aspect, embodiments of this application provide a method for training a classification model, including:
[0007] Obtain N texts of type 1 and N texts of type 2, where N is a positive integer;
[0008] The N texts of the first type or the N texts of the second type are combined in pairs to obtain at least one target text pair;
[0009] The target sample set is determined based on the types of the two texts in the target text pair;
[0010] A preset training operation is performed on the target sample set to obtain a trained target model, which is used to classify text.
[0011] Secondly, embodiments of this application provide a classification model training apparatus, which includes:
[0012] The acquisition unit is used to acquire N texts of the first type and N texts of the second type, where N is a positive integer;
[0013] A combination unit is used to combine the N first-type texts or the N second-type texts acquired by the acquisition unit in pairs to obtain at least one target text pair;
[0014] A determining unit is configured to determine a target sample set based on the types of the two texts in the target text pair obtained by the combining unit;
[0015] The training unit is used to perform a preset training operation on the target sample set determined by the determining unit to obtain a trained target model, which is used to classify text.
[0016] In one possible design, in a first possible implementation of the second aspect of the embodiments of this application, the determining unit includes:
[0017] The judgment module is used to determine whether the two texts in the target text pair are of the same type.
[0018] The first determining module is used to determine the target text pair as a positive sample when the determining module determines that the two texts in the target text pair are of the first type or the second type.
[0019] The second determining module is used to determine the target text pair as a negative sample if the determining module determines that the two texts in the target text pair are a combination of the first type and the second type.
[0020] The third determining module is used to determine a target sample set based on the positive samples determined by the first determining module and the negative samples determined by the second determining module.
[0021] In one possible design, in a second possible implementation of the second aspect of the embodiments of this application, the training unit includes:
[0022] The acquisition module is used to acquire feature information of two texts in any target text pair in the target sample set, and obtain first feature information and second feature information respectively.
[0023] The calculation module is used to calculate the feature similarity between the first feature information and the second feature information of the acquisition module to obtain the feature values of the target text pair;
[0024] The training module is used to train the target model by using the feature values of the target text pair calculated by the calculation module.
[0025] In one possible design, in a second possible implementation of the second aspect of the embodiments of this application, the acquisition module includes:
[0026] The word segmentation submodule is used to segment the two texts in the target text pair into words respectively, to obtain the first text sequence after word segmentation and the second text sequence after word segmentation.
[0027] The calculation submodule is used to determine the first word vector corresponding to each word in the first text sequence after word segmentation obtained by the word segmentation submodule, and the second word vector corresponding to each word in the second text sequence after word segmentation obtained by the word segmentation submodule;
[0028] The statistics submodule is used to calculate the first average value of the first word vector obtained by the calculation submodule in the K-dimensional vector space, and to calculate the second average value of the second word vector obtained by the calculation submodule in the K-dimensional vector space, where K is an integer greater than 2;
[0029] A determination submodule is used to take the first average value obtained by the statistics submodule as the first feature information and the second average value obtained by the statistics submodule as the second feature information.
[0030] In one possible design, in a third possible implementation of the second aspect of the embodiments of this application, the classification model training device further includes:
[0031] The first annotation unit is used to annotate the positive sample with a first label after the first determining module determines that the target text pair is a positive sample. The first label is used to indicate the type of the positive sample.
[0032] In one possible design, in a fourth possible implementation of the second aspect of the embodiments of this application, the classification model training device further includes:
[0033] The second annotation unit is used to annotate the positive sample with a first label after the second determining module determines that the target text pair is a positive sample. The first label is used to indicate the type of the positive sample.
[0034] In one possible design, in the fifth possible implementation of the second aspect of the embodiments of this application, the classification model training device further includes:
[0035] An extraction unit is configured to extract a first stop word from the first type of text and a second stop word from the second type of text after the acquisition unit acquires N texts of the first type and N texts of the second type;
[0036] A filtering unit is used to filter the first stop word and the second stop word extracted by the extraction unit.
[0037] Thirdly, embodiments of this application provide a classification model training device, which includes:
[0038] This includes: input / output (I / O) interfaces, processor, and memory.
[0039] The memory stores program instructions;
[0040] The processor is used to execute program instructions stored in memory to implement the method as described in the first aspect and any possible implementation of the first aspect.
[0041] The fourth aspect of this application provides a computer-readable storage medium storing computer-executable instructions for performing a method as described in the first aspect or any possible implementation thereof.
[0042] A fifth aspect of this application provides a computer program product containing instructions that, when run on a computer or processor, cause the computer or processor to perform the method of any of the above aspects.
[0043] As can be seen from the above technical solutions, the embodiments of this application have the following advantages:
[0044] In this embodiment, after obtaining N texts of the first type and an equal number of N texts of the second type, at least one target text pair can be obtained by combining these N texts of the first type or N texts of the second type in pairs. The target sample set determined based on the types of the two texts in the target text pair is then trained to obtain a trained target model, enabling the trained target model to classify text. Therefore, by combining the texts of the first type or the second type in pairs, rather than training them as independent texts, this application maximizes the accuracy of text classification, improving both the accuracy and recall of text classification. Attached Figure Description
[0045] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0046] Figure 1 This is a schematic diagram illustrating a scenario where text is classified in an embodiment of this application;
[0047] Figure 2 This is a schematic diagram of an embodiment of the classification model training method provided in this application;
[0048] Figure 3 This is a schematic diagram of another embodiment of the classification model training method provided in this application;
[0049] Figure 4 This is a schematic diagram of one embodiment of the classification model training device provided in this application;
[0050] Figure 5 This is a schematic diagram of another embodiment of the classification model training device provided in this application;
[0051] Figure 6 This is a schematic diagram of another embodiment of the classification model training device provided in this application;
[0052] Figure 7 This is a schematic diagram of one embodiment of the classification model training device provided in this application. Detailed Implementation
[0053] This application provides a method, apparatus, device, and storage medium for training a classification model, which can achieve accurate text classification, improving both the accuracy and recall of text classification.
[0054] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0055] The terms "first," "second," "third," "fourth," etc. (if present) in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus. The naming or numbering of steps appearing in this application does not imply that the steps in the method flow must be performed in the chronological / logical order indicated by the naming or numbering. The execution order of named or numbered process steps can be changed according to the desired technical purpose, as long as the same or similar technical effect is achieved.
[0056] Machine learning (ML) is a multidisciplinary field involving probability theory, statistics, approximation theory, convex analysis, and algorithm complexity theory. It specifically studies how computers can simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their performance. Machine learning is the core of artificial intelligence and the fundamental way to endow computers with intelligence; its applications span all areas of artificial intelligence. Machine learning and deep learning typically include techniques such as artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and instructional learning. With the development of machine learning technology, its applications are increasingly appearing in various scenarios. For example, for a massive amount of text in a public account, machine learning can be used to classify the text, making it easier for users to find and read texts of interest.
[0057] In text classification, word vector calculation tools like word2vec are commonly used. Word2vec can be efficiently trained on dictionaries with millions of entries and datasets with hundreds of millions of entries, yielding word vectors. Word vectors effectively measure the similarity between words in a text and can measure the feature information of each text. Based on formulas such as cosine similarity, the similarity between the feature information of each text can be determined, and a relevant classification model can be built based on this similarity. For example... Figure 1 The image shown is a schematic diagram illustrating a scenario for text classification in an embodiment of this application. Figure 1As can be seen, the articles on this public account are diverse, including entertainment, sports, digital products, technology, fashion, and more. Within these broad categories, there are further subcategories, such as digital products, which may include articles on mobile phones, smart hardware, tablets, digital appliances, virtual reality, artificial intelligence, or automotive technology. When users want to quickly find and read articles they need, such as those on mobile phones within the digital products category, searching through the vast amount of articles on the public account one by one is inefficient. Currently, one approach treats each text as an independent sample, labeling it with either manual annotation or positive unlabeled learning (PU-learning) to identify positive and negative samples, extracting features from both to generate a classification model. This model is then used to classify new text. However, if the articles lack strong distinguishability, this classification method is ineffective.
[0058] Therefore, in order to solve the above problems, this application provides a method for training a classification model. This method can obtain N texts of the first type and an equal amount of texts of the second type, combine them in pairs to obtain target text pairs, determine the target sample set according to the types of the two texts in the target text pair, and further train the target sample set to obtain a target model. The target model is then used to classify the text.
[0059] It should be understood that the number of N described above is not limited in the embodiments of this application.
[0060] To facilitate a better understanding of the solutions proposed in the embodiments of this application, the specific processes in this embodiment are described below. Please refer to [link / reference]. Figure 2 This is a schematic diagram of an embodiment of the classification model training method provided in this application, the method including:
[0061] 201. Obtain N texts of type 1 and N texts of type 2.
[0062] In this embodiment, different types of text are readily available on online platforms, such as articles on entertainment, sports, digital technology, science and technology, fashion, etc. However, to enable users to quickly search for and read the articles they need, a classification model is required to automatically categorize the text on the online platform. Therefore, it is necessary to obtain N texts of a first type and N texts of a second type. The first type of text consists of texts that have been manually labeled with a certain type of text, while the second type of text consists of texts that have been labeled using PU-learning to categorize other types of text besides the manually labeled texts.
[0063] It should be noted that the number of texts in the first type described above is equal to the number of texts in the second type. That is, if N articles are obtained from the first type, then the number of articles in the second type must also be N. This facilitates the subsequent combination of texts and simplifies the classification operation.
[0064] 202. Combine N texts of type 1 or N texts of type 2 in pairs to obtain at least one target text pair.
[0065] In this embodiment, after obtaining N texts of the first type and an equal amount of texts of the second type, the N texts of the first type or the N texts of the second type can be randomly combined in pairs to obtain at least one target text pair.
[0066] It should be understood that randomly combining any two of the N first-type texts or N second-type texts can result in three possible target text pairs: First, the target text pair can be any two first-type texts randomly selected from the N first-type texts; second, the target text pair can be any two second-type texts randomly selected from the N second-type texts; third, the target text pair can be any one text selected from the N first-type texts and any one text selected from the N second-type texts, and then combined with each of the selected first-type and second-type texts. It should be noted that this application does not specifically limit the method of obtaining the target text pair—whether it is obtained by combining texts of the first type, the second type, or both.
[0067] 203. Determine the target sample set based on the types of the two texts in the target text pair.
[0068] In this embodiment, after obtaining the target text pair, the target sample set can be determined by the types of the two texts included in the target text pair. This means that after combining texts of different types, the type of the target text pair is determined from the types of the two texts in the combined target text pair, thereby determining whether the target sample set belongs to a specific type of text or a mixed type of text. It should be understood that the target sample set can include positive samples or negative samples. Positive samples are those obtained by labeling the target text pair with a first label, typically represented by "1". Similarly, negative samples are those obtained by labeling the target text pair with a second label, typically represented by "0".
[0069] 204. Perform preset training operations on the target sample set to obtain the trained target model, which is then used to classify text.
[0070] In this embodiment, after obtaining the target sample set, a preset training formula is executed on each sample in the target sample set. Specifically, the target sample set can be trained and evaluated using a logistic regression (LR), support vector machine (SVM), or extreme gradient boosting (XGBoost) model to obtain the trained target model. It should be understood that the area under the curve (AUC) of the trained target model is higher than a preset threshold before type prediction can be performed on unlabeled new samples. The AUC described above refers to the area under the receiver operating characteristic (ROC) curve.
[0071] It should be understood that, in other embodiments, after determining the target sample set, samples with a proportion of A can be randomly selected from the target sample set as the training set, and samples with a proportion of B can be selected as the evaluation set, where A+B=1 and A is greater than B; and the model can be trained on the training set using LR, SVM or XGBoost as described above to obtain the trained target model, and the model can be evaluated on the evaluation set.
[0072] In some embodiments, after obtaining N texts of the first type and an equal number of texts of the second type, first stop words in the texts of the first type and second stop words in the texts of the second type may be respectively extracted, and the extracted first stop words and second stop words are further filtered out. The described stop words are usually function words contained in human languages, which have no practical or specific meanings, for example, Chinese characters, conjunctions, prepositions, modal particles and the like that appear alone with an extremely high frequency, such as "de", "shi", "zai", etc., or may also be numbers, numeric characters, punctuation marks and the like. These stop words do not play a key role in text classification, so after the first stop words and the second stop words are extracted, they can be filtered through operations such as deletion, automatic ignoring, etc.
[0073] In addition, in another embodiment, after obtaining the texts of the first type and the equal number of texts of the second type, illegal data in each text may be filtered. The illegal data may include, but is not limited to, illegal characters, sensitive information, violence, etc., or texts with a text length less than 200 characters may be filtered out, so that excessive interference of junk information in the training process of the classification model is avoided, which affects the reliability of model training.
[0074] For ease of understanding, the specific processes in the embodiments of the present application will be further described in detail below, please refer to Figure 3 , Figure 3 which is a schematic diagram of another embodiment of the method for training a classification model provided in the embodiments of the present application.
[0075] 301. Obtain N texts of a first type and N texts of a second type.
[0076] In this embodiment, different types of texts can be seen everywhere on network platforms, such as entertainment-type articles, sports-type articles, digital-type articles, technology-type articles, fashion-type articles, etc. However, in order for users to quickly query and read articles in demand, it is necessary to establish a classification model to automatically classify texts on the network platforms. Therefore, it is necessary to obtain N texts of the first type and N texts of the second type. The texts of the first type are texts of a certain type that have been manually labeled, and the texts of the second type are texts of other types that have been labeled by a PU-learning method in addition to the manually labeled texts of the certain type described above.
[0077] It should be noted that the number of texts in the first type described above is equal to the number of texts in the second type. That is, if N articles are obtained from the first type, then the number of articles in the second type must also be N. This facilitates the subsequent combination of texts and simplifies the classification operation.
[0078] 302. Combine N texts of type 1 or N texts of type 2 in pairs to obtain at least one target text pair.
[0079] In this embodiment, after obtaining N texts of the first type and an equal amount of texts of the second type, the N texts of the first type or the N texts of the second type can be randomly combined in pairs to obtain at least one target text pair.
[0080] It should be understood that randomly combining any two of the N first-type texts or N second-type texts can result in three possible target text pairs: First, the target text pair can be any two first-type texts randomly selected from the N first-type texts; second, the target text pair can be any two second-type texts randomly selected from the N second-type texts; third, the target text pair can be any one text selected from the N first-type texts and any one text selected from the N second-type texts, and then combined with each of the selected first-type and second-type texts. It should be noted that this application does not specifically limit the method of obtaining the target text pair—whether it is obtained by combining texts of the first type, the second type, or both.
[0081] 303. Determine whether the two texts in the target text pair are of the same type.
[0082] In this embodiment, after obtaining the target text pair, the target sample set can be determined by the types of the two texts included in the target text pair. This means that after combining texts of different types, the type of the target text pair is determined from the types of the two texts in the combined target text pair. For example, for a given target text pair, assuming it is obtained by randomly combining two texts of N first type, the target sample set can be determined by judging whether the text type information is the same.
[0083] For example, suppose the target text pair is a random combination of text from the digital category, such as combining text from the "Mobile Phone" and "Tablet" categories. By obtaining the type information for "Mobile Phone" and "Tablet," we can determine if the text in these two categories has the same type. Clearly, both "Mobile Phone" and "Tablet" texts belong to the digital category, therefore their text types are the same. Or, suppose the target text pair is a random combination of text from the second type, namely the "Fashion" category labeled using PU-learning. Fashion texts generally include topics like makeup, beauty, and clothing matching. If we combine texts from the "Makeup" and "Clothing Matching" categories, we can determine if the text in these two categories has the same type by obtaining the type information for "Makeup" and "Clothing Matching." Clearly, both "Makeup" and "Clothing Matching" texts belong to the fashion category, therefore their text types are the same. Alternatively, the target text pair could be a random pairwise combination of text from the first type and text from the second type. For example, text from the "digital" category could be selected from the "mobile phone" category, and text from the "fashion" category could be selected from the "beauty" category. The "mobile phone" text could then be combined with the "beauty" text. By obtaining the type information of the "beauty" category and the "mobile phone" category, it could be determined whether the texts in these two categories are of the same type. Obviously, the "beauty" text belongs to the "fashion" category, while the "mobile phone" text belongs to the "digital" category. Therefore, the texts in these two categories are not of the same type.
[0084] 304. If both texts in the target text pair are of type 1 or type 2, then the target text pair is determined to be a positive sample.
[0085] In this embodiment, the described positive samples are samples obtained by labeling target text pairs with a first label, which can usually be represented by "1". For example, in step 303 above, it is obvious that the target text pair composed of text related to mobile phones and virtual reality is a positive sample; in addition, the target text pair composed of text related to beauty and clothing matching is also a positive sample.
[0086] It should be understood that in some other embodiments, after determining that the target text pair is a positive sample, it is necessary to label the positive sample with a first label. This is mainly for predicting the text type of new samples after training the target model, so that the new samples can be classified after predicting the text type of the new samples.
[0087] 305. If the two texts in the target text pair are of type 1 and type 2, then the target text pair is determined to be a negative sample.
[0088] In this embodiment, the negative samples described are samples obtained by labeling the target text pairs with a second label, which is usually represented by "0". For example, in step 303 above, it is clear that the target text pairs consisting of text related to mobile phones and text related to beauty products are negative samples.
[0089] It should be understood that in some other embodiments, after determining that the target text pair is a negative sample, it is necessary to use a second label to annotate the negative sample. This is mainly for predicting the text type of new samples after training the target model, so that the new samples can be classified after predicting the text type of the new samples.
[0090] It should be understood that there is no restriction on the execution order of steps 304 and 305 above.
[0091] 306. Determine the target sample set based on positive and negative samples.
[0092] In this embodiment, after obtaining positive and negative samples, it is possible to select both positive and negative samples as samples in the target sample set.
[0093] 307. For any target text pair in the target sample set, obtain the feature information of the two texts in the target text pair respectively, and obtain the first feature information and the second feature information.
[0094] In this embodiment, the feature information may include the importance of a word, the frequency of its occurrence, the number of texts, etc. In practical applications, it may also include information such as word similarity or substitutability. This embodiment does not impose specific limitations. It should be understood that the importance of word A in a certain text is directly proportional to the frequency of word A in that text, and inversely proportional to the number of texts containing word A in all texts of the first type.
[0095] In other embodiments, to obtain the feature information of the two texts in the target text pair separately, i.e., to obtain the first feature information and the second feature information, the two texts in the target text pair can be segmented into words to obtain the segmented first text sequence and the segmented second text sequence, such as obtaining A = {a1, a2, ..., an, ...} and B = {b1, b2, ..., bm, ...} respectively. Further, the first word vector corresponding to each word in the first text sequence is calculated using the Word2Vec algorithm, and the second word vector corresponding to each word in the second text sequence is calculated using the Word2Vec algorithm. Then, the first average value of the first word vector in the K-dimensional vector space is calculated, and the second average value of the second word vector in the K-dimensional vector space is calculated. The first average value is used as the first feature information, and the second average value is used as the second feature information. In other words, after obtaining the first and second text sequences after word segmentation, the Word2Vec algorithm maps the words in the text to at least a three-dimensional vector space. For each word appearing in the text, the average value of the word vector corresponding to that word in this at least three-dimensional vector space is calculated. This average value represents the vector corresponding to the text, i.e., the feature information of the text. Furthermore, the similarity in this at least three-dimensional vector space can be used to represent the semantic similarity of the words in the text.
[0096] 308. Calculate the feature similarity between the first feature information and the second feature information to obtain the feature values of the target text pair.
[0097] In this embodiment, the preset formula may include, but is not limited to, the following two formulas:
[0098] The first method, based on the cosine similarity formula, is as follows:
[0099]
[0100] in, Indicates the first feature information, This represents the second feature information.
[0101] The second method, based on the Euclidean distance formula, is as follows:
[0102]
[0103] Where X represents the first feature information, Y represents the second feature information, and N represents the dimension.
[0104] Therefore, after calculating the similarity between the first feature information and the second feature information based on the first or second formula mentioned above, the similarity can be used as the feature value S of the corresponding target text pair.
[0105] 309. By training the feature values of the target text pairs, the trained target model is obtained.
[0106] In this embodiment, after obtaining the feature values of the target sample set, the feature values of the target sample set can be trained and evaluated using LR, SVM, or XGBoost to obtain the trained target model. It should be understood that the area under the curve (AUC) of the trained target model is higher than a pre-set threshold before type prediction can be performed on unlabeled new samples. The AUC described above refers to the area under the receiver operating characteristic (ROC) curve.
[0107] In this embodiment, after obtaining N texts of the first type and an equal number of N texts of the second type, at least one target text pair can be obtained by combining these N texts of the first type or N texts of the second type in pairs. The target sample set determined based on the types of the two texts in the target text pair is then trained to obtain a trained target model, enabling the trained target model to classify text. Therefore, by combining the texts of the first type or the second type in pairs, rather than training them as independent texts, the target model trained in this application maximizes the accuracy of text classification, improving both the accuracy and recall of text classification.
[0108] The foregoing primarily describes the solutions provided by the embodiments of this application from a methodological perspective. It is understood that to achieve the above functions, corresponding hardware structures and / or software modules are included to execute each function. Those skilled in the art should readily recognize that, based on the modules and algorithm steps described in conjunction with the embodiments disclosed in this application, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0109] This application embodiment can divide the device into functional modules according to the above method example. For example, each function can be divided into its own functional module, or two or more functions can be integrated into one processing module. The integrated module can be implemented in hardware or as a software functional module. It should be noted that the module division in this application embodiment is illustrative and only represents one logical functional division. In actual implementation, there may be other division methods.
[0110] The classification model training device in the embodiments of this application is described in detail below. Please refer to [link / reference]. Figure 4 , Figure 4 This is a schematic diagram of an embodiment of the classification model training device provided in this application. The classification model training device may include:
[0111] Acquisition unit 401 is used to acquire N texts of the first type and N texts of the second type, where N is a positive integer;
[0112] The combination unit 402 is used to combine the N first-type texts or the N second-type texts acquired by the acquisition unit 401 in pairs to obtain at least one target text pair;
[0113] Determining unit 403 is used to determine a target sample set based on the types of the two texts in the target text pair obtained by combining unit 402;
[0114] The training unit 404 is used to perform a preset training operation on the target sample set determined by the determining unit 403 to obtain a trained target model, which is used to classify text.
[0115] Optionally, in the above Figure 4 Based on the corresponding embodiments, please refer to Figure 5 This is a schematic diagram of another embodiment of the classification model training device provided in this application. The determining unit 403 may include:
[0116] The judgment module 4031 is used to determine whether the two texts in the target text pair are of the same type;
[0117] The first determining module 4032 is used to determine the target text pair as a positive sample when the determining module 4031 determines that the two texts in the target text pair are of the first type or the second type.
[0118] The second determining module 4033 is used to determine the target text pair as a negative sample if the determining module 4031 determines that the two texts in the target text pair are a combination of the first type and the second type.
[0119] The third determining module 4034 is used to determine a target sample set based on the positive samples determined by the first determining module 4032 and the negative samples determined by the second determining module 4033.
[0120] Optionally, in the above Figure 4 or Figure 5 Based on the corresponding embodiments, please refer to Figure 6 This is a schematic diagram of another embodiment of the classification model training device provided in this application. The training unit 404 may include:
[0121] The acquisition module 4041 is used to acquire feature information of two texts in any target text pair in the target sample set, and obtain first feature information and second feature information.
[0122] The calculation module 4042 is used to calculate the feature similarity between the first feature information and the second feature information of the acquisition module 4041 to obtain the feature value of the target text pair;
[0123] The training module 4043 is used to train the target model by using the feature values of the target text pair calculated by the calculation module 4042.
[0124] Optionally, in the above Figure 6 Based on the corresponding embodiments, in another embodiment of the classification model training device provided in this application, the acquisition module 4041 includes: a word segmentation submodule, used to segment the two texts in the target text pair into words respectively, to obtain a first text sequence and a second text sequence after word segmentation; a calculation submodule, used to determine the first word vector corresponding to each word in the first text sequence after word segmentation obtained by the word segmentation submodule, and the second word vector corresponding to each word in the second text sequence after word segmentation obtained by the word segmentation submodule; a statistics submodule, used to calculate the first average value of the first word vector obtained by the calculation submodule in a K-dimensional vector space, and calculate the second average value of the second word vector obtained by the calculation submodule in the K-dimensional vector space, where K is an integer greater than 2; and a determination submodule, used to use the first average value obtained by the statistics submodule as the first feature information, and the second average value obtained by the statistics submodule as the second feature information.
[0125] Optionally, in the above Figure 5Based on the corresponding embodiments, in another embodiment of the classification model training device provided in this application, the classification model training device further includes: a first labeling unit, used to label the positive sample by a first label after the first determining module determines that the target text pair is a positive sample, wherein the first label is used to indicate the type of the positive sample.
[0126] Optionally, in the above Figure 5 Based on the corresponding embodiments, in another embodiment of the classification model training device provided in this application, the classification model training device further includes: a second labeling unit, used to label the positive samples by a first label after the second determining module determines that the target text pair is a positive sample, wherein the first label is used to indicate the type of the positive sample.
[0127] Optionally, in the above Figures 4 to 6 Based on any corresponding embodiment, in another embodiment of the classification model training device provided in this application, the classification model training device further includes: an extraction unit, configured to extract a first stop word from the first type of text and a second stop word from the second type of text after the acquisition unit acquires N first type of text and N second type of text; and a filtering unit, configured to filter the first stop word and the second stop word extracted by the extraction unit.
[0128] Therefore, by combining the first type of text or the second type of text in pairs through the combination unit 402, instead of training the first type of text or the second type of text as independent text, the target model trained in this application can maximize the accurate classification of text, which not only improves the accuracy of text classification, but also improves the recall rate of text classification.
[0129] The classification model training device in this application embodiment has been described above from the perspective of modular functional entities. The classification model training device in this application embodiment has been described below from the perspective of hardware processing. Figure 7 This is a schematic diagram of the structure of the classification model training device provided in the embodiments of this application. The classification model training device may include the classification model training apparatus described above. The classification model training device may vary greatly due to different configurations or performance. The classification model training device may include at least one processor 501, a communication line 507, a memory 503, and at least one communication interface 504.
[0130] The processor 501 may be a general-purpose central processing unit (CPU), a microprocessor, an application-specific integrated circuit (server IC), or one or more integrated circuits used to control the execution of the program of the present application.
[0131] Communication line 507 may include a path for transmitting information between the aforementioned components.
[0132] Communication interface 504 uses any transceiver-like device for communicating with other devices or communication networks, such as Ethernet, radio access network (RAN), wireless local area networks (WLAN), etc.
[0133] The memory 503 can be a read-only memory (ROM) or other type of static storage device that can store static information and instructions, a random access memory (RAM) or other type of dynamic storage device that can store information and instructions. The memory can exist independently and be connected to the processor via communication line 507. The memory can also be integrated with the processor.
[0134] The memory 503 stores computer execution instructions for implementing the scheme of this application, and its execution is controlled by the processor 501. The processor 501 executes the computer execution instructions stored in the memory 503, thereby implementing the classification model training method provided in the above embodiments of this application.
[0135] Optionally, the computer execution instructions in the embodiments of this application may also be referred to as application code, and the embodiments of this application do not specifically limit this.
[0136] In a specific implementation, as one example, the classification model training device may include multiple processors, for example... Figure 7 Processors 501 and 502 are shown in the diagram. Each of these processors may be a single-core (single-CPU) processor or a multi-core (multi-CPU) processor. A processor here may refer to one or more devices, circuits, and / or processing cores used to process data (e.g., computer program instructions).
[0137] In a specific implementation, as one example, the classification model training device may further include an output device 505 and an input device 506. The output device 505 communicates with the processor 501 and can display information in various ways. The input device 506 communicates with the processor 501 and can receive user input in various ways. For example, the input device 506 may be a mouse, a touch screen device, or a sensing device, etc.
[0138] The aforementioned classification model training device can be a general-purpose device or a dedicated device. In specific implementations, this classification model training device can be a desktop computer, a laptop computer, a NAS server, a wireless terminal device, an embedded device, or something similar. Figure 7 A device with a similar structure. The embodiments of this application do not limit the type of classification model training device.
[0139] In this embodiment of the application, the processor 501 included in the classification model training device also has the following functions:
[0140] Obtain N texts of type 1 and N texts of type 2, where N is a positive integer;
[0141] The N texts of the first type or the N texts of the second type are combined in pairs to obtain at least one target text pair;
[0142] The target sample set is determined based on the types of the two texts in the target text pair;
[0143] A preset training operation is performed on the target sample set to obtain a trained target model, which is used to classify text.
[0144] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0145] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, or indirect coupling or communication connection between apparatuses or units, and may be electrical, mechanical, or other forms.
[0146] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0147] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0148] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0149] The above embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.
Claims
1. A method for training a classification model, characterized in that, include: Obtain N texts of type 1 and N texts of type 2, where N is a positive integer. The texts of type 1 are texts that have been manually labeled by a preset type of text. The texts of type 2 are texts that have been labeled by a positive sample unlabeled learning method for texts of other types besides the preset types of texts labeled by a preset type. The articles of the category corresponding to the text contain articles of the specific category. The N texts of the first type or the N texts of the second type are combined in pairs to obtain at least one target text pair; The target sample set is determined based on the types of the two texts in the target text pair; For any target text pair in the target sample set, the two texts in the target text pair are segmented into words to obtain the first text sequence and the second text sequence after segmentation. The words obtained after segmentation are then mapped into a K-dimensional vector space. Determine the first word vector corresponding to each word in the first text sequence after word segmentation, and the second word vector corresponding to each word in the second text sequence after word segmentation; Calculate the first average value of the first word vector in the K-dimensional vector space, and calculate the second average value of the second word vector in the K-dimensional vector space, where K is an integer greater than 2; The first average value is used as the first feature information, and the second average value is used as the second feature information. Both the first feature information and the second feature information include at least one of the following: word importance, word occurrence frequency, number of texts, and word similarity or substitutability. The first feature information and the second feature information are used to calculate the feature similarity, and the feature similarity is used as the feature value of the target text pair; the similarity between the first feature information and the second feature information in the K-dimensional space represents the semantic similarity between the words in the two texts; The trained target model is obtained by training the feature values of the target text pairs, and the trained target model is used to classify text.
2. The method according to claim 1, characterized in that, Determining the target sample set based on the types of the two texts in the target text pair includes: Determine whether the two texts in the target text pair are of the same type; If both texts in the target text pair are of the first type or the second type, then the target text pair is determined to be a positive sample. If the two texts in the target text pair are of a combination of the first type and the second type, then the target text pair is determined to be a negative sample; The target sample set is determined based on the positive and negative samples.
3. The method according to claim 2, characterized in that, After determining that the target text pair is a positive sample, the process also includes: The positive samples are labeled with a first label, which indicates the type of the positive samples.
4. The method according to claim 2, characterized in that, After determining that the target text pair is a negative sample, the process also includes: The negative samples are labeled with a second label, which indicates the type of the negative sample.
5. The method according to any one of claims 1-4, characterized in that, After obtaining N texts of type 1 and N texts of type 2, the process also includes: Extract the first stop word from the text of the first type, and extract the second stop word from the text of the second type; Filter the first stop word and the second stop word.
6. A classification model training device, characterized in that, include: The acquisition unit is used to acquire N texts of the first type and N texts of the second type, where N is a positive integer. The texts of the first type are texts that have been manually labeled by a preset type of text. The texts of the second type are texts that have been labeled by a positive sample unlabeled learning method for other types of texts besides the preset types of texts that have been manually labeled. The articles of the category corresponding to the text contain articles of the specific category. A combination unit is used to combine the N first-type texts or the N second-type texts acquired by the acquisition unit in pairs to obtain at least one target text pair; A determining unit is configured to determine a target sample set based on the types of the two texts in the target text pair obtained by the combining unit; The training unit is used to segment two texts in any target text pair in the target sample set, respectively, to obtain a first text sequence and a second text sequence after segmentation, and to map the segmented words into a K-dimensional vector space. The process involves determining a first word vector for each word in the segmented first text sequence and a second word vector for each word in the segmented second text sequence; calculating a first average value of the first word vector in a K-dimensional vector space and a second average value of the second word vector in the same K-dimensional vector space, where K is an integer greater than 2; using the first average value as first feature information and the second average value as second feature information, where both feature information includes at least one of word importance, word frequency, number of texts, and word similarity or substitutability; calculating feature similarity between the first and second feature information and using this similarity as the feature value of the target text pair; the similarity between the first and second feature information in the K-dimensional space represents the semantic similarity of the words in the two texts; and training the feature values of the target text pair to obtain the trained target model, which is used for text classification.
7. A classification model training device, characterized in that, include: A processor and a memory are connected via a communication bus; wherein the processor is used to call and execute a program stored in the memory; The memory is used to store a program for implementing the method for training a classification model as described in any one of claims 1 to 5.
8. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for performing the method for training the classification model according to any one of claims 1 to 5.
Citation Information
Patent Citations
Small-sample polarized SAR ground feature classification method based on deep convolutional twin network
CN108388927A
