Text classification model training method and device, text classification method and device

By fusing coding network and noise features in the text classification model for pre-training, the problem of high training costs in power production information is solved, and efficient semantic information extraction and classification under a small amount of data is realized.

CN116069926BActive Publication Date: 2025-08-12HUANENG CLEAN ENERGY RES INST +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211447376.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-18
Publication Date
2025-08-12
Estimated Expiration
2042-11-18

AI Technical Summary

Technical Problem

The existing text classification models have problems in the power industry that are high training costs, long time-consuming and serious dependence on labeled data, especially when dealing with unstructured power production information, it is difficult to efficiently extract semantic information.

Method used

The coding network in the text classification model is used to encode the training text, obtain the first semantic features, and size matching and fuse with the noise features. Pre-training the adversarial network to reduce dependence on the annotated data.

Benefits of technology

Improve model performance and performance when using a small amount of training text, effectively reduce dependence on labeled data, and improve the classification accuracy and efficiency of power production information.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116069926B_ABST
    Figure CN116069926B_ABST
Patent Text Reader

Abstract

The present disclosure provides a training method and device for a text classification model, as well as a text classification method and device. The method comprises: obtaining training text and encoding the training text using an encoding network in the text classification model to obtain a first semantic feature; obtaining a noise feature; fusing the noise feature with the first semantic feature to obtain a fused feature; and performing a first training of the text classification model based on the first semantic feature and the fused feature. Thus, the semantic features of the training text captured by the encoding network of the text classification model and the semantic features fused with the noise can be used to pre-train the text classification model. This allows the text classification model to effectively learn significant semantic information in the training text before actual training. This improves the model's performance and efficiency when the text classification model is actually trained using a small amount of training text, effectively reducing the model's reliance on labeled data.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a training method and device for a text classification model, and a text classification method and device. Background Art

[0002] The main purpose of text classification is to classify text into one or more categories based on its content and subject.

[0003] With the digital transformation of enterprises, the volume of power text information is expanding, and its content and types are becoming increasingly complex. Extracting power production information from this text and classifying it are crucial. In particular, the power industry's production processes involve a large amount of power production information, such as dispatch instructions. Extracting semantic information from this unstructured information is crucial for classifying and parsing it to improve production efficiency. Summary of the Invention

[0004] The present disclosure provides a text classification model training method and device, as well as a text classification method and device, to at least partially address one of the technical problems in the related art. The technical solution of the present disclosure is as follows:

[0005] According to one aspect of the present disclosure, a method for training a text classification model is provided, comprising:

[0006] Acquire a training text, and encode the training text using an encoding network in a text classification model to obtain a first semantic feature;

[0007] Acquire a noise feature; wherein the size of the noise feature matches the size of the first semantic feature;

[0008] fusing the noise feature and the first semantic feature to obtain a fused feature;

[0009] Based on the first semantic feature and the fusion feature, the text classification model is first trained.

[0010] According to another aspect of the present disclosure, a training device for a text classification model is provided, comprising:

[0011] A processing module, configured to obtain a training text and encode the training text using an encoding network in a text classification model to obtain a first semantic feature;

[0012] An acquisition module, configured to acquire a noise feature; wherein the noise feature and the first semantic feature have a size matching each other;

[0013] a fusion module, configured to fuse the noise feature with the first semantic feature to obtain a fused feature;

[0014] A first training module is used to perform a first training on the text classification model based on the first semantic feature and the fusion feature.

[0015] According to another aspect of the present disclosure, a text classification method is provided, comprising:

[0016] Obtaining electricity production information;

[0017] Encoding the power production information using an encoding network in a trained text classification model to obtain semantic features; wherein the text classification model is trained using the training method for the text classification model proposed in the above aspect of the present disclosure;

[0018] The semantic features are input into the classification network in the text classification model for classification to obtain the category to which the power production information belongs.

[0019] According to another aspect of the present disclosure, a text classification device is provided, comprising:

[0020] An acquisition module, used to obtain power production information;

[0021] an encoding module, which encodes the power production information using an encoding network in a trained text classification model to obtain semantic features; wherein the text classification model is trained using the training device for the text classification model proposed in another aspect of the present disclosure;

[0022] A classification module is used to input the semantic features into the classification network in the text classification model for classification, so as to obtain the category to which the power production information belongs.

[0023] According to another aspect of the present disclosure, an electronic device is provided, characterized in that it includes a memory, a processor, and a computer program stored in the memory and runnable on the processor, wherein when the processor executes the program, the training method of the text classification model proposed in the above-mentioned first aspect of the present disclosure is implemented, or the text classification method proposed in the above-mentioned still further aspect of the present disclosure is implemented.

[0024] According to another aspect of the present disclosure, a non-transitory computer-readable storage medium of computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the training method of the text classification model proposed in the above-mentioned first aspect of the present disclosure, or to execute the text classification method proposed in the above-mentioned still further aspect of the present disclosure.

[0025] According to another aspect of the present disclosure, a computer program product is provided, including a computer program, which, when executed by a processor, implements the training method of the text classification model proposed in the above-mentioned first aspect of the present disclosure, or implements the text classification method proposed in the above-mentioned still further aspect of the present disclosure.

[0026] The technical solutions provided by the embodiments of the present disclosure bring at least the following beneficial effects:

[0027] A training text is obtained and encoded using an encoding network in a text classification model to obtain a first semantic feature; a noise feature is obtained, wherein the noise feature and the first semantic feature have matching sizes; the noise feature and the first semantic feature are fused to obtain a fused feature; and a first training of the text classification model is performed based on the first semantic feature and the fused feature. Thus, the semantic features of the training text captured by the encoding network of the text classification model and the semantic features fused with the noise can be used to pre-train the text classification model. This allows the text classification model to effectively learn significant semantic information in the training text before actual training. This improves the model's performance and efficiency when the text classification model is actually trained using a small amount of training text, effectively reducing the model's reliance on labeled data.

[0028] Additional aspects and advantages of the present disclosure will be given in part in the following description and in part will be obvious from the following description, or will be learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0029] The above and / or additional aspects and advantages of the present disclosure will become apparent and readily understood from the following description of the embodiments in conjunction with the accompanying drawings, in which:

[0030] Figure 1 A flowchart of a method for training a text classification model provided in the first embodiment of the present disclosure;

[0031] Figure 2 A flowchart of a text classification model training method provided in the second embodiment of the present disclosure;

