Training method, device, equipment and computer storage medium for text classification model

By setting different probability values ​​of the Dropout layer in the BERT pre-training model, calculating cross-entropy loss and KL divergence, and optimizing model parameters, the inconsistency and over-fitting problems of the deep learning model in the training and inference stages are solved, and the model is improved. stability and performance.

CN114860939BActive Publication Date: 2024-09-27SHENZHEN XINGUODU INTELLIGENT COMPUTING TECHNOLOGY CO LTD
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202210573501.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-25
Publication Date
2024-09-27
Estimated Expiration
2042-05-25

AI Technical Summary

Technical Problem

Deep learning models such as the BERT pre-training model have inconsistencies in the Dropout algorithm during the training phase and the inference phase, resulting in overfitting and model instability. Existing methods such as Fraternal dropout and Simple Contrastive Learning of Sentence Embeddings cannot effectively solve the sentence problem of a single sentence. Problems with vector and interactive semantic matching models.

Method used

By obtaining the improved BERT pre-training model, setting the probability value of the Dropout layer to 0 and less than 1, train the first and second pre-training models respectively, calculate the cross-entropy loss and KL divergence between the two, and optimize the model parameters. To reduce inconsistency, use Bernoulli distribution to speed up the training process and avoid overfitting.

Benefits of technology

It effectively reduces the inconsistency between the training and inference phases of the text classification model caused by the Dropout layer, avoids overfitting, and improves the stability and performance of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114860939B
    Figure CN114860939B
Patent Text Reader

Abstract

The present invention relates to a training method, device, equipment, and computer storage medium for a text classification model. The training method for the text classification model includes: obtaining a text classification model; obtaining text training data; setting the probability value of the Dropout layer to 0 to obtain a first pre-trained model, and inputting the text training data into the first pre-trained model to obtain a first probability distribution; setting the probability value of the Dropout layer to p (0 < p < 1) to obtain a second pre-trained model, and inputting the text training data into the second pre-trained model to obtain a second probability distribution; calculating the loss function of the text classification model using the first probability distribution and the second probability distribution, and optimizing the parameters of the text classification model using the loss function to obtain a trained text classification model. The training method of the present invention can not only avoid the problem of overfitting of the text classification model, but also reduce the inconsistency problem of the text classification model in the training stage and the validation stage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of text classification, and in particular to a training method, device, equipment and computer storage medium for a text classification model. Background Art

[0002] Usually, in order to avoid overfitting problems in deep learning models such as BERT pre-trained models, the Dropout algorithm is often applied in the model training phase. However, since deep learning models such as BERT pre-trained models apply the Dropout algorithm in the training phase but not in the inference phase, deep learning models such as BERT pre-trained models have inconsistencies in the training phase and the inference phase.

[0003] In order to reduce the inconsistency problem in the training and reasoning stages of deep learning models such as the BERT pre-training model after applying the Dropout algorithm, many scholars have conducted relevant research. For example, Zolna et al. proposed the Fraternal Dropout algorithm (hereinafter referred to as the FD algorithm). The FD algorithm minimizes the equally weighted sum of the prediction losses of the two neural networks, and adds the L2 distance of the hidden states of the two networks as a regular term to the loss function of the model. However, since the main training goal of the FD algorithm is to minimize the negative log-likelihood of the output distribution of the neural network, and the hidden state of the neural network is far from the probability distribution of the neural network output, using the L2 distance of the hidden state is not the optimal solution; Gao et al. proposed Simple Contrastive Learning of Sentence Embeddings method (hereinafter referred to as: SimCSE method), the SimCSE method uses the Dropout algorithm to add noise to the text to construct a positive sample pair, and the negative sample pair is other sentences selected in the batch, thereby constructing positive and negative samples for contrastive learning and using the contrastive learning method to train the model, which achieves the best in unsupervised semantic similarity. This method enables the model to reduce the differences between the predicted distributions caused by different Dropout modes, thereby reducing the inconsistency problem between the training stage and the inference stage of the model caused by the Dropout algorithm. However, the SimCSE method is a representational semantic matching model, which can only be applied to the study of sentence vector similarity between two sentences, but cannot be applied to the sentence vector of a single sentence, nor can it be applied to the interactive semantic matching model. Summary of the invention

[0004] Based on this, the purpose of the present invention is to provide a training method, a training device and a computer storage medium for a text classification model, which can not only avoid the problem of overfitting of the text classification model, but also reduce the inconsistency problem of the text classification model in the training stage and the reasoning stage caused by the Dropout layer.

