Unbalanced text multi-level classification method and device based on large model
By designing a two-layer classification framework and using a generative large language model to identify mutex tags, the problem of unbalanced data sets and label mutex in text classification is solved, and a more accurate multi-level text classification effect is achieved.
Patent Information
- Application Number
- CN202411806282.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-10
- Publication Date
- 2025-04-04
AI Technical Summary
In text classification tasks, the imbalance of the data set and the mutual exclusion between labels lead to bias during model training, making it difficult to effectively deal with multi-category text classification tasks.
A two-layer classification framework consisting of a multi-classification model of mutex labels and a non-mutex multi-classification model is designed. Through a generative large language model, augmentation of sample data is performed, and the corresponding classification model is trained to handle the dependencies between labels.
This method can handle the dependencies between labels more accurately, avoiding the mutex tags being wrongly predicted simultaneously, and effectively solves the problems of mutually exclusive tags and multi-label classification in unbalanced text multi-level classification.
Smart Images

Figure CN119760136A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of text classification, and in particular to a method and device for unbalanced text multi-level classification based on a large model. Background Art
[0002] In text classification tasks, dataset imbalance is a common and challenging problem. Usually, the number of samples in some categories is much larger than that in other categories. This unbalanced distribution will cause bias in model training, and the model tends to predict categories with more samples, thereby ignoring categories with fewer samples, affecting the overall performance of the model. In addition, in multi-category text classification tasks, in addition to the problem of data imbalance, there is also the problem of mutual exclusivity between labels. The existence of mutually exclusive labels requires that the model cannot select this label and other labels at the same time when predicting, which increases the complexity of model learning. Therefore, how to effectively solve these two problems has become a key topic in multi-category text classification research.
[0003] For the classification problem of unbalanced data sets, the invention patent with publication number CN114077864A proposes a two-stage resampling method for unbalanced data sets, which aims to balance the data set by combining SMOTE (synthetic minority class oversampling technology) with generative adversarial networks (CGAN) to improve the performance of the classifier on minority classes. Although this multi-category text classification method based on two-stage resampling has many advantages, there are also some potential disadvantages and challenges: when using generative adversarial networks (CGAN) to generate new samples, the quality of the generated samples may not be satisfactory. Although CGAN can learn the distribution of minority classes, the generated samples may be different from the real samples, or they may not fully capture the characteristics of minority classes. This may result in the generated samples not effectively improving the performance of the model, and may even introduce noise, affecting the training effect of the classifier. In addition, generative adversarial networks (CGAN) require a long training time and large computing resources, especially when the amount of training data is large or the generated network structure is complex.
[0004] For the classification problem of mutually exclusive labels. The invention patent with publication number CN109447102A proposes a method for calculating a loss function based on classification mutual exclusivity. This method further enhances the discrimination of the classifier when dealing with multi-classification tasks by introducing mutually exclusive penalty terms. Although mutually exclusive penalty terms can enhance the discrimination ability of the classifier when facing multi-category tasks, calculating the mutually exclusive penalty terms in the classification probability vector of each data point involves comparing and calculating the probabilities of different categories, which may increase the amount of calculation, especially when the number of categories is large. In addition, compared with traditional loss functions (such as cross entropy loss), the training process may become more complicated after the introduction of mutually exclusive penalty terms. Summary of the invention
[0005] In view of this, the present invention provides a method and device for multi-level classification of unbalanced text based on a large model. By designing a two-layer classification framework consisting of a mutually exclusive label multi-classification model and a non-mutually exclusive multi-label classification model, the mutually exclusive label multi-classification model is first used to determine whether the sample belongs to a certain type of text in the mutually exclusive labels, and then a decision is made whether to enter the non-mutually exclusive multi-label classification model based on the judgment result. This method can more accurately handle the dependency relationship between labels and avoid mutually exclusive labels being erroneously predicted at the same time.
[0006] A method for multi-level classification of imbalanced text based on a large model, specifically comprising the following steps:
[0007] S1, obtain unbalanced text data;
[0008] S2, using a generative large language model to identify the label of each sample in the unbalanced text data, obtaining a mutually exclusive label set based on the identification results and reconstructing the training sample data;
[0009] S3, label processing is performed on the training sample data according to the mutually exclusive label set, and a mutually exclusive label multi-classification model is trained using the label-processed training sample data;
[0010] According to the mutually exclusive label set, all sample data with non-mutually exclusive labels are screened out from the training sample data, and a non-mutually exclusive multi-label classification model is obtained by training all sample data with non-mutually exclusive labels;
[0011] S4, using mutually exclusive label multi-classification model or mutually exclusive label multi-classification model and non-mutually exclusive multi-label classification model to determine the label to which the text to be classified belongs.
[0012] Preferably, in step S2, the specific steps of using a generative large language model to identify the label of each sample in the unbalanced text data, obtaining a mutually exclusive label set according to the identification result, and reconstructing the training sample data are:
[0013] The generative large language model identifies the label of each sample in the unbalanced text data, and selects mutually exclusive labels based on the relationship and semantic difference between different labels to obtain a mutually exclusive label set;
[0014] The number of samples of each type of label is counted, and the generative large language model then enhances the sample data of labels with a small number of samples and adds the newly added sample data to the unbalanced text data to obtain training sample data.
[0015] Preferably, the generative large language model is GPT-4.
[0016] Preferably, each sample in the unbalanced text data corresponds to one or more labels.
[0017] Preferably, in step S3, when label processing is performed on the training sample data according to the mutually exclusive label set, the labels of all samples with non-mutually exclusive labels in the training sample data are uniformly set to the same value, and the labels of samples with mutually exclusive labels remain unchanged.
[0018] Preferably, in step S3, the specific steps of training the mutually exclusive label multi-classification model using the label-processed training sample data are as follows:
[0019] The multi-classification model is trained based on each sample and its corresponding label in the training sample data after label processing. The multi-classification model is used to determine whether the sample label is a mutually exclusive label. The mutually exclusive label training data input into the multi-classification model is recorded as D′={(x 1′ ,y 1′ ),(x 2′ ,y 2′ ),…,(x s′ ,y s′ )}, where x i′ is the i-th sample in the training set, y i′ is the label set corresponding to the i-th sample;
[0020] The multi-classification model outputs a text vector representation V for each sample i , and represent each sample’s vector V i Input the fully connected layer to obtain the text vector representation V of each sample i Mapped to the probability distribution O of its category ij ;
[0021] According to the true label y corresponding to each sample i′ and its text vector representation V i Mapped to the probability distribution O of its category ij , use the cross entropy function to calculate the function loss value of the mutually exclusive label multi-classification model, and use back propagation to calculate the gradient information based on the function loss value, and then update the model parameters based on the gradient information;
[0022] Repeat the above steps until the function loss value output by the mutually exclusive label multi-classification model converges.
[0023] Preferably, in step S3, the specific steps of training a non-mutually exclusive multi-label classification model using all sample data with non-mutually exclusive labels are:
[0024] The multi-label classification model is trained using all sample data with non-mutually exclusive labels and their corresponding labels. The non-mutually exclusive label training data input into the multi-label classification model is recorded as D″={(x 1″ ,y 1″ ),(x 2″ ,y2″ ),…,(x n″ ,y n″ )},x j″ is the jth sample with non-mutually exclusive labels, y j″ is the label set corresponding to the jth sample with non-mutually exclusive labels;
[0025] The multi-label classification model outputs a text vector representation V for each sample j And represent the text vector of each sample as V j Input the fully connected layer to obtain the text vector representation V of each sample j Mapped to the probability distribution O of its category ij ';
[0026] According to the true label y corresponding to each sample j″ and its text vector representation V j Mapped to the probability distribution O of its category ij ', using the binary cross entropy function to calculate the binary cross entropy loss value of each sample label, the function loss value of the non-mutually exclusive multi-label classification model is the average value of the binary cross entropy loss values of all sample labels;
[0027] The function loss value of the non-mutually exclusive multi-label classification model uses back propagation to calculate the gradient information, and then updates the model parameters based on the gradient information;
[0028] Repeat the above steps until the function loss value output by the non-mutually exclusive multi-label classification model converges.
[0029] Preferably, in step S4, the specific steps of using the mutually exclusive label multi-classification model or the mutually exclusive label multi-classification model and the non-mutually exclusive multi-label classification model to determine the label to which the text to be classified belongs are:
[0030] Input the text to be classified into the mutually exclusive label multi-classification model to determine whether the text to be classified belongs to a certain type of text in the mutually exclusive label. If it does, directly output the label corresponding to the text;
[0031] Otherwise, the text to be classified is continuously input into the non-mutually exclusive multi-label classification model, which predicts the probability values of all labels that the text to be classified may correspond to, and outputs the labels whose probability values exceed the set threshold.
[0032] Preferably, steps S1, S2 and S3 are performed offline, and step S4 is performed online.
[0033] A large model-based unbalanced text multi-level classification device, comprising an offline module and an online module;
[0034] The offline module is used to use a generative large language model to identify the label of each sample in the unbalanced text data, obtain a mutually exclusive label set according to the identification result and reconstruct the training sample data, and perform label processing on the training sample data according to the mutually exclusive label set, and use the label-processed training sample data to train a mutually exclusive label multi-classification model; according to the mutually exclusive label set, all sample data with non-mutually exclusive labels are screened out from the training sample data, and all sample data with non-mutually exclusive labels are trained to obtain a non-mutually exclusive multi-label classification model;
[0035] The online module is used to determine the label to which the to-be-classified text belongs by using a mutually exclusive label multi-classification model or a mutually exclusive label multi-classification model and a non-mutually exclusive multi-label classification model.
[0036] The beneficial effects of the present invention are:
[0037] The present invention uses a generative large language model to analyze unbalanced text data, identifies and screens out mutually exclusive label sets, and adds data to label categories with small sample sizes, and adds the generated new text to the unbalanced text data to form training sample data. The mutually exclusive label set and the training sample data are used to train a mutually exclusive label multi-classification model and a non-mutually exclusive multi-label classification model. The mutually exclusive label multi-classification model is first used to determine whether a sample to be classified belongs to a certain type of text in the mutually exclusive labels, and then a decision is made whether to enter the non-mutually exclusive multi-label classification model based on the determination result. The dependency relationship between labels can be processed more accurately, and mutually exclusive labels can be avoided from being mistakenly predicted at the same time, thereby effectively solving the problem of mutually exclusive labels and multi-label classification. BRIEF DESCRIPTION OF THE DRAWINGS
[0038] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0039] Figure 1 It is the flowchart of the offline module.
[0040] Figure 2 is the flowchart of the online module. DETAILED DESCRIPTION
[0041] In order to make the purpose, technical scheme and advantages of the present invention clearer, the present invention is described below by the specific embodiments shown in the accompanying drawings. However, it should be understood that these descriptions are only exemplary and are not intended to limit the scope of the present invention. In addition, in the following description, the description of well-known structures and technologies is omitted to avoid unnecessary confusion of the concept of the present invention.
[0042] The terms used in this disclosure are for the purpose of describing specific embodiments only and are not intended to limit the disclosure. The singular forms of "a", "said" and "the" used in this disclosure and the appended claims are also intended to include plural forms unless the context clearly indicates otherwise. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0043] In order to better understand the technical solution of the present invention, the present invention is described in detail below with reference to the accompanying drawings.
[0044] The present invention provides a multi-level classification method for imbalanced text based on a large model, which specifically includes the following steps:
[0045] S1, obtain unbalanced text data.
[0046] The unbalanced text data refers to sample text data containing multiple categories, but the number of sample texts in some categories is much larger than the number of sample texts in another category or several other categories.
[0047] The imbalanced text dataset can be represented as D = {(x1,y1),(x2,y2),…,(x s ,y s )}, where x i is the i-th sample in the training set, y i is the label set corresponding to the i-th sample. The label set corresponding to a single sample may contain one or more labels, that is, a single sample corresponds to one or more labels.
[0048] S2, using a generative large language model to identify the label of each sample in the unbalanced text data, obtains a mutually exclusive label set based on the recognition results and reconstructs the training sample data.
[0049] Specifically, the generative large language model identifies the label of each sample in the imbalanced text data, and selects mutually exclusive labels based on the relationship and semantic difference between different labels to obtain a mutually exclusive label set (a set of all mutually exclusive labels). Mutually exclusive labels refer to each label in a set of labels being mutually exclusive, that is, a given text segment can only be assigned one of the labels in this set. If it selects a label in this set of labels, it cannot select other labels in the same set at the same time. For example, in sentiment analysis, "positive", "negative" and "neutral" are three mutually exclusive labels, and a sentiment review cannot be both positive and negative at the same time.
[0050] Data analysis tools are used to analyze the unbalanced text data and count the number of samples of each type of label. Then, the generative large language model performs sample data enhancement on labels with small sample numbers and adds the newly added sample data to the unbalanced text data to obtain training sample data.
[0051] Generative large language models perform sample enhancement on labels with a small number of samples, which means automatically generating samples of the same label so that the number of samples of the label is balanced with the number of samples of other labels to balance the label category distribution.
[0052] After using a generative large language model to perform sample enhancement on labels with a small number of samples, in order to ensure the rationality and applicability of the newly added samples, the newly added sample data can be manually screened to eliminate unreasonable samples.
[0053] In this embodiment, the generative large language model selected is GPT-4. Of course, in other embodiments, other suitable models may also be selected.
[0054] S3, label processing is performed on the training sample data according to the mutually exclusive label set, and the mutually exclusive label multi-classification model is trained using the label-processed training sample data.
[0055] Specifically, the specific steps for training a mutually exclusive label multi-classification model are:
[0056] S31, build a mutually exclusive label multi-classification model: first build a BERT model, and then connect the fully connected layer to the output layer of the BERT model;
[0057] S32, according to the mutually exclusive label set, the labels of all samples with non-mutually exclusive labels in the training sample data obtained in step S2 are uniformly set to the same value, the labels of samples with mutually exclusive labels remain unchanged, and then the training sample data after label processing is divided into a training set and a test set;
[0058] S33, input the data in the training set into the BERT model, use the samples in the training set and their corresponding labels to train the BERT model to obtain a multi-classification model, and record the mutually exclusive label training data input into the multi-classification model as D′={(x 1′ ,y 1′ ),(x 2′ ,y 2′ ),…,(x s′ ,y s′ )}, where x i′ is the i-th sample in the training set, y i′ is the label set corresponding to the i-th sample;
[0059] It should be noted that the type of multi-classification model is determined by the number of labels in the mutually exclusive label set. If there is only one label in the mutually exclusive label set, the training obtained in this step is a binary classification model; if the mutually exclusive label set contains more than two mutually exclusive labels, the training obtained in this step is a multi-classification model;
[0060] The multi-classification model outputs a text vector representation V for each sample i ;
[0061] V i ={v1,v2,…,v L}, where L is the length of the text sequence of the i-th sample;
[0062] S34, the vector representation V of each sample output by the multi-classification model i Input the fully connected layer to obtain the text vector representation V of each sample i Mapped to the probability distribution O of its category ij ;
[0063] O ij =softmax(W·V i +b), where W and b are the weight and bias of the fully connected layer respectively;
[0064] According to the true label y corresponding to each sample ij′ and its text vector representation V i Mapped to the probability distribution O of its category ij , use the cross entropy function to calculate the function loss value L of the mutually exclusive label multi-classification model,
[0065] Where s is the number of samples, c is the number of label categories, O ij is the predicted probability of the jth label in the predicted label of the i-th sample, y ij ' is the jth label in the label set corresponding to the i-th sample (when the i-th sample x i′ When the corresponding labels are mutually exclusive labels, y ij ' is the jth label in the corresponding true label set (i.e., the label set corresponding to the sample described in step S1). i′ When the corresponding labels are non-mutually exclusive labels, y ij ' is the uniform value set in step S32);
[0066] Then, the gradient information is calculated by back propagation according to the function loss value, and the model parameters are updated according to the gradient information. The above steps S33-S34 are repeated to train the initial mutually exclusive label multi-classification model.
[0067] S35, repeat the above steps S33-S34, and use the text data of the test set to test the accuracy of the initial mutually exclusive label multi-classification model until the function loss value output by the mutually exclusive label multi-classification model converges. When the function loss value output by the mutually exclusive label multi-classification model converges, it means that the performance of the model is stable and its estimated accuracy meets the requirements.
[0068] According to the mutually exclusive label set, all sample data with non-mutually exclusive labels are screened out from the training sample data, and a non-mutually exclusive multi-label classification model is obtained by training using all sample data with non-mutually exclusive labels. Specifically, the following steps are included:
[0069] S36, build a non-mutually exclusive multi-label classification model: first build a BERT model, and connect the fully connected layer to the output layer of the BERT model;
[0070] S37, based on the mutually exclusive label set, filter out all sample data with non-mutually exclusive labels from the training sample data obtained in step S2, and divide all the filtered sample data with non-mutually exclusive labels into a training set and a test set;
[0071] S38, input the data in the training set into the BERT model, use the samples in the training set and their corresponding labels to train the BERT model to obtain a multi-label classification model, and record the non-mutually exclusive label training data input into the multi-label classification model as D″={(x 1″ ,y 1″ ),(x 2″ ,y 2″ ),…,(x n″ ,y n″ )},x j″ is the jth sample with non-mutually exclusive labels, y j″ is the true label set of the jth sample with non-mutually exclusive labels (i.e., the label set corresponding to the sample described in step S1), and n is the number of samples with non-mutually exclusive labels;
[0072] The multi-label classification model outputs a text vector representation V for each sample j ;
[0073] V j ={v1,v2,…,v L}, where L is the j The length of the text sequence of samples;
[0074] Represent the text vector V of each sample output by the BERT model j Input the fully connected layer to obtain the text vector representation V of each sample j Mapped to the probability distribution O of its category ij ';
[0075] O ij '=sigmoid(W·V j +b), where W and b are the weight and bias of the fully connected layer respectively. The sigmoid function is used in this model instead of the softmax function because this is a multi-label classification problem. The prediction of each label is independent, not mutually exclusive. The sigmoid function can map the output of each label to the [0,1] interval, indicating the predicted probability of a certain label.
[0076] According to the true label y corresponding to each sample ij″ and its text vector representation V j Mapped to the probability distribution O of its category ij ', use the binary cross entropy function to calculate the binary cross entropy loss value L for each sample label i ,
[0077] Among them, k is the number of labels of the i-th sample, O ij ' is the predicted probability of the jth label in the predicted label of the i-th sample, y ij ' is the jth label in the true label set corresponding to the i-th sample;
[0078] Then the function loss value of the non-mutually exclusive multi-label classification model is the average value L of the binary cross entropy loss value of all sample labels;
[0079] n is the number of samples with non-mutually exclusive labels;
[0080] Then, the function loss value L of the non-mutually exclusive multi-label classification model is used to calculate the gradient information by back propagation, and then the model parameters are updated according to the gradient information. This step is repeated to train the initial non-mutually exclusive multi-label classification model.
[0081] S39, repeat the above step S38, and use the text data of the test set to test the accuracy of the initial non-mutually exclusive multi-label classification model until the function loss value output by the non-mutually exclusive multi-label classification model converges. When the function loss value output by the non-mutually exclusive multi-label classification model converges, it means that the performance of the model is stable and its estimated accuracy meets the requirements.
[0082] S4, using mutually exclusive label multi-classification model or mutually exclusive label multi-classification model and non-mutually exclusive multi-label classification model to determine the label to which the text to be classified belongs.
[0083] Specifically, the specific steps of using the mutually exclusive label multi-classification model or the mutually exclusive label multi-classification model and the non-mutually exclusive multi-label classification model to determine the label to which the text to be classified belongs are:
[0084] S41, input the text to be classified into the mutually exclusive label multi-classification model to determine whether the text to be classified belongs to a certain type of text in the mutually exclusive labels. If it does, directly output the label corresponding to the text;
[0085] Otherwise, the text to be classified is continuously input into the non-mutually exclusive multi-label classification model, which predicts the probability values of all labels that the text to be classified may correspond to, and outputs the labels whose probability values exceed the set threshold.
[0086] Preferably, the above steps S1, S2 and S3 are performed offline, and step S4 is performed online.
[0087] The present invention also provides a large model-based unbalanced text multi-level classification device, including an offline module and an online module;
[0088] The offline module is used to use a generative large language model to identify the label of each sample in the unbalanced text data, obtain a mutually exclusive label set according to the identification result and reconstruct the training sample data, and perform label processing on the training sample data according to the mutually exclusive label set, and use the label-processed training sample data to train a mutually exclusive label multi-classification model; according to the mutually exclusive label set, all sample data with non-mutually exclusive labels are screened out from the training sample data, and all sample data with non-mutually exclusive labels are trained to obtain a non-mutually exclusive multi-label classification model. The mutually exclusive label multi-classification model and the non-mutually exclusive multi-label classification model are as described above and will not be described in detail here.
[0089] The online module is used to determine the label to which the to-be-classified text belongs by using a mutually exclusive label multi-classification model or a mutually exclusive label multi-classification model and a non-mutually exclusive multi-label classification model. The specific determination method is as described in step S4 above and will not be described in detail here.
[0090] The present invention also provides a computer device, which includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the method when executing the computer program.
[0091] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and sold or used as independent products, and can be stored in a computer-readable storage medium. Based on such an understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device to perform all or part of the steps of the method described in the embodiment of the present invention. The aforementioned storage medium includes various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0092] Through the description of the above embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0093] It should be clear that the described embodiments are only part of the embodiments of the present invention, rather than all the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
Claims
1. A multi-level classification method for imbalanced text based on a large model, characterized in that: The specific steps include: S1, obtain unbalanced text data; S2, using a generative large language model to identify the label of each sample in the unbalanced text data, obtaining a mutually exclusive label set based on the identification results and reconstructing the training sample data; S3, label processing is performed on the training sample data according to the mutually exclusive label set, and a mutually exclusive label multi-classification model is trained using the label-processed training sample data; According to the mutually exclusive label set, all sample data with non-mutually exclusive labels are screened out from the training sample data, and a non-mutually exclusive multi-label classification model is obtained by training all sample data with non-mutually exclusive labels; S4, using mutually exclusive label multi-classification model or mutually exclusive label multi-classification model and non-mutually exclusive multi-label classification model to determine the label to which the text to be classified belongs.
2. The method for multi-level classification of unbalanced text based on a large model according to claim 1, characterized in that: In step S2, the generative large language model is used to identify the label of each sample in the unbalanced text data, and the specific steps of obtaining a mutually exclusive label set based on the identification result and reconstructing the training sample data are as follows: The generative large language model identifies the label of each sample in the unbalanced text data, and selects mutually exclusive labels based on the relationship and semantic difference between different labels to obtain a mutually exclusive label set; The number of samples of each type of label is counted, and the generative large language model then enhances the sample data of labels with a small number of samples and adds the newly added sample data to the unbalanced text data to obtain training sample data.
3. The unbalanced text multi-level classification method based on a large model according to claim 1 or 2, characterized in that: The generative large language model used is GPT-4.
4. The method for multi-level classification of unbalanced text based on a large model according to claim 1 or 2, characterized in that: Each sample in the unbalanced text data corresponds to one or more labels.
5. The method for multi-level classification of unbalanced text based on a large model according to claim 1, characterized in that: In step S3, when label processing is performed on the training sample data according to the mutually exclusive label set, the labels of all samples with non-mutually exclusive labels in the training sample data are uniformly set to the same value, and the labels of samples with mutually exclusive labels remain unchanged.
6. The method for multi-level classification of unbalanced text based on a large model according to claim 1, characterized in that: In step S3, the specific steps of training the mutually exclusive label multi-classification model using the label-processed training sample data are as follows: The multi-classification model is trained based on each sample and its corresponding label in the training sample data after label processing. The multi-classification model is used to determine whether the sample label is a mutually exclusive label. The mutually exclusive label training data input into the multi-classification model is recorded as D ′ ={(x1′,y1′),(x2′,y2′),…,(x s ′,y s ′)}, where x i ′ is the i-th sample in the training set, y i ′ is the label set corresponding to the i-th sample; The multi-classification model outputs a text vector representation V for each sample i , and represent each sample’s vector V i Input the fully connected layer to obtain the text vector representation V of each sample i Mapped to the probability distribution O of its category ij ; According to the true label y corresponding to each sample i ′ and its text vector representation V i Mapped to the probability distribution O of its category ij , use the cross entropy function to calculate the function loss value of the mutually exclusive label multi-classification model, and use back propagation to calculate the gradient information based on the function loss value, and then update the model parameters based on the gradient information; Repeat the above steps until the function loss value output by the mutually exclusive label multi-classification model converges.
7. The method for multi-level classification of unbalanced text based on a large model according to claim 1, characterized in that: In step S3, the specific steps of training a non-mutually exclusive multi-label classification model using all sample data with non-mutually exclusive labels are as follows: The multi-label classification model is trained using all sample data with non-mutually exclusive labels and their corresponding labels. The non-mutually exclusive label training data input into the multi-label classification model is recorded as D″={(x1″,y1″),(x2″,y2″),…,(x n ″,y n ″)},x j ″ is the jth sample with non-mutually exclusive labels, y j ″ is the label set corresponding to the jth sample with non-mutually exclusive labels; The multi-label classification model outputs a text vector representation V for each sample j And represent the text vector of each sample as V j Input the fully connected layer to obtain the text vector representation V of each sample j Mapped to the probability distribution O of its category ij '; According to the true label y corresponding to each sample j ″ and its text vector representation V j Mapped to the probability distribution O of its category ij ', using the binary cross entropy function to calculate the binary cross entropy loss value of each sample label, the function loss value of the non-mutually exclusive multi-label classification model is the average value of the binary cross entropy loss values of all sample labels; The function loss value of the non-mutually exclusive multi-label classification model uses back propagation to calculate the gradient information, and then updates the model parameters based on the gradient information; Repeat the above steps until the function loss value output by the non-mutually exclusive multi-label classification model converges.
8. The method for multi-level classification of unbalanced text based on a large model according to claim 1, characterized in that: In step S4, the specific steps of using the mutually exclusive label multi-classification model or the mutually exclusive label multi-classification model and the non-mutually exclusive multi-label classification model to determine the label to which the text to be classified belongs are: Input the text to be classified into the mutually exclusive label multi-classification model to determine whether the text to be classified belongs to a certain type of text in the mutually exclusive label. If it does, directly output the label corresponding to the text; Otherwise, the text to be classified is continuously input into the non-mutually exclusive multi-label classification model, which predicts the probability values of all labels that the text to be classified may correspond to, and outputs the labels whose probability values exceed the set threshold.
9. The method for multi-level classification of unbalanced text based on a large model according to claim 1, characterized in that: Steps S1, S2 and S3 are performed offline, and step S4 is performed online.
10. A multi-level classification device for imbalanced text based on a large model, characterized in that: Includes offline modules and online modules; The offline module is used to use a generative large language model to identify the label of each sample in the unbalanced text data, obtain a mutually exclusive label set according to the identification result and reconstruct the training sample data, and perform label processing on the training sample data according to the mutually exclusive label set, and use the label-processed training sample data to train a mutually exclusive label multi-classification model; According to the mutually exclusive label set, all sample data with non-mutually exclusive labels are screened out from the training sample data, and a non-mutually exclusive multi-label classification model is obtained by training all sample data with non-mutually exclusive labels; The online module is used to determine the label to which the to-be-classified text belongs by using a mutually exclusive label multi-classification model or a mutually exclusive label multi-classification model and a non-mutually exclusive multi-label classification model.
Citation Information
Patent Citations
Loss function calculation method based on classification mutual exclusivity, electronic device and medium
CN109447102A
Two-stage resampling method for unbalanced data
CN114077864A