[0032] Figure 3 A flowchart of a method for training a text classification model provided in the third embodiment of the present disclosure;

[0033] Figure 4 A flowchart of a text classification method provided in the fourth embodiment of the present disclosure;

[0034] Figure 5 A schematic diagram of the training principle of the text classification model provided in this disclosure;

[0035] Figure 6A schematic diagram of the structure of a training device for a text classification model provided in the fifth embodiment of the present disclosure;

[0036] Figure 7 This is a structural diagram of a text classification device provided in Example 6 of the present disclosure;

[0037] Figure 8 A block diagram is shown of an exemplary electronic device suitable for implementing embodiments of the present invention. DETAILED DESCRIPTION

[0038] The following describes in detail embodiments of the present disclosure, examples of which 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 disclosure, and should not be construed as limiting the present disclosure.

[0039] The power industry involves a large amount of power production information, such as dispatch instructions. Parsing dispatch instructions can help improve production efficiency and has promising application prospects. However, due to the unstructured nature of power production information, extracting semantic information from it is difficult.

[0040] In related technologies, the text classification process can use manual classification or automatic classification to annotate information, but manual classification requires huge time and manpower costs, and with the continuous growth of text data, it is becoming increasingly important to use automatic text classification to annotate information.

[0041] Currently, text classification methods can be divided into the following three categories:

[0042] 1. Rule-based text classification model

[0043] Rule-based text classification models can achieve good classification results in specific domains, and their advantages include low time complexity and fast execution. However, because these text classification models are described by defining multiple rules, and the rules for determining the categories to which a text belongs are defined by a knowledge base of domain experts, they have poor transferability.

[0044] 2. Text classification model based on machine learning

[0045] Machine learning-based text classification models include, for example, the Naive Bayes model (NB), random forest model, and SVM (Support Vector Machine) model. However, training these traditional machine learning models requires a large amount of labeled data to discover the relationship between text information and the labeled data.

[0046] 3. Text classification model based on deep learning

[0047] The structure of the text classification model based on deep learning is relatively complex, and this type of text classification model does not rely on artificially acquired text features. It can directly model and learn the text content by mapping the text into a low-dimensional vector space.

[0048] In the field of natural language processing, numerous large-scale text pre-training models have achieved good results. However, training these models requires a large amount of labeled data and a large number of parameters, making the model training costly and time-consuming.

[0049] In response to at least one of the above-mentioned problems, the present disclosure proposes a text classification model training method, a text classification method, an apparatus, a device, and a medium.

[0050] The following describes the text classification model training method, text classification method, apparatus, device, and medium of the embodiments of the present disclosure with reference to the accompanying drawings.

[0051] Figure 1 A flowchart of the text classification model training method provided in the first embodiment of the present disclosure.

[0052] The embodiment of the present disclosure uses the example of configuring the training method of the text classification model in a training device for the text classification model. The training device for the text classification model can be applied to any electronic device so that the electronic device can perform the training function of the text classification model.

[0053] Among them, the electronic device can be any device with computing capabilities, such as a personal computer (PC), a mobile terminal, a server, etc. The mobile terminal can be, for example, a mobile phone, a tablet computer, a personal digital assistant, a wearable device, and other hardware devices with various operating systems, touch screens and / or display screens.

[0054] like Figure 1 As shown, the training method of the text classification model may include the following steps:

[0055] Step 101: obtain a training text, and use an encoding network in a text classification model to encode the training text to obtain a first semantic feature.

[0056] In an embodiment of the present disclosure, the training text may include power production information, wherein the power production information may include power dispatch text, power production meeting content, power production daily report, power production weekly report, etc., and the present disclosure does not impose any restrictions on this.

[0057] In the embodiments of the present disclosure, there is no restriction on the method of obtaining the training text. For example, the training text can be obtained from an existing training set, or the training text can also be collected online, such as by obtaining it online through web crawler technology, or the training text can also be provided to the user, etc. The present disclosure does not impose any restrictions on this.

[0058] In an embodiment of the present disclosure, a text classification model may include an encoding network, wherein the encoding network may be, for example, a BERT (Bidirectional Encoder Representations from Transformer) model, Ernie (Enhanced language Representation with InformativeEntities, a knowledge-enhanced semantic representation model), etc., and the present disclosure does not impose any restrictions on this.

[0059] In an embodiment of the present disclosure, an encoding network in a text classification model may be used to encode the training text to obtain a first semantic feature.

[0060] Step 102: Acquire a noise feature; wherein the size of the noise feature matches the size of the first semantic feature.

[0061] In the embodiment of the present disclosure, the size of the first semantic feature is determined according to the number of rows and columns of the first semantic feature. For example, if the first semantic feature has n rows and m columns, the size of the first semantic feature is n*m.

[0062] In the embodiment of the present disclosure, the size of the noise feature may match the size of the first semantic feature. For example, the size of the first semantic feature is n*m, and the size of the noise feature is also n*m.

[0063] In the embodiment of the present disclosure, noise characteristics may be obtained, for example, the noise characteristics may be generated by using a Gaussian noise generation function.

[0064] Step 103: Fusing the noise feature and the first semantic feature to obtain a fused feature.

[0065] In the embodiment of the present disclosure, the noise feature and the first semantic feature may be fused to obtain a fused feature.

[0066] As an example, the noise feature and the first semantic feature may be added to obtain a fused feature.

[0067] As another example, the noise feature and the first semantic feature may be concatenated to obtain a fusion feature.

[0068] Step 104: Perform a first training on the text classification model based on the first semantic feature and the fusion feature.

[0069] In the disclosed embodiment, a text classification model can be first trained based on the first semantic features and the fused features. Thus, the text classification model can be pre-trained based on the semantic features of the training text captured by the encoding network of the text classification model and the semantic features fused with noise.

[0070] The training method of the text classification model of the embodiment of the present disclosure obtains training text and encodes the training text using the encoding network in the text classification model to obtain a first semantic feature; obtains a noise feature; wherein the size of the noise feature matches that of the first semantic feature; fuses the noise feature and the first semantic feature to obtain a fused feature; and performs a first training on the text classification model based on the first semantic feature and the fused feature. Thus, the semantic features of the training text captured by the encoding network of the text classification model and the semantic features fused with the noise can achieve pre-training of the text classification model, allowing the text classification model to effectively learn significant semantic information in the training text before actual training, thereby improving the performance and performance of the model when the text classification model is actually trained using a small amount of training text, and effectively reducing the model's dependence on labeled data.