[0005] The training method of the text classification model includes the following steps:

[0006] S1: Obtain a text classification model, where the text classification model is an improved BERT pre-trained model, and an embedding layer, an encoding layer, and an output layer of the improved BERT pre-trained model are all provided with a Dropout layer, and a probability value of the Dropout layer is less than 1;

[0007] S2: Get text training data;

[0008] S3: setting the probability value of the Dropout layer to 0 to obtain a first pre-training model, and inputting the text training data into the first pre-training model to obtain a first probability distribution;

[0009] S4: setting the probability value of the Dropout layer to p (0<p<1) to obtain a second pre-training model, and inputting the text training data into the second pre-training model to obtain a second probability distribution;

[0010] S5: Calculate the loss function of the text classification model using the first probability distribution and the second probability distribution, and optimize the parameters of the text classification model using the loss function to obtain a trained text classification model.

[0011] The training method of the text classification model disclosed in the present invention inputs the same training data into a text training model with a probability value of 0 in the Dropout layer and a text training model with a probability value of p (0<p<1) in the Dropout layer respectively, obtains different probability distributions, and uses the two probability distributions to calculate the loss function of the text classification model, and uses the loss function to optimize the parameters of the text classification model, which can reduce the inconsistency problem caused by the Dropout layer to the text classification model.

[0012] Further, in step S5, calculating the loss function of the text classification model using the first probability distribution and the second probability distribution includes the following steps:

[0013] S51: Calculate the cross entropy loss function of the first probability distribution and the second probability distribution, that is: Among them, P1(y i |x i ) is the i-th training data (x i ,yi ) corresponds to the first probability distribution, P2(y i |x i ) is the i-th training data (x i ,y i ) corresponds to the second probability distribution; n is the number of training data;

[0014] S52: Calculate the KL divergence of the first probability distribution and the second probability distribution, that is:

[0015] S53: Calculate the loss function of the text classification model using the cross entropy loss function of the first probability distribution and the second probability distribution and the KL divergence of the first probability distribution and the second probability distribution, i.e., L=L ce +αL kl , where: α is the scaling factor, and the value range of α is (0, 10].

[0016] Furthermore, in step S5, optimizing the parameters of the text classification model using the loss function is optimizing the weights of the text classification model using the gradient of the loss function, that is: Where: W t+1 is the weight of the text classification model at the (t+1)th iteration; W t is the weight of the text classification model at the tth iteration; η is the learning rate, and its value range is [e -5 ,e -4 ]; is the weight W t The corresponding loss function gradient.

[0017] Furthermore, in step S5, optimizing the weights of the text classification model using the gradient of the loss function includes the following steps:

[0018] The cross entropy loss function gradient corresponding to the first probability distribution is optimized using Bernoulli distribution to obtain an improved loss function gradient, and Where: g′ is the improved loss function gradient; Bernoulli (1-p) is the Bernoulli distribution, and p is the probability value of the Dropout layer;

[0019] The weights of the text classification model are optimized using an improved loss function gradient, and

[0020] The present invention also discloses a training device for a text classification model, comprising a first acquisition module, a second acquisition module, a third acquisition module, a fourth acquisition module and an update module; the first acquisition module is used to acquire the text classification model, the text classification model is a BERT pre-training model, and the embedding layer, the encoding layer and the output layer of the BERT pre-training model are all provided with a Dropout layer, and the probability value of the Dropout layer is less than 1; the second acquisition module is used to acquire text training data; the third acquisition module sets the probability value of the Dropout layer to 0 to obtain a first pre-training model, and inputs the text training data into the first pre-training model to obtain a first probability distribution; the fourth acquisition module sets the probability value of the Dropout layer to p (0<p<1) to obtain a second pre-training model, and inputs the text training data into the second pre-training model to obtain a second probability distribution; the update module is used to calculate the loss function of the text classification model using the first probability distribution and the second probability distribution, and optimizes the parameters of the text classification model using the loss function to obtain a trained text classification model.

[0021] Furthermore, the update module includes a first calculation unit, a second calculation unit and an update unit, the first calculation unit is used to calculate the loss function of the text classification model using the first probability distribution and the second probability distribution; the second calculation unit calculates the gradient of the weight corresponding to the loss function; the update unit optimizes the weight of the text classification model using the gradient of the weight corresponding to the loss function to obtain a trained text classification model.

