Method and device for improving classification model performance using unlabeled text data samples
By introducing a random perturbation mechanism and unlabeled sample training into the classification model, the problem of insufficient data is solved, the robustness and performance of the model are improved, unlabeled samples are effectively utilized, and the dependence on labeled samples is reduced.
Patent Information
- Application Number
- CN202111045781.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-07
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2041-09-07
AI Technical Summary
Existing classification models require sufficient labeled samples during training and ignore the use of unlabeled samples, resulting in unsatisfactory training results when there is insufficient data.
By introducing a random perturbation mechanism into the supervised learning model, using unlabeled samples for training, the characters in the text data are randomly set to character 0, and combined with the randomization structure of the model to ensure that the probability distribution after perturbation is consistent with the normal output , thereby effectively utilizing unlabeled samples.
It improves the robustness and performance of classification models, reduces dependence on labeled samples, and is not restricted by specific model structures and classification tasks.
Smart Images

Figure CN113806535B
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of classification models, and in particular to a method and device for improving the performance of a classification model by using unlabeled text data samples. Background Art
[0002] Classification model is one of the two important categories of neural network models, the other category is regression model. The task of classification model is to analyze the input data and judge the type of input sample from multiple candidate targets; in contrast, regression model requires neural network fitting to obtain the target value. Classification model is more commonly used than regression model in some actual projects, because classification model is easier to evaluate results and apply. Text data is a common input data type for classification models in specific fields (such as data mining, natural language processing, etc.), such as spam classification, text sentiment analysis, entity classification and other classification tasks. Classification model cannot be used without the supervision information provided by a certain number of labeled samples, so that the model knows the sample distribution corresponding to each candidate classification target. However, the acquisition cost of labeled samples is much higher than that of unlabeled samples when applied. Academic data sets are relatively clean, and the data sets of classification tasks are uniformly composed of labeled samples, or unlabeled samples are specially designed to explore unsupervised learning methods; while business data has more noise, there is sufficient unlabeled data, but there is little labeled data, and the cost of manual annotation is very high. Existing methods ignore unlabeled samples, which is a waste of resources.
[0003] When existing model design methods are used to solve classification tasks, they often idealize the content composition of the data set. The conventional academic idea is to use only labeled samples for supervised learning. Although the classification model of supervised learning is easy to design, it requires sufficient labeled samples for training. In order to use unlabeled samples, the model design needs to analyze the application scenario and carefully design the semi-supervised / unsupervised learning model. The method is quite different from the supervised learning model, and a large number of unlabeled samples may also be required. With the development of pre-training technology, large-scale neural network models have been used to learn and obtain hidden features in massive data in fields such as text and images, such as the BERT model in the text field. They can complete classification tasks as part of the classification model through feature extraction or fine-tuning methods.
[0004] In the entity classification task, each entity sample has an entity name and a contextual description of the entity, and the type of the entity needs to be determined. The entity classification model proposed in Shimaoka's article is a classic supervised learning classification model. It encodes text data through attention mechanisms and pooling operations to obtain the final vector representation, and then gives the classification prediction result through the fully connected layer. Many similar supervised learning methods are easy to think about when designing, and it is easy to give a usable classification model according to the needs of the scene, but if the data set lacks sufficient labeled data, it is theoretically impossible to achieve the ideal training effect. Ling's article proposes an unsupervised (self-supervised) method, which uses the idea of contrastive learning to allow the model to learn the vector representation of the entity by distinguishing different entities, and then applies it to downstream entity classification tasks. When a new unsupervised method is published in an academic paper, its design will be praised for its cleverness, but in actual applications, there may not be enough unlabeled data to meet the training requirements. Mishra's article gives a semi-supervised method for named entity recognition, because named entities are continuous text characters, and CRF technology can be used to constrain the classification output of the model. It can be seen that the traditional semi-supervised learning method needs to be combined with the characteristics of the classification task itself, and it is more difficult to apply it universally. Summary of the invention
[0005] The present application aims to solve one of the technical problems in the related art at least to some extent.
[0006] To this end, the first purpose of the present application is to propose a method for improving the performance of a classification model using unlabeled text data samples, which solves the technical problem that existing methods require sufficient labeled samples for training and ignore unlabeled samples. At the same time, it solves the problem that the semi-supervised / unsupervised learning models designed for the use of unlabeled samples in existing methods may not have sufficient unlabeled data to meet the training requirements. The method utilizes the property that the sample classification remains consistent, and adding reasonable perturbation input does not change the result of the sample classification. The original supervised learning model is improved so that the unlabeled samples can participate in the training at the same time, thereby improving the robustness of the model. Randomly setting the characters in the sample's text data to character 0 with a small probability basically does not affect the expression of the text meaning. The unlabeled samples are effectively utilized, and random perturbations are added through text characters and model randomization structures to improve the performance of the classification model. At the same time, the present application does not require a sufficient number of labeled samples or unlabeled samples, and is not limited to specific model structures and classification tasks.
[0007] The second objective of this application is to propose a device for improving the performance of a classification model using unlabeled text data samples.
[0008] To achieve the above-mentioned purpose, the first embodiment of the present application proposes a method for improving the performance of a classification model using unlabeled text data samples, including: obtaining a labeled sample set, an unlabeled sample set, a classification type set of a classification task, a verification set and a supervised learning model, wherein the classification type set of the classification task includes all possible types of samples, the classification model needs to use the classification type set of the classification task to predict the type of the input sample, and the supervised learning model is generated by training using labeled samples; initializing the parameters of the supervised learning model, determining a first perturbation probability and a second perturbation probability, wherein the first perturbation probability is the probability of randomly setting the input text character to character 0, character 0 represents a corresponding fixed all-0 variable, and the second perturbation probability represents the probability of a randomization layer in the model; repeatedly training the supervised learning model using a labeled sample set and an unlabeled sample set, and evaluating the performance of the supervised learning model on the verification set after each training, if the evaluation index performs better, recording the model parameters at that time, and when the repeated training reaches a preset condition, the training stops, and the final trained model is output.
[0009] Optionally, in one embodiment of the present application, training the supervised learning model includes the following steps:
[0010] Randomly sample a batch of data from the labeled sample set and the unlabeled sample set as training data;
[0011] The loss function is calculated using the training data, and the parameter gradients are updated through backpropagation.
[0012] Optionally, in one embodiment of the present application, the loss function is expressed as:
[0013] L merge =L labeled +λL unlabeled
[0014] Among them, L labeled Represents the loss function of the labeled sample set, L unlabeled Represents the loss function of the unlabeled sample set, and uses the parameter λ to control the weight of the loss function of the unlabeled sample part.
[0015] Optionally, in one embodiment of the present application, the loss function of the labeled sample set is the same as the loss function during supervised learning, and the loss function of the unlabeled sample set is the distance between the first probability distribution and the second probability distribution.
[0016] Optionally, in one embodiment of the present application, the first probability distribution is the probability distribution given by the model when no disturbance is added to the unlabeled samples in the fixed training data, and the second probability distribution is the probability distribution given by the model after disturbance is added to the unlabeled samples in the training data.
[0017] Optionally, in one embodiment of the present application, if the classification task is multi-label classification, the loss function of the labeled sample set is binary cross entropy, and the loss function of the unlabeled sample set is expressed as:
[0018]
[0019] Among them, B 2 is an unlabeled sample in the training data, I() represents the indicator function, and returns whether the condition at each position of the vector in the brackets is true, p s,c The classification c corresponding to each position of the prediction vector must be judged. β is a constant threshold used to determine whether the prediction result given by the model is reliable. The model discards unreliable unlabeled samples through β. ⊙ is the vector dot product, which calculates the distance between the two probability distributions. s,ε is the predicted probability of sample s after adding disturbance, p' s is the target prediction probability of sample s after polarization prediction,
[0020] When the multi-label classification model outputs the prediction result, it first calculates the original prediction result, and then maps the prediction result to between 0 and 1 through the sigmoid function, calculates the probability that the sample has a specific type, and polarizes the sigmoid function that the model calculates the target prediction probability. The calculation formula of the sigmoid function is:
[0021]
[0022] Among them, x represents the original prediction result calculated by the model, 0<τ≤1 is the temperature constant, which controls the degree of polarization. The closer it is to 0, the closer the output value of the sigmoid function is to 0 or 1, and the higher the degree of polarization.
[0023] Optionally, in one embodiment of the present application, if the classification task is multi-category classification, the loss function of the labeled sample set is cross entropy, and the loss function of the unlabeled sample set is expressed as:
[0024]
[0025] Among them, B 2 is the unlabeled sample in the training data, I() represents the indicator function, which returns the value of whether the condition in the brackets is true, β is a constant threshold used to determine whether the prediction result given by the model is reliable. The model discards unreliable unlabeled samples through β, and p s,ε is the predicted probability of sample s after adding disturbance, max(p s ) indicates calculating the maximum element value of the predicted probability vector, p' s is the target prediction probability of sample s after polarization prediction,
[0026] The prediction result vector output by the multi-class classification model is the probability distribution of each type of sample. Similarly, the original prediction result is calculated first, and then the predicted probability distribution is obtained through the softmax function. Polarization acts on the softmax function of the model to calculate the target prediction probability. The calculation formula of the softmax function is:
[0027]
[0028] Among them, x i It represents the prediction result of the sample calculated by the model on type i, k represents the number of possible classification types of the sample, 0<τ≤1 is the temperature constant, which controls the degree of polarization. The closer it is to 0, the closer the output value of the softmax function is to 0 or 1, and the higher the degree of polarization.
[0029] Optionally, in one embodiment of the present application, the preset condition is: using an early stopping mechanism, evaluating the performance of the supervised learning model after each round of training on the validation set, and terminating the training if the performance of the evaluation index does not get better in a set number of consecutive rounds of evaluation.
[0030] To achieve the above-mentioned purpose, the second aspect of the present application proposes an embodiment, comprising: an acquisition module, an initialization module, and a training module, wherein:
[0031] An acquisition module is used to acquire a labeled sample set, an unlabeled sample set, a classification type set of a classification task, a validation set, and a supervised learning model. The classification type set of the classification task contains all possible types of samples. The classification model needs to use the classification type set of the classification task to predict the type of the input sample. The supervised learning model is generated by training using labeled samples.
[0032] An initialization module is used to initialize the parameters of the supervised learning model and determine a first perturbation probability and a second perturbation probability, wherein the first perturbation probability is the probability of randomly setting the input text character to character 0, character 0 represents a corresponding fixed all-0 variable, and the second perturbation probability represents the probability of a randomization layer in the model;
[0033] The training module is used to repeatedly train the supervised learning model using labeled sample sets and unlabeled sample sets, and evaluate the performance of the supervised learning model on the validation set after each training. If the evaluation index performs better, the model parameters at that time are recorded. When the repeated training meets the preset conditions, the training stops and the final trained model is output.
[0034] The method and device for improving the performance of a classification model by using unlabeled text data samples in the embodiments of the present application solve the technical problem that the existing methods require sufficient labeled samples for training and ignore the unlabeled samples. At the same time, it solves the problem that the semi-supervised / unsupervised learning models designed for using unlabeled samples in the existing methods may not have sufficient unlabeled data to meet the training requirements. It utilizes the property that sample classification remains consistent, and adding reasonable perturbation input does not change the result of sample classification. The original supervised learning model is improved so that unlabeled samples can participate in the training at the same time, thereby improving the robustness of the model. Randomly setting the characters in the sample's text data to character number 0 with a small probability does not basically affect the expression of the text meaning. The unlabeled samples are effectively utilized, and random perturbations are added through text characters and model randomization structures to improve the performance of the classification model. At the same time, the present application does not require a sufficient number of labeled samples or unlabeled samples, and is not limited to specific model structures and classification tasks.
[0035] During training, this application samples unlabeled samples at the same time, randomly sets the characters in the sample's text data to character 0 (corresponding to a fixed all-0 vector), and combines the randomization operations (Dropout, etc.) contained in the model itself to obtain the predicted probability distribution of samples with noise perturbations. Since the nature of the samples themselves remains unchanged, the probability distribution of noise perturbations needs to be consistent with the probability distribution of normal outputs. This application can effectively utilize unlabeled samples to further improve the performance of the classification model.
[0036] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become apparent from the description below, or will be learned through the practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0037] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:
[0038] Figure 1 A flowchart of a method for improving classification model performance using unlabeled text data samples provided in Example 1 of the present application;
[0039] Figure 2 This is an overall flow chart of a method for improving classification model performance using unlabeled text data samples according to an embodiment of the present application;
[0040] Figure 3 An example diagram of a supervised learning model M of a method for improving classification model performance using unlabeled text data samples according to an embodiment of the present application;
[0041] Figure 4 A schematic diagram of the structure of a device for improving classification model performance using unlabeled text data samples provided in Example 2 of the present application. DETAILED DESCRIPTION
[0042] The embodiments of the present application are described in detail below, and examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are intended to be used to explain the present application, and should not be construed as limiting the present application.
[0043] The following describes a method and device for improving classification model performance using unlabeled text data samples according to an embodiment of the present application with reference to the accompanying drawings.
[0044] Figure 1 A flowchart of a method for improving classification model performance by using unlabeled text data samples provided in Example 1 of the present application.
[0045] like Figure 1 As shown, the method for improving the performance of the classification model using unlabeled text data samples includes the following steps:
[0046] Step 101, obtaining a labeled sample set, an unlabeled sample set, a classification type set of a classification task, a validation set, and a supervised learning model, wherein the classification type set of the classification task includes all possible types of samples, the classification model needs to use the classification type set of the classification task to predict the type of the input sample, and the supervised learning model is generated by training using labeled samples;
[0047] Step 102, initializing the parameters of the supervised learning model, determining a first perturbation probability and a second perturbation probability, wherein the first perturbation probability is the probability of randomly setting the input text character to character 0, character 0 represents a corresponding fixed all-0 variable, and the second perturbation probability represents the probability of the randomization layer in the model;
[0048] Step 103, repeatedly train the supervised learning model using a labeled sample set and an unlabeled sample set, and evaluate the performance of the supervised learning model on the validation set after each training. If the evaluation index performs better, record the model parameters at that time. When the repeated training reaches the preset conditions, the training stops and the final trained model is output.
[0049] The method of improving the performance of a classification model using unlabeled text data samples in an embodiment of the present application comprises obtaining a labeled sample set, an unlabeled sample set, a classification type set of a classification task, a validation set and a supervised learning model, wherein the classification type set of the classification task includes all possible types of samples, the classification model needs to use the classification type set of the classification task to predict the type of the input sample, and the supervised learning model is generated by training using labeled samples; initializing parameters of the supervised learning model, determining a first perturbation probability and a second perturbation probability, wherein the first perturbation probability is the probability of randomly setting the input text character to character 0, character 0 represents a corresponding fixed all-0 variable, and the second perturbation probability represents the probability of a randomization layer in the model; repeatedly training the supervised learning model using a labeled sample set and an unlabeled sample set, and evaluating the performance of the supervised learning model on the validation set after each training, if the evaluation index performs better, recording the model parameters at that time, and when the repeated training reaches a preset condition, the training stops, and the final trained model is output. In this way, the technical problem that the existing methods require sufficient labeled samples for training and ignore unlabeled samples can be solved. At the same time, the problem that the semi-supervised / unsupervised learning models designed for the use of unlabeled samples in the existing methods may not have sufficient unlabeled data to meet the training needs can be solved. The consistent nature of sample classification is utilized, and adding reasonable perturbation input does not change the result of sample classification. The original supervised learning model is improved so that unlabeled samples can participate in the training at the same time, thereby improving the robustness of the model. Randomly setting the characters in the sample's text data to character number 0 with a small probability basically does not affect the expression of the text meaning. The unlabeled samples are effectively utilized, and random perturbations are added through text characters and model randomization structures to improve the performance of the classification model. At the same time, the present application does not require a sufficient number of labeled samples or unlabeled samples, and is not limited to specific model structures and classification tasks.
[0050] During training, this application samples unlabeled samples at the same time, randomly sets the characters in the sample's text data to character number 0, and combines the randomization operations (such as Dropout) contained in the model itself to obtain the predicted probability distribution of samples with noise perturbations. Since the nature of the samples themselves remains unchanged, the probability distribution of noise perturbations needs to be consistent with the probability distribution of normal outputs. This application can effectively utilize unlabeled samples to further improve the performance of the classification model.
[0051] Classification tasks can be divided into multi-label classification and multi-class classification according to the number of positive classification categories of the sample. Multi-label classification means that the sample can have an indefinite number of positive classification categories, while multi-class classification has only one positive classification category. When the neural network is used for multi-label classification, the binary cross-entropy loss is mainly used as the loss function, and when it is used for multi-class classification, the cross-entropy loss is mainly used as the loss function.
[0052] The problem to be solved can be formally defined as: labeled , unlabeled sample set S unlabeled , the target classification category set C of the classification task = {c 1 ,…,c k}, where the input data contained in the sample is mainly text. Suppose sample s has a text set T s ={t 1 ,…,t m}, for a labeled sample s∈S labeled , will give its correct classification category vector y s ,y s Each position of is used 0 / 1 to indicate whether the sample has the target classification (multi-label classification can have multiple 1s, and multi-category classification has only one 1). At the same time, a model M that only uses labeled samples for supervised learning is provided, which accepts various data of sample s as input, and after passing through different layers of the model, the probability vector p of the sample predicted by the model has each classification category is obtained. s The model is trained by optimizing y s and p s The model is evaluated on a test set with labeled samples by using p s Generate sample predicted labels, and then calculate them using indicators such as F1-score.
[0053] Taking the entity classification task as an example, there are n labeled sample sets in total labeled samples, the total number of unlabeled sample sets is n unlabeled There are k types of sample entities (i.e., y s and p s The dimension of the prediction vector is k).
[0054] The current tools for implementing neural network codes, such as PyTorch, TensorFlow, etc., will automatically initialize the various parameters of the model according to certain rules when the neural network is created. Since this application does not change the structure of the model itself, the parameter initialization of the neural network model M for supervised learning is consistent with the method when only supervised learning is performed on the current classification task. It can be automatically initialized by the tool, or some parameters of the model can be initialized with other probability distributions based on the characteristics of the classification task. The method of adding disturbances in this application acts on the sample text data and the randomized structure of the model itself (Dropout layer, etc.). For the sample text data, the input text characters will be randomly set to character 0, and the disturbance probability p 1 represents the probability of a character being set to character 0, p 1 Take a smaller value (such as 0.1) to avoid excessive destruction of text semantics. For classification tasks, some key characters in text data play a decisive role. For example, in the text segment of the "Fish-flavored Shredded Pork" sample, the four characters "Sichuan" and "Sichuan cuisine" directly indicate that the sample entity is Sichuan cuisine. The probability of them being replaced at the same time is one in ten thousand. In theory, the probability of excessive destruction of text semantics is very low. Perturbation probability p 2 Used for randomization layers such as Dropout layers in the model, and different probabilities can be set for each randomization layer, because supervised learning also has these randomization layers, p 2 The value of is to improve the performance of supervised learning. Generally, p 2 ≤0.5 (e.g. 0.2)
[0055] During the training of supervised learning models, a small batch of samples are normally sampled at each step, the loss function is calculated through forward propagation, and the gradient is updated by back propagation to obtain new parameter weights. At present, neural network optimizers such as Adam will record the gradient values of the parameter history, which will accumulate and affect the gradient update of the current step. Therefore, a fixed sample configuration should be used for each step of optimization. The unlabeled samples of this application also need to participate in the training, so each step needs to be from the labeled sample set S labeled Sample a small batch of labeled samples B 1 , and from the unlabeled sample set S unlabeled Sample a small batch of unlabeled samples B 2 In the code implementation, due to the cyclic sampling without replacement, B 1 , B 2 The number of samples in each loop is different, so different data loaders need to be used separately. Because random perturbations will introduce additional random interference to the gradient calculation, B 2 The batch size should be larger than B 1 , such as |B 2 |=2|B1 |, to reduce the impact of extreme situations.
[0056] For B 1 and B 2 The input of the samples in will be preprocessed to become the input acceptable to the model, where the text will be converted into character indexes to obtain the corresponding trainable word vectors, and the character 0 is a special character corresponding to a fixed all-0 vector. 2 The text of the sample in the text remains unchanged when no perturbation is added, and the text characters are changed with probability p when perturbation is added 1 Randomly set to character 0.
[0057] Furthermore, in an embodiment of the present application, training the supervised learning model includes the following steps:
[0058] Randomly sample a batch of data from the labeled sample set and the unlabeled sample set as training data;
[0059] The loss function is calculated using the training data, and the parameter gradients are updated through backpropagation.
[0060] Initialize the parameters of the supervised learning neural network model M with the default initialization or other probability distributions as needed, and determine the perturbation probability p 1 、p 2 Numerical value; sample a small batch of labeled and unlabeled samples B 1 , B 2 ; Calculate the loss function and back-propagate to update the parameter gradient; Determine whether the number of training rounds is sufficient; Retain the model parameters with the best evaluation index.
[0061] Furthermore, in the embodiment of the present application, the loss function is expressed as:
[0062] L merge =L labeled +λL unlabeled
[0063] Among them, L labeled Represents the loss function of the labeled sample set, L unlabeled Represents the loss function of the unlabeled sample set, and uses the parameter λ to control the weight of the loss function of the unlabeled sample part.
[0064] This application mainly uses unlabeled samples during training. Due to the accumulation of historical gradients of parameters, the loss function calculation method of each step of the model should be fixed. Each step of neural network training generally calculates the loss function and then back-propagates the gradient of the updated parameters. This application also uses unlabeled samples, and its loss function will be determined by the labeled sample B. 1 and unlabeled samples B 2The two different loss functions are combined to obtain
[0065] Furthermore, in an embodiment of the present application, the loss function of the labeled sample set is the same as the loss function during supervised learning, and the loss function of the unlabeled sample set is the distance between the first probability distribution and the second probability distribution.
[0066] The calculation of the loss function is divided into two cases: multi-label classification and multi-category classification. The part of unlabeled samples also uses three techniques: confidence-based hiding, polarization prediction, and warm-up training to further improve the training effect.
[0067] Confidence-based hiding: Use β to discard unreliable unlabeled samples, which can be adjusted according to data quality and can be taken as 0.3. The model outputs the predicted probability vector p of the sample in the classification task. s , if the model is uncertain about the classification of the sample (corresponding to high entropy of the probability distribution and close values at each position), then the undisturbed target prediction probability is unreliable; Polarization prediction: Use τ to polarize the prediction probability vector p s The value of p s The previous softmax or sigmoid function makes them closer to 0 / 1, playing a role similar to the soft target in knowledge distillation; Warm-up training: The parameter λ controls the weight of the loss function of the unlabeled sample part, starting from 0 and changing to 1 after a certain number of steps (such as 1000 steps), because the unperturbation target probability distribution of the unlabeled sample itself is unreliable at the beginning.
[0068] Furthermore, in an embodiment of the present application, the first probability distribution is the probability distribution given by the model when no disturbance is added to the unlabeled samples in the fixed training data, and the second probability distribution is the probability distribution given by the model after disturbance is added to the unlabeled samples in the training data.
[0069] The loss function of the unlabeled sample is the distance between two probability distributions, the first probability distribution is fixed B 2 The probability distribution given by the model when no perturbation is added to the sample (the model is in the eval state to avoid random operations such as the Dropout layer from taking effect), and the second probability distribution is the probability distribution given after the sample is perturbed, which is as close as possible to the target probability distribution when no perturbation is added. The distance between the two probability distributions can be calculated using metric functions such as mean square error and KL divergence.
[0070] Further, in an embodiment of the present application, if the classification task is multi-label classification, the loss function of the labeled sample set is binary cross entropy, and the loss function of the unlabeled sample set is expressed as:
[0071]
[0072] Among them, B 2 is an unlabeled sample in the training data, I() represents the indicator function, and returns whether the condition at each position of the vector in the brackets is true, p s,c The classification c corresponding to each position of the prediction vector must be judged. β is a constant threshold used to determine whether the prediction result given by the model is reliable. The model discards unreliable unlabeled samples through β. ⊙ is the vector dot product, which calculates the distance between the two probability distributions. s,ε is the predicted probability of sample s after adding disturbance, p' s is the target prediction probability of sample s after polarization prediction,
[0073] When the multi-label classification model outputs the prediction result, it first calculates the original prediction result, and then maps the prediction result to between 0 and 1 through the sigmoid function, calculates the probability that the sample has a specific type, and polarizes the sigmoid function that the model calculates the target prediction probability. The calculation formula of the sigmoid function is:
[0074]
[0075] Among them, x represents the original prediction result calculated by the model, 0<τ≤1 is the temperature constant, which controls the degree of polarization. The closer it is to 0, the closer the output value of the sigmoid function is to 0 or 1, and the higher the degree of polarization.
[0076] Further, in an embodiment of the present application, if the classification task is multi-category classification, the loss function of the labeled sample set is the cross entropy, and the loss function of the unlabeled sample set is expressed as:
[0077]
[0078] Among them, B 2 is the unlabeled sample in the training data, I() represents the indicator function, which returns the value of whether the condition in the brackets is true, β is a constant threshold used to determine whether the prediction result given by the model is reliable. The model discards unreliable unlabeled samples through β, and p s,ε is the predicted probability of sample s after adding disturbance, max(p s ) indicates calculating the maximum element value of the predicted probability vector, p' s is the target prediction probability of sample s after polarization prediction,
[0079] The prediction result vector output by the multi-class classification model is the probability distribution of each type of sample. Similarly, the original prediction result is calculated first, and then the predicted probability distribution is obtained through the softmax function. Polarization acts on the softmax function of the model to calculate the target prediction probability. The calculation formula of the softmax function is:
[0080]
[0081] Among them, x i It represents the prediction result of the sample calculated by the model on type i, k represents the number of possible classification types of the sample, 0<τ≤1 is the temperature constant, which controls the degree of polarization. The closer it is to 0, the closer the output value of the softmax function is to 0 or 1, and the higher the degree of polarization.
[0082] Furthermore, in an embodiment of the present application, the preset condition is: using an early stopping mechanism, the performance of the supervised learning model after each round of training is evaluated on the validation set, and the training is terminated if the performance of the evaluation index does not get better in a set number of consecutive rounds of evaluation.
[0083] The training of neural networks requires sampling many steps of samples to calculate the back-propagation gradient and then update the parameters before they can finally converge to the local optimal solution or overfitting. Therefore, to determine whether the number of training rounds is sufficient, it is necessary to set a larger maximum number of training steps (such as 10,000 steps) or not limit the maximum number of training steps. At the same time, an early stop mechanism is used. The model evaluates its performance on the validation set after every several steps. If the performance of the evaluation index does not improve for t consecutive times, the training is terminated. t takes a small value (such as t = 8) to avoid too many extra steps after overfitting to increase the training time, and to avoid too few steps that lead to failure to train to a local optimal solution.
[0084] During the training process, the model will be evaluated on the validation set multiple times. When the evaluation index performs better, the model parameters at that time are recorded. After the training is completed, the best parameters of the model are the model parameters saved at the time with the best evaluation index, and the final trained model is output.
[0085] A small batch of unlabeled samples B sampled additionally during the training process of this application 2 The scale is labeled sample B 1 A constant times, B 2 During training, only the target probability vector without disturbance is additionally calculated, and the forward propagation computation time is less than the back propagation gradient update time. Therefore, the time complexity of training with unlabeled data samples is the same as that of the original supervised learning. A certain number of labeled samples are randomly retained in multiple entity classification task data sets, and the remaining labeled samples are regarded as unlabeled samples. Then some supervised learning neural network models are designed, and the performance of these models is compared when only labeled samples are used for supervised learning and when unlabeled samples are additionally involved in training. It can be found that the overall performance is better when unlabeled samples are additionally involved in training.
[0086] Without changing or limiting the structure of the model M itself, this application takes advantage of the consistent nature of sample classification, adds reasonably disturbed input data and the randomized structure of the model itself without changing the results of sample classification, and uses the unperturbed probability vector as the target for distribution fitting, so that the supervised learning model can additionally use unlabeled data to improve the performance of evaluation indicators. This application perturbs the input data to the text, and completes the perturbation by randomly setting the text characters to character 0 with a small probability; the randomized structure of the model itself is mainly the Dropout layer in the model, which will randomly set the input neurons to 0 with a certain probability.
[0087] This application can be applied to entity classification tasks. Entities refer to things that exist objectively and can be distinguished from each other. Entity classification is a basic task in the field of artificial intelligence. Determining the classification type of entities can indirectly help applications such as text classification and knowledge graph construction. When actually solving entity classification tasks, unlike academic research, which has labeled data sets, a large number of entities do not have known classification types, but through various internal and external data sources, relevant information about the entities can be obtained. This is a typical situation that artificial intelligence will encounter when applying, that is, the relevant information of the sample is relatively sufficient, but it is difficult to obtain labeled samples. This application can effectively utilize unlabeled samples, alleviate the problem of insufficient data, and improve the performance of classification models.
[0088] Figure 2 This is an overall flow chart of a method for improving classification model performance using unlabeled text data samples according to an embodiment of the present application.
[0089] like Figure 2 As shown in the figure, the method of using unlabeled text data samples to improve the performance of the classification model is to input a labeled sample set S labeled , unlabeled sample set S unlabeled , classification set C = {c 1 ,…,c k}, supervised learning model M; initialize the parameters of the supervised learning neural network model M and determine the disturbance probability p 1 、p 2 Numerical value; sample a small batch of labeled and unlabeled samples B 1 , B 2 ; Calculate the loss function and back-propagate to update the parameter gradient; Determine whether the number of training rounds is sufficient. If not, return to step 1 to sample a small batch of labeled and unlabeled samples B 1 , B 2 ; If yes, keep the model parameters with the best evaluation index; output the trained model.
[0090] Figure 3 This is an example diagram of a supervised learning model M of a method for improving classification model performance using unlabeled text data samples according to an embodiment of the present application.
[0091] like Figure 3 As shown in the figure, the supervised learning model M of the method of improving the performance of the classification model by using unlabeled text data samples, the linear layer in the model is prone to degradation due to the large number of parameters, and it should be followed by a Dropout layer as much as possible to improve the generalization ability of the model. Taking the entity classification task as an example, the information that an entity may have includes the entity name, related text segments of multiple entities, etc. A typical supervised learning model for solving this task obtains the encoded vector representation of the entity through operations such as text encoding and pooling, and then obtains the classification result predicted by the model through vector concatenation and MLP layers.
[0092] Figure 4 A schematic diagram of the structure of a device for improving classification model performance using unlabeled text data samples provided in Example 2 of the present application.
[0093] like Figure 4 As shown, the device for improving the performance of a classification model using unlabeled text data samples includes: an acquisition module 10, an initialization module 20, and a training module 30, wherein:
[0094] An acquisition module 10 is used to acquire a labeled sample set, an unlabeled sample set, a classification type set of a classification task, a validation set, and a supervised learning model, wherein the classification type set of the classification task includes all possible types of samples, the classification model needs to use the classification type set of the classification task to predict the type of the input sample, and the supervised learning model is generated by training using labeled samples;
[0095] Initialization module 20, used to initialize the parameters of the supervised learning model, determine the first perturbation probability and the second perturbation probability, wherein the first perturbation probability is the probability of randomly setting the input text character to the character 0, the character 0 represents the corresponding fixed all-0 variable, and the second perturbation probability represents the probability of the randomization layer in the model;
[0096] The training module 30 is used to repeatedly train the supervised learning model using a labeled sample set and an unlabeled sample set, and evaluate the performance of the supervised learning model on the validation set after each training. If the evaluation index performs better, the model parameters at that time are recorded. When the repeated training reaches the preset conditions, the training stops and the final trained model is output.
[0097] The device for improving the performance of a classification model using unlabeled text data samples in an embodiment of the present application includes: an acquisition module, an initialization module, and a training module, wherein the acquisition module is used to acquire a labeled sample set, an unlabeled sample set, a classification type set of a classification task, a verification set, and a supervised learning model, wherein the classification type set of the classification task includes all possible types of samples, the classification model needs to use the classification type set of the classification task to predict the type of the input sample, and the supervised learning model is generated by training using labeled samples; the initialization module is used to initialize the parameters of the supervised learning model and determine a first perturbation probability and a second perturbation probability, wherein the first perturbation probability is the probability of randomly setting the input text character to the character 0, the character 0 represents a corresponding fixed all-0 variable, and the second perturbation probability represents the probability of a randomization layer in the model; the training module is used to repeatedly train the supervised learning model using the labeled sample set and the unlabeled sample set, and evaluate the performance of the supervised learning model on the verification set after each training, if the evaluation index performs better, record the model parameters at that time, when the repeated training reaches a preset condition, stop the training, and output the final trained model. In this way, the technical problem that the existing methods require sufficient labeled samples for training and ignore unlabeled samples can be solved. At the same time, the problem that the semi-supervised / unsupervised learning models designed for the use of unlabeled samples in the existing methods may not have sufficient unlabeled data to meet the training needs can be solved. The consistent nature of sample classification is utilized, and adding reasonable perturbation input does not change the result of sample classification. The original supervised learning model is improved so that unlabeled samples can participate in the training at the same time, thereby improving the robustness of the model. Randomly setting the characters in the sample's text data to character number 0 with a small probability basically does not affect the expression of the text meaning. The unlabeled samples are effectively utilized, and random perturbations are added through text characters and model randomization structures to improve the performance of the classification model. At the same time, the present application does not require a sufficient number of labeled samples or unlabeled samples, and is not limited to specific model structures and classification tasks.
[0098] During training, this application samples unlabeled samples at the same time, randomly sets the characters in the sample's text data to character 0 (corresponding to a fixed all-0 vector), and combines the randomization operations (Dropout, etc.) contained in the model itself to obtain the predicted probability distribution of samples with noise perturbations. Since the nature of the samples themselves remains unchanged, the probability distribution of noise perturbations needs to be consistent with the probability distribution of normal outputs. This application can effectively utilize unlabeled samples to further improve the performance of the classification model.
[0099] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, without contradiction.
[0100] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of this application, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0101] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, fragment or portion of code comprising one or more executable instructions for implementing the steps of a custom logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0102] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as an ordered list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by an instruction execution system, device or apparatus (such as a computer-based system, a system including a processor, or other system that can fetch instructions from an instruction execution system, device or apparatus and execute the instructions), or in combination with these instruction execution systems, devices or apparatuses. For the purpose of this specification, "computer-readable medium" can be any device that can contain, store, communicate, propagate or transmit a program for use by an instruction execution system, device or apparatus, or in combination with these instruction execution systems, devices or apparatuses. More specific examples of computer-readable media (a non-exhaustive list) include the following: an electrical connection with one or more wires (electronic device), a portable computer disk box (magnetic device), a random access memory (RAM), a read-only memory (ROM), an erasable and programmable read-only memory (EPROM or flash memory), a fiber optic device, and a portable compact disk read-only memory (CDROM). In addition, the computer-readable medium may even be paper or other suitable medium on which the program is printed, since the program may be obtained electronically, for example, by optically scanning the paper or other medium and then editing, interpreting or processing in other suitable ways if necessary, and then stored in a computer memory.
[0103] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0104] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0105] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0106] The storage medium mentioned above may be a read-only memory, a magnetic disk or an optical disk, etc. Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limiting the present application. A person of ordinary skill in the art may change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for improving the performance of a classification model using unlabeled text data samples, characterized in that: The following steps are involved: Obtain a labeled sample set, an unlabeled sample set, a classification type set of a classification task, a validation set, and a supervised learning model, wherein the classification type set of the classification task includes all possible types of samples, the classification model needs to use the classification type set of the classification task to predict the type of the input sample, and the supervised learning model is generated by training using labeled samples; Initializing parameters of the supervised learning model to determine a first disturbance probability and a second disturbance probability, wherein the first disturbance probability is the probability of randomly setting the input text character to character 0, the character 0 represents a corresponding fixed all-0 variable, and the second disturbance probability represents the probability of a randomization layer in the model; The supervised learning model is repeatedly trained using the labeled sample set and the unlabeled sample set, and the performance of the supervised learning model is evaluated on the validation set after each training. If the evaluation index is better, the model parameters at that time are recorded. When the repeated training reaches a preset condition, the training is stopped and the final trained model is output; The supervised learning model is trained, including the following steps: Randomly sampling a batch of data from the labeled sample set and the unlabeled sample set as training data; Using the first disturbance probability and the second disturbance probability to add disturbances to the text data of the samples in the training data and the randomized structure of the model itself respectively; Using the training data to calculate the loss function, and back-propagate to update the parameter gradient; The loss function is expressed as: THE merge =L labeled +λL unlabeled Among them, L labeled Represents the loss function of the labeled sample set, L unlabeled Represents the loss function of the unlabeled sample set, and uses the parameter λ to control the weight of the loss function of the unlabeled sample part; If the classification task is multi-label classification, the loss function of the labeled sample set is binary cross entropy, and the loss function of the unlabeled sample set is expressed as: Wherein, B2 is the unlabeled sample in the training data, I() represents the indicator function, which returns whether the condition at each position of the vector in brackets is true, and p s,c The classification c corresponding to each position of the prediction vector must be judged. β is a constant threshold used to determine whether the prediction result given by the model is reliable. The model discards unreliable unlabeled samples through β. ⊙ is the vector dot product, which calculates the distance between the two probability distributions. s,ε is the predicted probability of sample s after adding disturbance, p' s is the target prediction probability of sample s after polarization prediction, When the multi-label classification model outputs the prediction result, it will first calculate the original prediction result, and then map the prediction result to between 0 and 1 through the sigmoid function, calculate the probability that the sample has a specific type, and polarize the sigmoid function of the model to calculate the target prediction probability. The calculation formula of the sigmoid function is: Among them, x represents the original prediction result calculated by the model, 0<τ≤1 is the temperature constant, which controls the degree of polarization. The closer it is to 0, the closer the output value of the sigmoid function is to 0 or 1, and the higher the degree of polarization.
2. The method for improving classification model performance using unlabeled text data samples as claimed in claim 1, characterized in that: The loss function of the labeled sample set is the same as the loss function during supervised learning, and the loss function of the unlabeled sample set is the distance between the first probability distribution and the second probability distribution; The first probability distribution is the probability distribution given by the model when the unlabeled samples in the training data are fixed and no disturbance is added, and the second probability distribution is the probability distribution given by the model after disturbance is added to the unlabeled samples in the training data.
3. The method according to claim 1, characterized in that If the classification task is multi-category classification, the loss function of the labeled sample set is cross entropy, and the loss function of the unlabeled sample set is expressed as: Wherein, B2 is the unlabeled sample in the training data, I() represents the indicator function, which returns the value of whether the condition in the brackets is true, β is a constant threshold used to judge whether the prediction result given by the model is reliable, and the model discards unreliable unlabeled samples through β, and p s,ε is the predicted probability of sample s after adding disturbance, max(p s ) indicates calculating the maximum element value of the predicted probability vector, p' s is the target prediction probability of sample s after polarization prediction, The prediction result vector output by the multi-class classification model is the probability distribution of each type of sample. The original prediction result is calculated first, and then the predicted probability distribution is obtained through the softmax function. Polarization acts on the model to calculate the softmax function of the target prediction probability. The calculation formula of the softmax function is: Among them, x i It represents the prediction result of the sample calculated by the model on type i, k represents the number of possible classification types of the sample, 0<τ≤1 is the temperature constant, which controls the degree of polarization. The closer it is to 0, the closer the output value of the softmax function is to 0 or 1, and the higher the degree of polarization.
4. The method for improving classification model performance using unlabeled text data samples as claimed in claim 1, characterized in that: The preset condition is: using an early stopping mechanism, evaluating the performance of the supervised learning model after each round of training on the validation set, and ending the training if the performance of the evaluation indicator does not get better in a set number of consecutive rounds of evaluation.
5. A device for improving the performance of a classification model using unlabeled text data samples, characterized in that: It includes acquisition module, initialization module and training module, among which, The acquisition module is used to acquire a labeled sample set, an unlabeled sample set, a classification type set of a classification task, a validation set, and a supervised learning model, wherein the classification type set of the classification task includes all possible types of samples, the classification model needs to use the classification type set of the classification task to predict the type of the input sample, and the supervised learning model is generated by training using labeled samples; The initialization module is used to initialize the parameters of the supervised learning model and determine a first disturbance probability and a second disturbance probability, wherein the first disturbance probability is the probability of randomly setting the input text character to character 0, the character 0 represents a corresponding fixed all-0 variable, and the second disturbance probability represents the probability of a randomization layer in the model; The training module is used to repeatedly train the supervised learning model using the labeled sample set and the unlabeled sample set, and evaluate the performance of the supervised learning model on the validation set after each training. If the evaluation index performs better, the model parameters at that time are recorded. When the repeated training reaches a preset condition, the training is stopped and the final trained model is output; The supervised learning model is trained, including the following steps: Randomly sampling a batch of data from the labeled sample set and the unlabeled sample set as training data; Using the first disturbance probability and the second disturbance probability to add disturbances to the text data of the samples in the training data and the randomized structure of the model itself respectively; Using the training data to calculate the loss function, and back-propagate to update the parameter gradient; The loss function is expressed as: THE merge =L labeled +λL unlabeled Among them, L labeled Represents the loss function of the labeled sample set, L unlabeled Represents the loss function of the unlabeled sample set, and uses the parameter λ to control the weight of the loss function of the unlabeled sample part; If the classification task is multi-label classification, the loss function of the labeled sample set is binary cross entropy, and the loss function of the unlabeled sample set is expressed as: Wherein, B2 is the unlabeled sample in the training data, I() represents the indicator function, which returns whether the condition at each position of the vector in brackets is true, and p s,c The classification c corresponding to each position of the prediction vector must be judged. β is a constant threshold used to determine whether the prediction result given by the model is reliable. The model discards unreliable unlabeled samples through β. ⊙ is the vector dot product, which calculates the distance between the two probability distributions. s,ε is the predicted probability of sample s after adding disturbance, p' s is the target prediction probability of sample s after polarization prediction, When the multi-label classification model outputs the prediction result, it will first calculate the original prediction result, and then map the prediction result to between 0 and 1 through the sigmoid function, calculate the probability that the sample has a specific type, and polarize the sigmoid function of the model to calculate the target prediction probability. The calculation formula of the sigmoid function is: Among them, x represents the original prediction result calculated by the model, 0<τ≤1 is the temperature constant, which controls the degree of polarization. The closer it is to 0, the closer the output value of the sigmoid function is to 0 or 1, and the higher the degree of polarization.
Citation Information
Patent Citations
Image classification model training method, device and equipment
CN111144451A
Classification model training method, system and device and storage medium
CN112347261A
Learning device, learning method, and learning program
JP2021022316A