[0071] In order to clearly illustrate how the encoding network in the text classification model is used to encode the training text in the above embodiment of the present disclosure to obtain the first semantic feature, the present disclosure also proposes a training method for the text classification model.

[0072] Figure 2 This is a flowchart of the training method of the text classification model provided in the second embodiment of the present disclosure.

[0073] like Figure 2 As shown, the training method of the text classification model may include the following steps:

[0074] Step 201: Obtain training text.

[0075] The execution process of step 201 can refer to the execution process of any embodiment of the present disclosure and will not be described in detail here.

[0076] Step 202: perform word segmentation processing on the training text to obtain at least one word segment of the training text.

[0077] In the embodiment of the present disclosure, the number of word segments may be, but is not limited to, one, and the present disclosure does not impose any restriction on this.

[0078] In the embodiments of the present disclosure, the training text can be segmented. For example, a subword tokenizer (Subword Tokenization), a segmentation algorithm based on HMM (Hidden Markov Model), a segmentation algorithm based on CRF (Conditional Random Field), etc. can be used to segment the training text to obtain at least one segmentation of the training text.

[0079] As an example, assuming that the training text is "Increase the voltage of the substation to 100 volts", after word segmentation processing of the training text, the obtained word segments include "will", "substation", "of", "voltage", "increase", "to", "100", and "volts".

[0080] Step 203: Obtain a word vector corresponding to at least one word segmentation.

[0081] In an embodiment of the present disclosure, for any word in at least one word segmentation, a word vector corresponding to the any word segmentation can be obtained. For example, the torch.nn.embedding() function can be used to generate a word vector corresponding to the any word segmentation.

[0082] It should be noted that when there are multiple word segments, the word vectors corresponding to each word segment have the same size.

[0083] Step 204 : Based on the position of the at least one word segment in the training text, the word vectors corresponding to the at least one word segment are combined to obtain an input vector.

[0084] It can be understood that, for any one of the at least one segmented words, the any one segmented word may have a corresponding position in the training text.

[0085] In an embodiment of the present disclosure, the word vectors corresponding to at least one word segmentation may be combined based on the position of the at least one word segmentation in the training text, thereby obtaining an input vector.

[0086] Still using the above example for explanation, assuming that the word vector corresponding to the word participle "will" is A, the word vector corresponding to the word participle "substation" is B, the word vector corresponding to the word participle "of" is C, the word vector corresponding to the word participle "voltage" is D, the word vector corresponding to the word participle "increase" is E, the word vector corresponding to the word participle "to" is F, the word vector corresponding to the word participle "100" is G, and the word vector corresponding to the word participle "volt" is H. Based on the positions of the above participles in the training text "Increase the voltage of the substation to 100 volts", the word vectors corresponding to the above participles are combined to obtain the input vector (ABCDEFGH).

[0087] Step 205 : Input the input vector to the encoding network in the text classification model, so as to encode the input vector using the encoding network to obtain a first semantic feature.

[0088] In an embodiment of the present disclosure, the input vector may be input into an encoding network in a text classification model, so that the encoding network is used to encode the input vector, thereby obtaining a first semantic feature.

[0089] It is understandable that the first semantic feature may include the semantic vector of each word segment in the training text. In order to utilize the semantic information of the context of each word segment in the training text to represent the corresponding word segment and obtain the enhanced semantic vector of each word segment in different semantic spaces, in a possible implementation of the embodiment of the present disclosure, the input vector can be input into the encoding network in the text classification model, so that the encoding network can be used to encode each word segment based on multiple attention mechanisms, and multiple encoding vectors corresponding to each word segment can be obtained; for any word segment, the multiple encoding vectors corresponding to the word segment can be fused to obtain the semantic vector corresponding to the word segment.

[0090] In an embodiment of the present disclosure, multiple encoding vectors corresponding to each word segmentation may be fused. For example, multiple encoding vectors corresponding to each word segmentation may be weighted and summed to obtain a semantic vector corresponding to the word segmentation.

[0091] It should be noted that, for any word segmentation, the size of the semantic vector of the word segmentation can be the same as the size of the word vector corresponding to the word segmentation.

[0092] As an example, assuming that the encoding network is a BERT model, the BERT model includes 12 layers of Transformer, where each layer of Transformer includes a forward propagation layer and a multi-head attention layer. Therefore, the encoding network can encode each word based on multiple attention mechanisms, and can obtain multiple encoding vectors corresponding to each word; for any word, the multiple encoding vectors corresponding to the word can be fused, for example, the multiple encoding vectors corresponding to the word can be linearly combined to obtain a semantic vector with the same size as the word vector corresponding to the word.

[0093] Step 206: Acquire a noise feature; wherein the size of the noise feature matches the size of the first semantic feature.

[0094] Step 207: Fusing the noise feature and the first semantic feature to obtain a fused feature.

[0095] Step 208: Perform a first training on the text classification model based on the first semantic feature and the fusion feature.

[0096] The execution process of steps 206 to 208 can refer to the execution process of any embodiment of the present disclosure and will not be described in detail here.

[0097] In any embodiment of the present disclosure, the actual training of the text classification model can be: the encoding network in the text classification model that has undergone the first training can be used to re-encode the training text to obtain a third semantic feature; the third semantic feature is input into the classification network in the text classification model that has undergone the first training for classification, and the predicted category to which the training text belongs can be obtained; based on the difference between the labeled category and the predicted category on the training text, a second loss value can be generated; and based on the second loss value, the text classification model that has undergone the first training can be subjected to a second training.

[0098] In an embodiment of the present disclosure, the text classification model may include a classification network. Thus, in the present disclosure, the third semantic feature may be input into the classification network in the first trained text classification model for classification to obtain a predicted category to which the training text belongs.

[0099] In the disclosed embodiment, a second loss value can be generated based on the difference between the labeled category and the predicted category of the training text. The second loss value is positively correlated with the difference, i.e., the smaller the difference, the smaller the second loss value, and the larger the difference, the larger the second loss value.

[0100] As an example, the training text is "Increase the voltage of the substation to 100 volts", the annotation type of "substation" is "power plant facilities", the annotation type of "voltage" is "object", and the annotation type of "increase" is "operation technology". The predicted category of "substation" in the training text is "object", the annotation type of "voltage" is "object", and the annotation type of "increase" is "operation technology". At this time, due to the large difference between the annotation category and the predicted category corresponding to the substation, the prediction accuracy of the text classification model is poor. Therefore, the model parameters in the text classification model can be adjusted. Specifically, a second loss value can be generated according to the difference between the annotation type and the predicted category on the training text. Therefore, in the present disclosure, the text classification model that has undergone the first training can be trained for the second time according to the second loss value.