[0022] Furthermore, the first calculation unit is used to calculate the loss function of the text classification model using the first probability distribution and the second probability distribution, comprising the following steps:

[0023] Calculate the cross entropy loss function of the first probability distribution and the second probability distribution, that is: Among them, P1(y i |x i ) is the i-th training data (x i ,y i ) corresponds to the first probability distribution, P2(y i |x i ) is the i-th training data (x i ,y i ) corresponds to the second probability distribution; n is the number of training data;

[0024] Calculate the KL divergence of the first probability distribution and the second probability distribution, that is:

[0025] The loss function of the text classification model is calculated using the cross entropy loss function of the first probability distribution and the second probability distribution and the KL divergence of the first probability distribution and the second probability distribution, that is, L = L ce +αL kl , where: α is the scaling factor, and the value range of α is (0,10].

[0026] Further, the second calculation unit calculates the gradient of the weight corresponding to the loss function as follows: optimizing the gradient of the cross entropy loss function corresponding to the first probability distribution using the Bernoulli distribution to obtain an improved gradient of the loss function, and Where: g′ is the improved loss function gradient; Bernoulli (1-p) is the Bernoulli distribution, and p is the probability value of the Dropout layer;

[0027] The present invention also discloses a training device for a text classification model, comprising a memory, a processor and a computer program, wherein the computer program is stored in the memory and is configured to be executed by the processor to implement the training method for the text classification model described in the present invention.

[0028] The present invention also discloses a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the training method of the text classification model described in the present invention.

[0029] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0030] Figure 1 A flowchart of a method for training a text classification model of the present invention;

[0031] Figure 2 This is a schematic diagram of the structure of the improved BERT pre-training model;

[0032] Figure 3 This is a structural diagram when the probability value of the Dropout layer is 0;

[0033] Figure 4 This is a structural diagram of the Dropout layer when the probability value is p (0<p<1). DETAILED DESCRIPTION

[0034] In order to make the objectives, technical solutions and advantages of the present application more clear, the embodiments of the present application will be further described in detail below with reference to the accompanying drawings.

[0035] It should be clear that the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the embodiments of the present application.

[0036] The terms used in the embodiments of the present application are only for the purpose of describing specific embodiments, and are not intended to limit the embodiments of the present application. The singular forms of "a", "said" and "the" used in the embodiments of the present application and the appended claims are also intended to include plural forms, unless the context clearly indicates other meanings. 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.

[0037] When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present application. On the contrary, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the attached claims. In the description of the present application, it should be understood that the terms "first", "second", "third", etc. are only used to distinguish similar objects, and do not have to be used to describe a specific order or sequence, nor can they be understood as indicating or implying relative importance. For those of ordinary skill in the art, the specific meanings of the above terms in the present application can be understood according to the specific circumstances.

[0038] In addition, in the description of this application, unless otherwise specified, "plurality" means two or more. "And / or" describes the association relationship of associated objects, indicating that three relationships may exist. For example, A and / or B can mean: A exists alone, A and B exist at the same time, and B exists alone. The character " / " generally indicates that the associated objects are in an "or" relationship.

[0039] It should be understood that the embodiments of the present application are not limited to the precise structures described above and shown in the drawings, and various modifications and changes can be made without departing from the scope thereof. The scope of the embodiments of the present application is limited only by the appended claims.

[0040] like Figure 1 As shown, this embodiment provides a training method for a text classification model, comprising the following steps:

[0041] S1: Obtain a text classification model, where the text classification model is an improved BERT pre-trained model.

[0042] The Bert pre-trained model is a pre-trained language model. The full name of the model is Bidirectional Encoder Representations from Transformers. The model is obtained by training the Masked Language Model and predicting the next sentence. Figure 2 As shown, the improved BERT pre-training model includes an input layer, an embedding layer, a coding layer and an output layer, and the embedding layer, the coding layer and the output layer are all provided with a Dropout layer, and the probability value of the Dropout layer is less than 1.

[0043] Specifically in this implementation, the embedding layer includes a position embedding layer and a Dropout layer; the encoding layer is formed by stacking 12 layers of Transformer encoder blocks with the same structure, and the Transformer encoder block includes a multi-head self-attention mechanism, a Dropout layer, a residual connection and a layer regularization layer, a feedforward neural network, a Dropout layer and a residual connection and layer stacked in sequence, and the output result of the Transformer encoder block is LayerNorm(x+Sublayer(x)); the output layer includes a Dropout layer, a feedforward neural network and a Softmax layer stacked in sequence.

[0044] Dropout refers to the process of removing neural network training units from the network with a certain probability during the training process of the text classification model. Since the removal is random, each input training data is training a different text classification model.

[0045] S2: Obtain text training data.

[0046] In this embodiment, let (X, Y) represent text training data, and X = {x1, x2, ..., x n}, Y = {y1, y2, ..., y n}, and n is the number of training data, X represents text data, and Y is the category set of text data.

[0047] S3: Setting the probability value of the Dropout layer to 0 to obtain a first pre-trained model, and inputting the text training data into the first pre-trained model to obtain a first probability distribution.

[0048] In this embodiment, the probability value of the Dropout layer is set to 0, and the training data (x i ,y i )(i=1,2,...,n) inputs the improved BERT pre-training model, such as Figure 3As shown, at this time, all neural network training units participate in the training and obtain the first probability distribution P1(y i |x i )(i=1,2,...,n).

[0049] S4: Setting the probability value of the Dropout layer to p (0<p<1) to obtain a second pre-training model, and inputting the text training data into the second pre-training model to obtain a second probability distribution.

[0050] In this embodiment, the probability value of the Dropout layer is set to p (0 < p < 1) to obtain a second pre-training model, such as Figure 4 As shown, at this time, (1-p) neural network training units are randomly selected from the neural network training units to participate in the training, and the second probability distribution P2(y i |x i )(i=1,2,...,n)

[0051] S5: Calculate the loss function of the text classification model using the first probability distribution and the second probability distribution, and optimize the parameters of the text classification model using the loss function to obtain a trained text classification model.

[0052] In this embodiment, calculating the loss function of the text classification model using the first probability distribution and the second probability distribution includes the following sub-steps:

[0053] (1) Calculate the cross entropy loss function of the first probability distribution and the second probability distribution, that is: Among them, P1(y i |x i ) is the i-th training data (x i ,y i ) corresponds to the first probability distribution, P2(y i |x i ) is the i-th training data (x i ,y i ) corresponds to the second probability distribution; n is the number of training data;

[0054] (2) Calculate the KL divergence of the first probability distribution and the second probability distribution, that is:

[0055] (3) The loss function of the text classification model is calculated using the cross entropy loss function of the first probability distribution and the second probability distribution and the KL divergence of the first probability distribution and the second probability distribution, that is, L = L ce +αL kl , where: α is the scaling factor, and the value range of α is (0,10].

[0056] In this embodiment, optimizing the parameters of the text classification model using the loss function is optimizing the weights of the text classification model using the gradient of the loss function, that is: Where: W t+1 is the weight of the text classification model at the (t+1)th iteration; W t is the weight of the text classification model at the tth iteration; η is the learning rate, and its value range is [e -5 ,e -4 ]; is the weight W t The corresponding loss function gradient.

[0057] Moreover, in order to avoid overfitting when the training data is input into the first pre-training model, the present invention uses Bernoulli distribution to optimize the gradient of the cross entropy loss function corresponding to the first probability distribution output by the first pre-training model to obtain an improved loss function gradient, which is achieved in the following way:

[0058] The cross entropy loss function gradient corresponding to the first probability distribution is optimized using Bernoulli distribution to obtain an improved loss function gradient, and Where: g′ is the improved loss function gradient; Bernoulli (1-p) is the Bernoulli distribution, and p is the probability value of the Dropout layer;

[0059] The weights of the text classification model are optimized using an improved loss function gradient, and

[0060] The training method of the text classification model disclosed in the present invention inputs the same training data into a text training model with a probability value of 0 in the Dropout layer and a text training model with a probability value of p (0<p<1) in the Dropout layer respectively, obtains different probability distributions, and uses the two probability distributions to calculate the loss function of the text classification model, and uses the loss function to optimize the parameters of the text classification model, which can reduce the inconsistency problem caused by the Dropout layer to the text classification model, because the KL divergence of the first probability distribution and the second probability distribution is used as the consistency regularization term of the loss function of the text classification model, which can reduce the inconsistency problem of the text classification model in the training stage and the verification stage. In addition, in order to speed up the convergence speed of the text classification model, the weight of the first pre-training model is optimized using Bernoulli distribution, so that the weight of the first pre-training model is 0 with a certain probability p, and overfitting of the text classification model can also be avoided.