[0101] For example, the text classification model that has undergone the first training may be subjected to a second training based on the second loss value to minimize the second loss value.

[0102] It should be noted that the above only uses the termination condition of the second training of the text classification model as an example of minimizing the second loss value. In actual application, other termination conditions can also be set, such as the number of training times reaching a set number of times, the training time reaching a set time, the second loss value convergence, etc. The present disclosure does not impose any restrictions on this.

[0103] The training method of the text classification model of the embodiment of the present disclosure performs word segmentation processing on the training text to obtain at least one word segmentation of the training text and obtain a word vector corresponding to the at least one word segmentation; based on the position of the at least one word segmentation in the training text, the word vectors corresponding to the at least one word segmentation are combined to obtain an input vector; the input vector is input into the encoding network in the text classification model to encode the input vector using the encoding network to obtain a first semantic feature. In this way, each word segmentation can be obtained by segmenting the training text, and the word vectors of each word segmentation can be combined to obtain the input vector of the encoding network, so that the first semantic feature of the training text can be effectively obtained based on the encoding of the input vector by the encoding network.

[0104] In any embodiment of the present disclosure, in order to clearly illustrate how the text classification model is first trained based on the first semantic feature and the fusion feature, the present disclosure also proposes a training method for the text classification model.

[0105] Figure 3 This is a flowchart of the training method of the text classification model provided in Example 3 of the present disclosure.

[0106] like Figure 3 As shown, the training method of the text classification model may include the following steps:

[0107] Step 301: Obtain training text.

[0108] Step 302: perform word segmentation processing on the training text to obtain at least one word segment of the training text.

[0109] Step 303: Obtain a word vector corresponding to at least one word segmentation.

[0110] Step 304 : Based on the position of the at least one word segment in the training text, the word vectors corresponding to the at least one word segment are combined to obtain an input vector.

[0111] Step 305 : Input the input vector to the encoding network in the text classification model, so as to encode the input vector using the encoding network to obtain a first semantic feature.

[0112] Step 306: Acquire a noise feature; wherein the size of the noise feature matches the size of the first semantic feature.

[0113] Step 307: Fusing the noise feature and the first semantic feature to obtain a fused feature.

[0114] The execution process of steps 301 to 307 can refer to the execution process of any embodiment of the present disclosure and will not be described in detail here.

[0115] Step 308: Input the fused features into the generator in the adversarial network in the text classification model to obtain the second semantic features output by the generator.

[0116] In an embodiment of the present disclosure, the text classification model may include an adversarial network, wherein the adversarial network may be, for example, a GAN (Generative Adversarial Network) network.

[0117] As an example, the generator in the adversarial network in a text classification model may include 1 fully connected layer and 3 deconvolution layers.

[0118] It should be noted that the above examples of the generator structure are merely exemplary. In actual applications, the generated structure can be set as needed, and this disclosure does not impose any restrictions on this.

[0119] In an embodiment of the present disclosure, the fused features may be input into a generator in an adversarial network in a text classification model to obtain a second semantic feature output by the generator.

[0120] Step 309: Input the first semantic feature into the discriminator in the adversarial network to obtain a first output value output by the discriminator.

[0121] In the embodiment of the present disclosure, the adversarial network may include a discriminator (also called a classifier).

[0122] As a possible implementation manner, the first semantic feature and the input vector may be concatenated to obtain a first concatenated feature; and the first concatenated feature may be input into the discriminator to obtain a first output value output by the discriminator.

[0123] As an example, assume that the first semantic feature X' is ;The input vector X is , concatenate the first semantic feature and the input vector, and the obtained first concatenated feature can be , and the first splicing feature can be input into the discriminator to obtain the first output value output by the discriminator. For example, the first output value can be D( , ).

[0124] It should be noted that the above examples of the first splicing feature are only exemplary. In practical applications, other examples may be used. For example, the first splicing feature may also be Alternatively, the first splicing feature can also be Alternatively, the first splicing feature can also be .

[0125] Step 310: Input the second semantic feature into the discriminator to obtain a second output value output by the discriminator.

[0126] As a possible implementation manner, the first semantic feature and the second semantic feature may be concatenated to obtain a second concatenated feature; and the second concatenated feature may be input into a discriminator to obtain a second output value output by the discriminator.

[0127] As an example, suppose the first semantic feature is X' ; The second semantic feature is for , the first semantic feature and the second semantic feature are spliced together, and the second spliced feature obtained can be , and the second splicing feature can be input into the discriminator to obtain the second output value output by the discriminator. For example, the second output value can be D( , ).

[0128] It should be noted that the above examples of the second splicing feature are only exemplary. In practical applications, other examples may be used. For example, still using the above examples for illustration, the second splicing feature may also be Alternatively, the second splicing feature can also be Alternatively, the second splicing feature can also be .

[0129] Step 311: Determine a first loss value according to the first output value and the second output value.

[0130] In the embodiment of the present disclosure, the first loss value may be determined according to the first output value and the second output value.

[0131] For example, the first output value is D( , ), the second output value is D( , ), the first loss value can be determined according to the following formula:

[0132] ; (1)

[0133] Where B is the encoding network of the text classification model, D is the discriminator of the adversarial network in the text classification model, G is the generator of the adversarial network in the text classification model, V(D,B,G) is the first loss value, and E(·) represents the expectation of the distribution function.

[0134] Step 312: Perform a first training on the text classification model according to the first loss value.

[0135] In an embodiment of the present disclosure, the text classification model may be first trained based on the first loss value.

[0136] As an example, the model parameters of the encoding network in the text classification model and the model parameters of the generator of the adversarial network in the text classification model can be adjusted according to the first loss value to minimize the value of the first loss value. For example, according to formula (1), the model parameters in the text classification model are adjusted so that the model parameters of the encoding network and the generator can be updated by gradient descent, and the model parameters of the discriminator can be updated by gradient ascent, that is, the following minimum-maximum objective function is satisfied:

[0137] ; (2)

[0138] It should be noted that the above only uses the termination condition of the first training of the text classification model as an example of minimizing the first loss value. In actual application, other termination conditions can also be set. For example, the termination condition can be that the number of training times reaches a set number, or the termination condition can be that the training time reaches a set time, etc. The present disclosure does not impose any restrictions on this.

[0139] Therefore, the adversarial network based on the text classification model can enable the encoding network of the text classification model to learn the semantic features of the training text in the absence of labeled data.

[0140] The training method of the text classification model of the embodiment of the present disclosure is as follows: the fusion feature is input into the generator in the adversarial network of the text classification model to obtain the second semantic feature output by the generator; the first semantic feature is input into the discriminator in the adversarial network to obtain the first output value output by the discriminator; the second semantic feature is input into the discriminator to obtain the second output value output by the discriminator; a first loss value is determined based on the first output value and the second output value; and the text classification model is first trained based on the first loss value. Thus, the adversarial network based on the text classification model can enable the text classification model to learn the semantic features of the training text without the need for labeled data, thereby improving the performance and performance of the text classification model and thus improving the accuracy and reliability of the model prediction results.

[0141] The above are various embodiments corresponding to the training method of the text classification model. The present disclosure also proposes an application method of the text classification model, namely, a text classification method.

[0142] Figure 4 This is a flowchart of the text classification method provided in the fourth embodiment of the present disclosure.

[0143] like Figure 4 As shown, the text classification method may include the following steps:

[0144] Step 401: Obtain power production information.

[0145] In the embodiment of the present disclosure, the power production information may include power dispatch text, power production meeting content, power production daily report, power production weekly report, etc., and the present disclosure does not impose any restrictions on this.

[0146] In the embodiments of the present disclosure, there is no restriction on the method of obtaining power production information. For example, the power production information can be collected online, for example, the power production information can be collected online through web crawler technology, or the power production information can also be collected offline, or the power production information can also be input by the user, etc. The present disclosure does not impose any restrictions on this.

[0147] Step 402: Encode the power production information using the encoding network in the trained text classification model to obtain semantic features.

[0148] The text classification model may be obtained by training using the text classification model training method proposed in any of the above embodiments.

[0149] In an embodiment of the present disclosure, an encoding network in a trained text classification model may be used to encode power production information to obtain semantic features.

[0150] As an example, the power production information can be segmented to obtain target segmentations in the power production information; after obtaining the initial vector corresponding to each target segmentation, the initial vectors corresponding to each target segmentation can be combined based on the position of each target segmentation in the power production information to obtain an input vector; and the input vector can be input into the encoding network in the text classification model to encode the input vector using the encoding network to obtain semantic features.

[0151] Step 403: input the semantic features into the classification network in the text classification model for classification to obtain the category to which the power production information belongs.

[0152] In the embodiment of the present disclosure, the semantic features may be input into the classification network in the text classification model for classification, and the category to which the power production information belongs may be obtained.

[0153] The text classification method of the embodiments of the present disclosure obtains power production information; encodes the power production information using an encoding network in a trained text classification model to obtain semantic features; wherein the text classification model is trained using the text classification model training method proposed in any of the above embodiments of the present disclosure; and inputs the semantic features into the classification network in the text classification model for classification to obtain the category to which the power production information belongs. This enables automatic classification of power production information based on deep learning technology, improving classification effectiveness, namely, improving the accuracy and reliability of the classification results.

[0154] As an example, the use of generative adversarial networks to train a text classification model is used as an example, wherein the BERT model can be used as the encoding network for power production information, that is, the encoding network of the text classification model is the BERT model. By encoding the power production information through the BERT model, the semantic representation of the power production information can be obtained (recorded as the first semantic feature in this disclosure). The semantic representation of the power production information is combined with the Gaussian prior to obtain a fusion feature; and the fusion feature can be encoded by the generator to obtain a representation vector (recorded as the second semantic feature in this disclosure); the representation vector is input as a negative sample to the discriminator (also called a discriminator); at the same time, the semantic representation obtained by the BERT model can be input as a positive sample to the discriminator. Thus, the text classification model can be optimized to the optimal solution through adversarial training between the generator and the discriminator. Among them, the training principle diagram of the text classification model of the present disclosure can be shown as follows: Figure 5 shown.

[0155] Specifically, the encoding network of the text classification model uses the BERT model, whose goal is to use large-scale unlabeled corpus to perform the first training of the text classification model and obtain a semantic representation of the power production information containing rich semantic information, which can ultimately be applied to the text classification task. The main input of the BERT model is the original word vector (referred to as word vector in this disclosure) of each word segment in the power production information. The original word vector of each word segment can be generated by random initialization, and the word vectors corresponding to each word segment can be combined to obtain an input vector. This input vector is input into the BERT model, which can output a vector representation of each word segment in the power production information that integrates the semantic information of the entire text, i.e., the semantic representation of the power production information.

[0156] It should be noted that the BERT model includes 12 layers of Transformer, and each layer of Transformer includes a forward propagation layer and a multi-head attention layer. In order to differentiate the representation of each word segment using different contextual semantic information, the present disclosure adopts an attention mechanism to obtain the weight of the context for each word segment. Among them, in the operation process of the attention mechanism, the combined representation matrix of the key vector (Key vector), query vector (Query vector) and value vector (Value vector) can be used as the input matrix of the next layer of Transformer, and the above three vectors can form three corresponding weight matrices, which are respectively denoted as W K 、W Q and W V In order to enhance the diversity of the attention mechanism, the present disclosure adopts multiple different self-attention modules to encode each word of the power production information, and can obtain the enhanced semantic vector of each word in the power production information in different semantic spaces, that is, the encoding vector in the present disclosure; for any word, the multiple encoding vectors of any word can be linearly combined to obtain the semantic vector of each word.

[0157] In the related art, the task of the generator module is to generate negative samples based on samples extracted from the Gaussian distribution. Among them, the generator uses 1 fully connected layer and 3 deconvolution layers to learn the Gaussian distribution to obtain a false embedding. Inspired by the generative adversarial network (GAN), for high-dimensional data, if the generator of the generative adversarial network of the text classification model in the present disclosure only processes samples generated by the Gaussian distribution (referred to as noise features in the present disclosure), this approach is meaningless. Because it is necessary to capture the semantic changes in the latent space of the text from the Gaussian distribution, therefore, in the present disclosure, the vector of the generator in the generative adversarial network input to the text classification model can use the first semantic feature combined with the Gaussian distribution to construct the above-mentioned false embedding, that is, the first semantic feature is fused with the noise feature to obtain a fused feature.