[0061] Based on the training method of the text classification model provided in this embodiment, this embodiment also provides a training device for a text classification model, including a first acquisition module, a second acquisition module, a third acquisition module, a fourth acquisition module and an update module; the first acquisition module is used to acquire the text classification model, the text classification model is a BERT pre-training model, and the embedding layer, the encoding layer and the output layer of the BERT pre-training model are all provided with a Dropout layer, and the probability value of the Dropout layer is less than 1; the second acquisition module is used to acquire text training data; the third acquisition module sets the probability value of the Dropout layer to 0 to obtain a first pre-training model, and inputs the text training data into the first pre-training model to obtain a first probability distribution; the fourth acquisition module sets the probability value of the Dropout layer to p (0<p<1) to obtain a second pre-training model, and inputs the text training data into the second pre-training model to obtain a second probability distribution; the update module is used to calculate the loss function of the text classification model using the first probability distribution and the second probability distribution, and optimize the parameters of the text classification model using the loss function to obtain a trained text classification model.

[0062] Moreover, the update module includes a first calculation unit, a second calculation unit and an update unit, the first calculation unit is used to calculate the loss function of the text classification model using the first probability distribution and the second probability distribution; the second calculation unit calculates the gradient of the weight corresponding to the loss function; the update unit optimizes the weight of the text classification model using the gradient of the weight corresponding to the loss function to obtain a trained text classification model.

[0063] In this embodiment, the first calculation unit calculates the loss function of the text classification model using the first probability distribution and the second probability distribution, including the following steps:

[0064] Calculate the cross entropy loss function of the first probability distribution and the second probability distribution, that is: Among them, P1(y i |x i ) is the i-th training data (x i ,y i ) corresponds to the first probability distribution, P2(y i |x i ) is the i-th training data (x i ,y i ) corresponds to the second probability distribution; n is the number of training data;

[0065] Calculate the KL divergence of the first probability distribution and the second probability distribution, that is:

[0066] The loss function of the text classification model is calculated using the cross entropy loss function of the first probability distribution and the second probability distribution and the KL divergence of the first probability distribution and the second probability distribution, that is, L = L ce +αL kl , where: α is the scaling factor, and the value range of α is (0,10].

[0067] In this embodiment, the second calculation unit calculates the gradient of the weight corresponding to the loss function as follows: using the Bernoulli distribution to optimize the gradient of the cross entropy loss function corresponding to the first probability distribution to obtain an improved gradient of the loss function, and Where: g′ is the improved loss function gradient; Bernoulli (1-p) is the Bernoulli distribution, and p is the probability value of the Dropout layer;

[0068] This embodiment also provides a training device for a text classification model, including a memory, a processor, and a computer program, wherein the computer program is stored in the memory and is configured to be executed by the processor to implement the training method for the text classification model provided in this embodiment.

[0069] This embodiment also provides a computer-readable storage medium on which a computer program is stored. The computer program is executed by a processor to implement the training method of the text classification model provided in this embodiment.

[0070] The above-mentioned embodiments only express the preferred implementation of the present invention, and the description thereof is relatively specific and detailed, but it cannot be understood as limiting the scope of the invention patent. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, and the present invention is also intended to include these modifications and modifications.

Claims