[0158] Assume that the first semantic feature is Z, the noise feature is Y, and the fusion feature It can be determined according to the following formula:

[0159] ; (3)

[0160] Finally, a bilinear binary classification network can be used as a discriminator to distinguish positive and negative samples and perform the first training of the text classification model.

[0161] It can be seen that the text classification model of the present disclosure includes an encoding network B, a generator G, and a discriminator D. In order to implement the first training of the text classification model, the optimization function of the following formula (4) can be used:

[0162] ; (4)

[0163] B(X)=Z; (5)

[0164] Where X is the input vector, B(X) is the first semantic feature after the encoding network B encodes the input vector X, and Z is the first semantic feature. is the fusion feature after the noise feature Y is fused with the first semantic feature Z, To input the fusion feature into the generator G to obtain the second semantic feature, P r is the positive sample distribution, P g is the negative sample distribution.

[0165] The above optimization function is a minimum-maximum objective function, and this optimization function can use the same alternating stochastic gradient as a general generative adversarial network to optimize the text classification model of the present disclosure (i.e., perform the first training of the text classification model). In each iteration, the parameter matrix of the discriminator can be updated by taking one or more steps in the positive gradient direction, while the parameters of the encoding network and the parameters of the generator can be updated together by taking one step in the negative gradient direction.

[0166] Therefore, the text classification model disclosed in this paper draws on the idea of adversarial learning and uses the mutual game learning between the generator and the discriminator of the adversarial network to produce good output results. The training principle of the text classification model disclosed in this paper is as follows: Figure 5 shown.

[0167] The text classification model disclosed in this paper can be used to address the problems of existing methods, such as long model construction time due to processing massive amounts of data and high data annotation costs during the fine-tuning phase. Specifically, its advantages can be reflected in the following two aspects:

[0168] 1. In the field of text classification, traditional model training requires a large amount of labeled data and huge parameters. The text classification method based on generative adversarial networks proposed in this paper can effectively reduce the model's dependence on labeled data.

[0169] 2. In the process of constructing negative samples, if random distribution is directly used, the negative samples will be meaningless, and the embedding of meaningless negative samples will affect the optimization training of the model. The combination of Gaussian distribution and true embedding used in the text classification model of this disclosure can train a more robust encoding network.

[0170] With the above Figures 1 to 3 Corresponding to the training method of the text classification model provided in the embodiment, the present disclosure also provides a training device for a text classification model. Figures 1 to 3 The training method of the text classification model provided in the embodiment corresponds to the embodiment, so the implementation method of the text classification model training method is also applicable to the training device of the text classification model provided in the embodiment of the present disclosure, and will not be described in detail in the embodiment of the present disclosure.

[0171] Figure 6 This is a structural diagram of the training device for the text classification model provided in Example 5 of the present disclosure.

[0172] like Figure 6 As shown, the text classification model training device 600 may include: a processing module 601 , an acquisition module 602 , a fusion module 603 and a first training module 604 .

[0173] The processing module 601 is used to obtain a training text and encode the training text using an encoding network in a text classification model to obtain a first semantic feature.

[0174] The acquisition module 602 is configured to acquire a noise feature, wherein the size of the noise feature matches the size of the first semantic feature.

[0175] The fusion module 603 is configured to fuse the noise feature and the first semantic feature to obtain a fused feature.

[0176] The first training module 604 is configured to perform a first training on the text classification model based on the first semantic feature and the fusion feature.

[0177] In a possible implementation of an embodiment of the present disclosure, the processing module 601 is used to: perform word segmentation processing on a training text to obtain at least one word segmentation of the training text; obtain a word vector corresponding to at least one word segmentation; combine the word vectors corresponding to at least one word segmentation based on the position of the at least one word segmentation in the training text to obtain an input vector; input the input vector into an encoding network in a text classification model to encode the input vector using the encoding network to obtain a first semantic feature.

[0178] In a possible implementation of an embodiment of the present disclosure, the first semantic feature includes a semantic vector of each word in the training text, and the processing module 601 is used to: input the input vector into the encoding network in the text classification model, so as to use the encoding network to encode each word based on multiple attention mechanisms, and obtain multiple encoding vectors corresponding to each word; for any word, the multiple encoding vectors corresponding to the word are fused to obtain the semantic vector corresponding to the word.

[0179] In a possible implementation of an embodiment of the present disclosure, the first training module 604 is used to: input the fused feature into the generator in the adversarial network in the text classification model to obtain the second semantic feature output by the generator; input the first semantic feature into the discriminator in the adversarial network to obtain the first output value output by the discriminator; input the second semantic feature into the discriminator to obtain the second output value output by the discriminator; determine a first loss value based on the first output value and the second output value; and perform a first training on the text classification model based on the first loss value.

[0180] In a possible implementation of the embodiment of the present disclosure, the first training module 604 is configured to: concatenate the first semantic feature and the input vector to obtain a first concatenated feature; and input the first concatenated feature into a discriminator to obtain a first output value output by the discriminator.

[0181] In a possible implementation of the embodiment of the present disclosure, the first training module 604 is configured to: concatenate the first semantic feature and the second semantic feature to obtain a second concatenated feature; and input the second concatenated feature into a discriminator to obtain a second output value output by the discriminator.

[0182] In a possible implementation of the embodiment of the present disclosure, the text classification model training device 600 may further include:

[0183] The encoding module is used to re-encode the training text using the encoding network in the first trained text classification model to obtain a third semantic feature.

[0184] The classification module is used to input the third semantic feature into the classification network in the first trained text classification model for classification, so as to obtain the predicted category to which the training text belongs.

[0185] The generation module is used to generate a second loss value according to the difference between the labeled category and the predicted category on the training text.

[0186] The second training module is used to perform a second training on the text classification model that has undergone the first training according to the second loss value.

[0187] The training device for the text classification model of the embodiment of the present disclosure obtains training text and encodes the training text using the encoding network in the text classification model to obtain a first semantic feature; obtains a noise feature; wherein the size of the noise feature matches that of the first semantic feature; fuses the noise feature and the first semantic feature to obtain a fused feature; and performs a first training on the text classification model based on the first semantic feature and the fused feature. Thus, the semantic features of the training text captured by the encoding network of the text classification model and the semantic features fused with the noise can be used to pre-train the text classification model, so that the text classification model can effectively learn the significant semantic information in the training text before actual training, thereby improving the performance and performance of the model when the text classification model is actually trained using a small amount of training text, and effectively reducing the model's dependence on labeled data.

[0188] With the above Figure 4 Corresponding to the text classification method provided in the embodiment, the present disclosure also provides a text classification device. Since the text classification device provided in the embodiment of the present disclosure is consistent with the above Figure 4 The text classification method provided in the embodiment corresponds to the text classification method, so the implementation of the text classification method is also applicable to the text classification device provided in the embodiment of the present disclosure, and will not be described in detail in the embodiment of the present disclosure.

[0189] Figure 7 This is a structural diagram of the text classification device provided in Example 6 of the present disclosure.

[0190] like Figure 7 As shown, the text classification device 700 may include: an acquisition module 701 , an encoding module 702 and a classification module 703 .

[0191] The acquisition module 701 is used to acquire power production information.

[0192] The encoding module 702 uses the encoding network in the trained text classification model to encode the power production information to obtain semantic features; wherein the text classification model is based on the above-mentioned Figure 6 The text classification model is obtained by training using the training device of the embodiment.

[0193] The classification module 703 is used to input the semantic features into the classification network in the text classification model for classification, so as to obtain the category to which the power production information belongs.

[0194] The text classification device of an embodiment of the present disclosure obtains power production information; encodes the power production information using an encoding network in a trained text classification model to obtain semantic features; wherein the text classification model is trained using the text classification model training method proposed in any of the above embodiments of the present disclosure; and inputs the semantic features into the classification network in the text classification model for classification to obtain the category to which the power production information belongs. This enables automatic classification of power production information based on deep learning technology, improving classification effectiveness, namely, improving the accuracy and reliability of the classification results.

[0195] In order to implement the above embodiments, the present disclosure also proposes an electronic device, which is characterized in that it includes a memory, a processor, and a computer program stored in the memory and runnable on the processor. When the processor executes the program, it implements the training method of the text classification model proposed in any of the aforementioned embodiments of the present disclosure.

[0196] In order to implement the above embodiments, the present disclosure further proposes a non-temporary computer-readable storage medium on which a computer program is stored. When the program is executed by a processor, it implements the training method of the text classification model proposed in any of the above embodiments of the present disclosure.

[0197] In order to implement the above embodiments, the present disclosure further provides a computer program product. When the instructions in the computer program product are executed by a processor, the training method of the text classification model proposed in any of the above embodiments of the present disclosure is performed.

[0198] like Figure 8 As shown, electronic device 12 is implemented as a general-purpose computing device. Components of electronic device 12 may include, but are not limited to, one or more processors or processing units 16, system memory 28, and a bus 18 that connects various system components (including system memory 28 and processing unit 16).

[0199] Bus 18 represents one or more of several types of bus structures, including a memory bus or memory controller, a peripheral bus, an accelerated graphics port, a processor, or a local bus using any of a variety of bus architectures. Examples of these architectures include, but are not limited to, the Industry Standard Architecture (ISA) bus, the Micro Channel Architecture (MAC) bus, the Enhanced ISA bus, the Video Electronics Standards Association (VESA) local bus, and the Peripheral Component Interconnection (PCI) bus.

[0200] The electronic device 12 typically includes a variety of computer system readable media. These media can be any available media that can be accessed by the electronic device 12, including volatile and non-volatile media, removable and non-removable media.

[0201] The memory 28 may include computer system readable media in the form of volatile memory, such as random access memory (RAM) 30 and / or cache memory 32. The electronic device 12 may further include other removable / non-removable, volatile / non-volatile computer system storage media. By way of example only, the storage system 34 may be configured to read and write non-removable, non-volatile magnetic media ( Figure 8 Not shown, usually called a "hard drive"). Although Figure 8 Although not shown, a disk drive for reading and writing to a removable non-volatile disk (e.g., a floppy disk) and an optical disk drive for reading and writing to a removable non-volatile optical disk (e.g., a Compact Disc Read Only Memory (CD-ROM), a Digital Video Disc Read Only Memory (DVD-ROM), or other optical media) may be provided. In these cases, each drive may be connected to bus 18 via one or more data media interfaces. Memory 28 may include at least one program product having a set (e.g., at least one) of program modules configured to perform the functions of various embodiments of the present disclosure.

[0202] A program / utility 40 having a set (at least one) of program modules 42 may be stored, for example, in memory 28. Such program modules 42 include, but are not limited to, an operating system, one or more application programs, other program modules, and program data, each of which, or some combination thereof, may include an implementation of a network environment. Program modules 42 generally implement the functions and / or methodologies described in the embodiments of the present disclosure.

[0203] The electronic device 12 can also communicate with one or more external devices 14 (e.g., a keyboard, pointing device, display 24, etc.), one or more devices that enable a user to interact with the electronic device 12, and / or any device that enables the electronic device 12 to communicate with one or more other computing devices (e.g., a network card, a modem, etc.). This communication can occur via an input / output (I / O) interface 22. Furthermore, the electronic device 12 can communicate with one or more networks (e.g., a local area network (LAN), a wide area network (WAN), and / or a public network such as the Internet) via a network adapter 20. As shown, the network adapter 20 communicates with other modules of the electronic device 12 via the bus 18. It should be understood that, although not shown, other hardware and / or software modules may be used in conjunction with the electronic device 12, including but not limited to microcode, device drivers, redundant processing units, external disk drive arrays, RAID systems, tape drives, and data backup storage systems.

[0204] The processing unit 16 executes various functional applications and data processing by running programs stored in the system memory 28, such as implementing the methods mentioned in the above embodiments.

[0205] In the description of this specification, the reference terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" mean 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 disclosure. In this specification, the schematic expressions of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art can combine and combine different embodiments or examples described in this specification and features of different embodiments or examples without contradiction.

[0206] Furthermore, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features being referred to. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. Throughout the present disclosure, "plurality" means at least two, such as two, three, etc., unless otherwise specifically defined.

[0207] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment 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 disclosure includes additional implementations in which functions may be performed out of 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 those skilled in the art to which the embodiments of the present disclosure belong.

[0208] The logic and / or steps represented in a flowchart or otherwise described herein, for example, can be considered a sequenced list of executable instructions for implementing the logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (e.g., a computer-based system, a system including a processor, or other system that can fetch and execute instructions from an instruction execution system, apparatus, or device). For purposes of this specification, a "computer-readable medium" is any device that can contain, store, communicate, propagate, or transport a program for use by, or in conjunction with, an instruction execution system, apparatus, or device. More specific examples (not exhaustive) of computer-readable media include: an electrical connection with one or more wires (electronic devices), a portable computer disk cartridge (magnetic device), random access memory (RAM), read-only memory (ROM), erasable and programmable read-only memory (EPROM or flash memory), fiber optic devices, and a portable compact disc read-only memory (CDROM). Furthermore, 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 it in another suitable manner if necessary, and then storing it in a computer memory.