1. Training method for text classification model, characterized in that, it includes the following steps: S1: Obtain a text classification model, the text classification model is an improved BERT pre-training model, and Dropout layers are provided in the embedding layer, encoding layer and output layer of the improved BERT pre-training model, and the probability value of the Dropout layer is less than 1; S2: Obtain text training data; S3: Set the probability value of the Dropout layer to 0 to obtain a first pre-training model, and input the text training data into the first pre-training model to obtain a first probability distribution; S4: Set the probability value of the Dropout layer to p (0 < p < 1) to obtain a second pre-training model, and input the text training data into the second pre-training model to obtain a second probability distribution; S5: Calculate the loss function of the text classification model using the first probability distribution and the second probability distribution, and optimize the parameters of the text classification model using the loss function to obtain a trained text classification model; wherein, calculating the loss function of the text classification model using the first probability distribution and the second probability distribution includes the following steps: S51: Calculate the cross entropy loss function of the first probability distribution and the second probability distribution, that is: Among them, P 1 (y i |x i ) is the i-th training data (x i ,y i ) corresponds to the first probability distribution, P 2 (y i |x i ) is the i-th training data (x i ,y i ) corresponds to the second probability distribution; n is the number of training data; S52: Calculate the KL divergence of the first probability distribution and the second probability distribution, that is: S53: Calculate the loss function of the text classification model using the cross entropy loss function of the first probability distribution and the second probability distribution and the KL divergence of the first probability distribution and the second probability distribution, i.e., L=L ce +αL kl , where: α is the scaling factor, and the value range of α is (0, 10]; Among them, optimizing the parameters of the text classification model using the loss function is optimizing the weights of the text classification model using the gradient of the loss function, that is: Where: W t+1 is the weight of the text classification model at the (t+1)th iteration; W t is the weight of the text classification model at the tth iteration; η is the learning rate, and its value range is [e -5 , e -4 ]; is the weight W t The corresponding loss function gradient; wherein, optimizing the weights of the text classification model using the gradient of the loss function includes the following steps: The cross entropy loss function gradient corresponding to the first probability distribution is optimized using Bernoulli distribution to obtain an improved loss function gradient, and Where: g′ is the improved loss function gradient; Bernoulli (1-p) is the Bernoulli distribution, and p is the probability value of the Dropout layer; The weights of the text classification model are optimized using an improved loss function gradient, and 2. Training device for text classification model, characterized in that, it includes a first acquisition module, a second acquisition module, a third acquisition module, a fourth acquisition module and an update module; the first acquisition module is used to acquire a text classification model, the text classification model is a BERT pre-training model, and Dropout layers are provided in the embedding layer, encoding layer and output layer of the BERT pre-training model, and the probability value of the Dropout layer is less than 1; the second acquisition module is used to acquire text training data; the third acquisition module sets the probability value of the Dropout layer to 0 to obtain a first pre-training model, and inputs the text training data into the first pre-training model to obtain a first probability distribution; the fourth acquisition module sets the probability value of the Dropout layer to p (0 < p < 1) to obtain a second pre-training model, and inputs the text training data into the second pre-training model to obtain a second probability distribution; the update module is used to calculate the loss function of the text classification model using the first probability distribution and the second probability distribution, and optimize the parameters of the text classification model using the loss function to obtain a trained text classification model; the update module includes a first calculation unit, a second calculation unit and an update unit, the first calculation unit is used to calculate the loss function of the text classification model using the first probability distribution and the second probability distribution; the second calculation unit calculates the gradient of the weight corresponding to the loss function; the update unit optimizes the weights of the text classification model using the gradient of the weight corresponding to the loss function to obtain a trained text classification model; the steps for the first calculation unit to calculate the loss function of the text classification model using the first probability distribution and the second probability distribution include: Calculate the cross entropy loss function of the first probability distribution and the second probability distribution, that is: Among them, P 1 (y i |x i ) is the i-th training data (x i ,y i ) corresponds to the first probability distribution, P 2 (y i |x i ) is the i-th training data (x i ,y i ) corresponds to the second probability distribution; n is the number of training data; Calculate the KL divergence of the first probability distribution and the second probability distribution, that is: The loss function of the text classification model is calculated using the cross entropy loss function of the first probability distribution and the second probability distribution and the KL divergence of the first probability distribution and the second probability distribution, that is, L = L ce +αL kl , where: α is the scaling factor, and the value range of α is (0, 10]; The second calculation unit calculates the gradient of the weight corresponding to the loss function as follows: the gradient of the cross entropy loss function corresponding to the first probability distribution is optimized using the Bernoulli distribution to obtain an improved gradient of the loss function, and g′= Where: g′ is the improved loss function gradient; Bernoulli (1-p) is the Bernoulli distribution, and p is the probability value of the Dropout layer; 3. Training device for text classification model, characterized in that, The invention comprises a memory, a processor and a computer program, wherein the computer program is stored in the memory and is configured to be executed by the processor to implement the training method of the text classification model as claimed in claim 1.

4. Computer readable storage medium, It is characterized in that A computer program is stored thereon, and the computer program is executed by a processor to implement the training method of the text classification model as claimed in claim 1.

Citation Information

Patent Citations

  • Classification model training method and device, terminal and storage medium

    CN112465017A

  • Method and device for improving performance of classification model by using label-free text data sample

    CN113806535A

  • Automatically Associating Context-based Sounds With Text

    US20210193109A1