[0209] It should be understood that various parts of the present disclosure can be implemented using hardware, software, firmware, or a combination thereof. In the above-described embodiments, multiple steps or methods can be implemented using software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented using hardware, as in another embodiment, any one of the following technologies known in the art or a combination thereof can be used: a discrete logic circuit having logic gate circuits for implementing logical functions on data signals, an application-specific integrated circuit having suitable combinational logic gate circuits, a programmable gate array (PGA), a field-programmable gate array (FPGA), etc.

[0210] Those skilled in the art will understand that all or part of the steps in the method of the above embodiment can be completed by instructing related hardware through a program, and the program can be stored in a computer-readable storage medium. When the program is executed, it includes one or a combination of the steps of the method embodiment.

[0211] In addition, the functional units in the various embodiments of the present disclosure may be integrated into a single processing module, or each unit may exist physically separately, or two or more units may be integrated into a single module. The aforementioned integrated modules may be implemented in the form of hardware or in the form of software functional modules. If the integrated modules are implemented in the form of software functional modules and sold or used as independent products, they may also be stored in a computer-readable storage medium.

[0212] 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 disclosure have been shown and described above, it is understood that the above embodiments are exemplary and should not be construed as limiting the present disclosure. A person of ordinary skill in the art may make changes, modifications, substitutions, and variations to the above embodiments within the scope of the present disclosure.

Claims

1. A training method for a text classification model, characterized in that: The method comprises: Acquire a training text, and encode the training text using an encoding network in a text classification model to obtain a first semantic feature; Acquire a noise feature; wherein the size of the noise feature matches the size of the first semantic feature; fusing the noise feature and the first semantic feature to obtain a fused feature; Performing a first training on the text classification model based on the first semantic feature and the fusion feature; The step of encoding the training text using an encoding network in a text classification model to obtain a first semantic feature includes: Performing word segmentation processing on the training text to obtain at least one word segment of the training text; Obtaining a word vector corresponding to the at least one word segmentation; Combining word vectors corresponding to the at least one word segmentation based on a position of the at least one word segmentation in the training text to obtain an input vector; Inputting the input vector into an encoding network in the text classification model, so as to encode the input vector using the encoding network to obtain the first semantic feature; The first training of the text classification model based on the first semantic feature and the fusion feature includes: Inputting the fused feature into the generator in the adversarial network in the text classification model to obtain a second semantic feature output by the generator; Concatenating the first semantic feature and the input vector to obtain a first concatenated feature; Inputting the first splicing feature into a discriminator to obtain a first output value output by the discriminator; concatenating the first semantic feature and the second semantic feature to obtain a second concatenated feature; Inputting the second splicing feature into the discriminator to obtain a second output value output by the discriminator; determining a first loss value according to the first output value and the second output value; Performing a first training on the text classification model according to the first loss value.

2. The method according to claim 1, wherein The first semantic feature includes the semantic vector of each word in the training text, Inputting the input vector into the encoding network in the text classification model to encode the input vector using the encoding network to obtain the first semantic feature includes: Inputting the input vector into the encoding network in the text classification model, so as to encode each of the segmented words using the encoding network based on multiple attention mechanisms, and obtaining multiple encoding vectors corresponding to each of the segmented words; For any of the word segments, multiple encoding vectors corresponding to the word segment are fused to obtain a semantic vector corresponding to the word segment.

3. The method according to any one of claims 1 to 2, characterized in that The method further comprises: Re-encoding the training text using the encoding network in the text classification model that has undergone the first training to obtain a third semantic feature; Inputting the third semantic feature into the classification network in the first trained text classification model for classification to obtain a predicted category to which the training text belongs; generating a second loss value according to a difference between the labeled category on the training text and the predicted category; According to the second loss value, the text classification model that has undergone the first training is subjected to a second training.

4. A text classification method, characterized in that: The method comprises: Obtaining electricity production information; Encoding the power production information using an encoding network in a trained text classification model to obtain semantic features; wherein the text classification model is trained using the method according to any one of claims 1 to 3; The semantic features are input into the classification network in the text classification model for classification to obtain the category to which the power production information belongs.

5. A training device for a text classification model, characterized in that: The device comprises: A processing module, configured to obtain a training text and encode the training text using an encoding network in a text classification model to obtain a first semantic feature; An acquisition module, configured to acquire a noise feature; wherein the noise feature and the first semantic feature have a size matching each other; a fusion module, configured to fuse the noise feature with the first semantic feature to obtain a fused feature; A first training module, configured to perform a first training on the text classification model based on the first semantic feature and the fusion feature; Wherein, the processing module is further used for: Performing word segmentation processing on the training text to obtain at least one word segment of the training text; Obtaining a word vector corresponding to the at least one word segmentation; Combining word vectors corresponding to the at least one word segmentation based on a position of the at least one word segmentation in the training text to obtain an input vector; Inputting the input vector into an encoding network in the text classification model, so as to encode the input vector using the encoding network to obtain the first semantic feature; The first training module is further used to: Inputting the fused feature into the generator in the adversarial network in the text classification model to obtain a second semantic feature output by the generator; Concatenating the first semantic feature and the input vector to obtain a first concatenated feature; Inputting the first splicing feature into a discriminator to obtain a first output value output by the discriminator; concatenating the first semantic feature and the second semantic feature to obtain a second concatenated feature; Inputting the second splicing feature into the discriminator to obtain a second output value output by the discriminator; determining a first loss value according to the first output value and the second output value; Performing a first training on the text classification model according to the first loss value.

6. A text classification device, characterized in that: The device comprises: An acquisition module, used to obtain power production information; an encoding module, which encodes the power production information using an encoding network in a trained text classification model to obtain semantic features; wherein the text classification model is trained using the apparatus according to claim 5; A classification module is used to input the semantic features into the classification network in the text classification model for classification, so as to obtain the category to which the power production information belongs.

Citation Information

Patent Citations

  • An unbiased mapping zero sample classification method and device based on a generative adversarial network

    CN109816032A

  • Emotion difference privacy protection method based on generative adversarial network

    CN111666588A