Method for training emotion classification model, method for predicting emotion classification, and electronic device

By introducing word vectors and attribute word vector matrices, and training a sentiment classification model using a preset loss function, the accuracy of sentiment classification is improved by utilizing prompt information. This solves the problems of low accuracy and high cost in existing technologies and is applicable to attribute-level text sentiment classification.

CN116226381BActive Publication Date: 2026-06-16EAST CHINA UNIV OF SCI & TECH

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
EAST CHINA UNIV OF SCI & TECH
Filing Date
2023-01-18
Publication Date
2026-06-16

Smart Images

  • Figure CN116226381B_ABST
    Figure CN116226381B_ABST
Patent Text Reader

Abstract

The application relates to the field of model training, and discloses a training method of a sentiment classification model, a sentiment classification prediction method and electronic equipment, which comprises the following steps: receiving text data, actual attribute labels and actual sentiment labels corresponding to the text data, obtaining word vector representation of the text data and an attribute word vector matrix, the text data being obtained by splicing review text and prompt information of users in the same field, the prompt information being used for guiding the sentiment classification model to perform sentiment classification on attributes of the text data; extracting attribute features and sentiment features based on the word vector representation and the attribute word vector matrix; obtaining predicted attribute labels based on the attribute features and predicted sentiment labels based on the sentiment features; and training the sentiment classification model based on a loss function, combining the actual attribute labels, the actual sentiment labels, the predicted attribute labels and the predicted sentiment labels until convergence is achieved, so that a trained sentiment classification model is obtained, the accuracy of sentiment classification is improved, and the time and labor costs are reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of model training, and more particularly to a training method for a sentiment classification model, a sentiment classification prediction method, and an electronic device. Background Technology

[0002] With the rapid development of the internet, users can share their preferences and opinions on various software platforms. This has led to a surge in online discussions about products, people, current events, and shops. These discussions contain a wealth of user sentiment, which, in the era of big data, holds significant value for analysis and discovery. Therefore, the need for automatic sentiment classification has made it a popular area of ​​Natural Language Processing (NLP).

[0003] However, with the explosive growth of data, different users express themselves in different ways, and it becomes time-consuming and labor-intensive for various software to recommend choices that meet people's needs and preferences. Therefore, general sentiment analysis methods suffer from low accuracy, high time and labor costs. Summary of the Invention

[0004] The purpose of this invention is to solve the above-mentioned problems by providing a training method for a sentiment classification model, a sentiment classification prediction method, and an electronic device, which solves the problems of low accuracy, high time cost, and high labor cost in text sentiment analysis.

[0005] To address the aforementioned issues, embodiments of this application provide a training method for a sentiment classification model, comprising: receiving text data and corresponding actual attribute labels and actual sentiment labels; obtaining word vector representations and attribute word vector matrices of the text data, wherein the text data is obtained by concatenating comment texts and prompts from users within the same domain, and the prompts are used to guide the sentiment classification model to be trained to classify the attributes of the text data into sentiment categories; extracting attribute features and sentiment features of the text data based on the word vector representations and attribute word vector matrices; obtaining predicted attribute labels of the text data based on the attribute features, and obtaining predicted sentiment labels of the text data based on the sentiment features; and training the sentiment classification model to be trained based on a preset loss function, combining the actual attribute labels, actual sentiment labels, predicted attribute labels, and predicted sentiment labels until convergence, thereby obtaining a trained sentiment classification model.

[0006] To address the aforementioned issues, embodiments of this application provide a sentiment classification prediction method, comprising: acquiring text data to be predicted; and using a sentiment classification model trained using the aforementioned sentiment classification model training method to perform sentiment classification prediction on the text data to be predicted.

[0007] To address the aforementioned problems, embodiments of this application also provide an electronic device, comprising: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the training method of the aforementioned sentiment classification model, or to perform the aforementioned sentiment classification prediction method.

[0008] To address the aforementioned issues, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the training method for the aforementioned sentiment classification model, or executes the aforementioned sentiment classification prediction method.

[0009] The training method for the sentiment classification model proposed in this application involves inputting text data with concatenated prompt information into the sentiment classification model to be trained. This enables the sentiment classification model to process the input comment text according to the prompt information, solving the problem of reduced classification accuracy due to insufficient corpus in attribute-level text sentiment classification tasks. At the same time, it eliminates the need for attribute and sentiment annotation of a large amount of corpus, reducing the manual and time costs of model training.

[0010] In one example, obtaining the word vector representation and attribute word vector matrix of text data includes: projecting the text data into the embedding space of the sentiment classification model to be trained to obtain the word vector representation of the text data; and encoding the attribute set in the text data to obtain the attribute word vector matrix of the text data.

[0011] In one example, the extraction of attribute features from text data based on word vector representations and attribute word vector matrices includes: inputting the word vector representations into a bidirectional encoding representation converter to obtain the hidden layer state matrix of the bidirectional encoding representation converter; performing average pooling on the last layer of the hidden layer state matrix to obtain the average representation of the text data; and performing a dot product between the attribute word vector matrix and the average representation of the text data to obtain the attribute features of the text data.

[0012] In one example, obtaining predicted attribute labels for text data based on attribute features includes: using a fully connected layer to perform a linear transformation on the attribute features of the text data; wherein the fully connected layer is pre-set with Dropout release parameters; projecting the linearly transformed attribute features into the attribute label space to obtain the predicted attribute labels for the text data; wherein the attribute label space is composed of an attribute word vector matrix.

[0013] In one example, the prompt information contains N prompt templates, where N is an integer greater than 1; the process of extracting sentiment features includes: inputting word vector representations into the masked language model; obtaining predicted label word vectors from the output of the masked language model based on each of the N prompt templates; and summing the predicted label word vectors corresponding to the N prompt templates to obtain the sentiment features of the text data.

[0014] In one example, the prompt information includes the correspondence between sentiment tags and preset sentiment tags; wherein, each preset sentiment tag corresponds to at least one sentiment tag word; the process of obtaining the predicted sentiment tag of the text data based on sentiment features includes: calculating the similarity between each sentiment tag word and the sentiment features; and selecting the preset sentiment tag corresponding to the sentiment tag word with the highest similarity as the predicted sentiment tag of the text data.

[0015] In one example, the cross-entropy loss is calculated between the actual attribute labels and the predicted attribute labels of the text data to obtain the attribute classification loss; the cross-entropy loss is calculated between the actual sentiment labels and the predicted sentiment labels of the text data to obtain the sentiment classification loss; the attribute classification loss and the sentiment classification loss are weighted and summed to obtain the model loss; the sentiment classification model to be trained is trained based on the model loss until convergence. Attached Figure Description

[0016] One or more embodiments are illustrated by way of example with reference numerals in the accompanying drawings. These illustrations do not constitute a limitation on the embodiments. Elements with the same reference numerals in the drawings are denoted as similar elements. Unless otherwise stated, the figures in the drawings are not to be limited by scale.

[0017] Figure 1 This is a flowchart of a training method for an emotion classification model provided in an embodiment of this application;

[0018] Figure 2 This is a diagram demonstrating the effectiveness of an emotion classification model provided in one embodiment of this application.

[0019] Figure 3 This is an embodiment of the sentiment classification prediction method provided in this application;

[0020] Figure 4 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0021] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the various embodiments of this application will be described in detail below with reference to the accompanying drawings. However, those skilled in the art will understand that many technical details have been presented in the various embodiments of this application to enable the reader to better understand this application. However, the technical solutions claimed in this application can be implemented even without these technical details and various changes and modifications based on the following embodiments.

[0022] One embodiment of this application relates to a training method for a sentiment classification model, comprising: receiving text data and corresponding actual attribute labels and actual sentiment labels; obtaining word vector representations and attribute word vector matrices of the text data, wherein the text data is obtained by concatenating comment texts and prompts from users in the same domain, and the prompts are used to guide the sentiment classification model to be trained to classify the attributes of the text data into sentiment; extracting attribute features and sentiment features of the text data based on the word vector representations and attribute word vector matrices; obtaining predicted attribute labels of the text data based on the attribute features, and obtaining predicted sentiment labels of the text data based on the sentiment features; training the sentiment classification model to be trained based on a preset loss function, combining the actual attribute labels, actual sentiment labels, predicted attribute labels, and predicted sentiment labels until convergence, thereby obtaining a trained sentiment classification model, which solves the problems of low accuracy, high time cost, and high labor cost in text sentiment analysis.

[0023] The following details the implementation of the training method for the sentiment classification model in this embodiment. This content is only for understanding the implementation details of this solution and is not essential for its implementation. The specific process is as follows: Figure 1 As shown, the steps may include the following:

[0024] In step 101, text data and the corresponding actual attribute tags and actual sentiment tags are received, and the word vector representation and attribute word vector matrix of the text data are obtained.

[0025] The text data is obtained by concatenating the comment texts of users in the same domain with prompts. The prompts are used to guide the sentiment classification model to be trained to classify the attributes of the text data according to sentiment.

[0026] In one example, the text data is obtained by concatenating preprocessed comment text and prompt information. The system receives text data used to train the sentiment feature model, as well as the actual attribute labels and actual sentiment labels corresponding to the text data, and obtains the word vector representation and attribute word vector matrix corresponding to the text data.

[0027] In one example, before the sentiment model to be trained receives the text data used for training, user review texts from the restaurant domain are obtained. The review texts are all in UTF-8 plain text format. The review texts are preprocessed as follows: the XML structure file is parsed, the feature columns are split, and review texts in the form of "text-attribute words-sentiment tendency" are constructed based on the feature columns. The constructed review texts are divided into review texts for training the sentiment model and review texts for testing sentiment features, namely the training set and the test set.

[0028] In one example, Python's standard library XML is used to parse the comment text. Based on the corresponding tags in the XML data file, each user's comment text is split into three parts: "text," "attribute words," and "sentiment." The Features method from the datasets library is then used to convert these three parts into three feature columns for the dataset. Specifically, the three feature columns for each text data point correspond to the text itself, the actual attribute tags, and the actual sentiment tags, respectively. In other words, when performing feature segmentation on the comment text, we can obtain each comment text along with its corresponding actual attribute tags and actual sentiment tags.

[0029] In one example, the sequence of user comment texts is concatenated with prompts to form a new text sequence, or text data, used for model training. For instance, each comment text is concatenated with the prompt to obtain the text data for training the model. For multi-attribute comment texts, each attribute in the comment text is concatenated with the prompt separately, splitting it into multiple single-attribute comment texts, which are then used for training.

[0030] In this embodiment, text data is projected into the embedding space of the sentiment classification model to be trained to obtain word vector representations of the text data; the attribute set in the text data is encoded to obtain the attribute word vector matrix of the text data.

[0031] In one example, in the encoding layer of the sentiment classification model, the tokenizer of the BERT (Bidirectional Encoder Representations from Transformers) model maps the words in the received text data into the model's embedding space, obtaining word vector representations of the text data. Simultaneously, it encodes the attribute set in the text data, obtaining a set of word vector representations of the attribute set, i.e., the attribute word vector matrix. .

[0032] In step 102, attribute features and sentiment features of the text data are extracted based on word vector representation and attribute word vector matrix.

[0033] In this embodiment, word vector representations are input into a bidirectional encoding representation converter model to obtain the hidden layer state matrix of the bidirectional encoding representation converter; average pooling is performed on the last layer of the hidden layer state matrix to obtain the average representation of the text data; and the attribute word vector matrix and the average representation of the text data are multiplied by a dot product to obtain the attribute features of the text data.

[0034] In one example, in the feature layer of the sentiment classification model, word vector representations of text data are fed into the BERT model to obtain the hidden state matrix of the bidirectional encoding representation converter model. Where e is the vector representation of the entire sentence. This represents the hidden state vector output by the i-th layer. After obtaining the hidden state matrix of the model, the last layer in the hidden state matrix... Average pooling is used to obtain the average representation of the text data. The specific formula is as follows:

[0035]

[0036]

[0037] Where 'c' represents the hidden layer.

[0038] The attribute word vector matrix A is compared with the average representation of the text data. Perform dot product calculations to obtain features with fused attribute information. The attribute features of text data are calculated using the following formula:

[0039]

[0040] Among them, b n Attributes that represent text data.

[0041] In this embodiment of the application, the prompt information includes N prompt templates, where N is an integer greater than 1; the process of extracting sentiment features includes: inputting word vector representations into a masked language model; obtaining predicted label word vectors from the output of the masked language model based on each of the N prompt templates; and adding the predicted label word vectors corresponding to the N prompt templates to obtain the sentiment features of the text data.

[0042] In one example, a prompt template is constructed based on the characteristics of the user's comment text and the attribute-level sentiment classification task. The attribute-level sentiment classification task refers to classifying the sentiment polarity of a certain attribute of the target object being evaluated. Based on the above characteristics, multiple prompt templates are constructed, with the template content as follows:

[0043] 1. The aspect is mask.

[0044] 2. I felt the {aspect} was [MASK]

[0045] 3. I [MASK] the {aspect}

[0046] 4. The {aspect} made me feel [MASK]

[0047] Here, {aspect} represents the corresponding attribute word to be filled in, and [MASK] indicates that the sentiment classification model will predict the sentiment tag word corresponding to the filled attribute here. Each sentiment tag word has its corresponding preset sentiment tag, and one preset sentiment tag word corresponds to multiple sentiment tag words.

[0048] In one example, the preset sentiment labels include: positive, negative, neural, and conflict. During model training, text data containing the "conflict" sentiment label is removed as input to the sentiment classification model, avoiding noise masking during model development. Label mappings are constructed based on the given prompt templates, specifically: ① positive→good, negative→bad, neural→ok. ② positive→satisfying, negative→bad, neural→ok. ③ positive→love, negative→hate, neural→dislike. ④ positive→happy, negative→sad, neural→indifferent. These mappings make the label words closer to natural language semantics, facilitating the sentiment classification model's prediction and classification of sentiment labels for each attribute.

[0049] In one example, word vector representations are input into an MLM (Masked Language Model). Based on each cue template, predicted label word vectors are extracted from the MLM output, i.e., the predicted label word vector representation at the [MASK] position for each cue template is predicted. The predicted label word vectors obtained from multiple [MASK] positions are summed to obtain the sentiment features of the text data. MLM is a pre-training task proposed by the BERT model for learning the contextual representation of text. This task uses flags to mask words, thereby learning their contextual content features to predict the masked words.

[0050] In step 103, the predicted attribute labels of the text data are obtained based on attribute features, and the predicted sentiment labels of the text data are obtained based on sentiment features.

[0051] In this embodiment, a fully connected layer is used to linearly transform the attribute features of the text data; wherein, the fully connected layer is pre-set with a Dropout release parameter; the linearly transformed attribute features are projected into the attribute label space to obtain the predicted attribute labels of the text data; wherein, the attribute label space is composed of an attribute word vector matrix.

[0052] In one example, a fully connected layer is used to perform a linear transformation on the attribute features of the text data. The transformed attribute features are then projected onto an attribute label control to obtain the predicted attribute labels for the text data. The specific formula is as follows:

[0053]

[0054] Where W is the learnable weight matrix and b is the learnable bias vector. The predicted attribute labels are shown below. Additionally, Dropout=0.3 is set in the fully connected layer to improve the model's generalization ability and prevent overfitting.

[0055] In this embodiment of the application, the prompt information includes the correspondence between sentiment tag words and preset sentiment tags; wherein, each type of preset sentiment tag corresponds to at least one sentiment tag word; the predicted sentiment tag of the text data is obtained based on sentiment features, including: for each sentiment tag word, performing similarity calculation with the sentiment features respectively; and selecting the preset sentiment tag corresponding to the sentiment tag word with the highest similarity as the predicted sentiment tag of the text data.

[0056] In one example, a traditional cue-based learning method is used to perform attribute-level sentiment classification of text data. The prediction result of the sentiment classification model at the [MASK] position, i.e., the predicted label word vector representation of the text data, is compared with each label word in the label mapping. Cosine similarity is selected as the metric, and the formula is as follows:

[0057]

[0058] in, To obtain the emotional feature representation, For the label word vector representation, the label corresponding to the label word with the highest similarity to the prediction result is selected as the predicted sentiment label of the text data. .

[0059] In step 104, based on a preset loss function, the emotion classification model to be trained is trained by combining the actual attribute labels, actual sentiment labels, predicted attribute labels, and predicted sentiment labels until convergence, thereby obtaining the trained emotion classification model.

[0060] In this embodiment, the actual attribute labels and predicted attribute labels of the text data are cross-entropy loss calculated to obtain the attribute classification loss; the actual sentiment labels and predicted sentiment labels of the text data are cross-entropy loss calculated to obtain the sentiment classification loss; the attribute classification loss and the sentiment classification loss are weighted and summed to obtain the model loss; the sentiment classification model to be trained is trained based on the model loss until convergence.

[0061] In one example, a multi-class cross-entropy loss function is used to calculate the attribute classification loss and sentiment classification loss separately, as follows:

[0062]

[0063] When calculating attribute classification loss, N represents the number of text data samples, and M represents the number of attribute categories in the text data. Indicates whether sample i belongs to category j. Let be the predicted probability that sample i belongs to category j.

[0064] When calculating the sentiment classification loss, N represents the number of text data samples, and M represents the number of sentiment categories in the text data. Indicates whether sample i belongs to category j. Let be the predicted probability that sample i belongs to category j.

[0065] The predicted attribute labels obtained from the prediction The attribute classification loss is obtained by calculating the cross-entropy loss with the corresponding actual attribute labels. The predicted sentiment labels The cross-entropy loss is calculated by comparing the data with the corresponding actual sentiment tags to obtain the sentiment classification loss. The model loss is obtained by weighted summation. The formula is as follows:

[0066]

[0067] Here, 'a' is an adjustable weight parameter, which is assigned a value according to the specific circumstances in the practical application of sentiment classification.

[0068] The sentiment classification model to be trained is trained based on the model loss function until it converges.

[0069] In one example, the sentiment classification model includes an encoding layer, a feature extraction layer, and a classification layer connected in sequence. The encoding layer receives the input text data, uses BERT's word segmenter to project the text data into the model's representation space, and obtains word vector representations of the text data, which serve as input to the feature extraction layer. The feature extraction layer extracts attribute features and sentiment features from the input text data, and the results serve as input to the classification layer. The classification layer performs classification prediction on the input text data based on the attribute features and sentiment features obtained from the feature extraction layer.

[0070] To verify the effectiveness of the sentiment classification model trained by the training method proposed in this application, experiments were conducted on the following four commonly used public datasets:

[0071] a) SemEval-2014 Task4 Restaurants (Res14)

[0072] b)SemEval-2014 Task4 Laptops (Lap14)

[0073] c)SemEval-2015 Task12 Restaurants (Res15)

[0074] d)SemEval-2016 Task5 Restaurants (Res16)

[0075] The datasets mentioned above contain review texts from the restaurant and laptop sectors. Each dataset is divided into training and test sets. The attribute words in the datasets have been labeled, and the corresponding sentiment labels are divided into positive, negative, and neutral.

[0076] In this experiment, the effectiveness of the attribute classification model will be tested. A sentiment classification model with the attribute classification module removed and a sentiment classification model will be used to perform sentiment tests on the attribute word "food" in the example "the food here was moderate at best". Specific details are as follows: Figure 2 As shown, (a) is the visualization result of the attention of the sentiment classification model to the sample after removing the attribute classification module, and (b) is the visualization result of the attention of the sentiment classification model (AWP-BERT) to the sample.

[0077] The top and bottom rows in the figure show the attention weights of the full sentence representation "[CLS]" and the attribute word "food" to each word in the text, respectively. (b) shows the visualization results of AWP-BERT's attention to the examples. From the first row of the figure, it can be seen that AWP-BERT's semantic representation attention is more focused on attribute words. In (a), although the semantic representation obtained from the model with attribute classification removed also has a high attention score for attribute words, its attention score on "here" is higher than that of attribute words. This shows that AWP-BERT can pay more attention to attribute words, further verifying that the attribute classification module can play a role in prompting the model to pay more attention to attribute word-related information.

[0078] Visualizing the "food" row in the figure reveals that in (b), the AWP-BERT model achieves the highest attention score for "moderate," while in (a), the highest attention score is for "best." This indicates that the sentiment classification model, after removing the attribute classification module, may misclassify "best" as a word containing sentiment information, thus affecting prediction accuracy. Comparing the two figures demonstrates that the proposed AWP-BERT model can more accurately focus on sentiment words related to sentiment tendency prediction. This further illustrates that introducing the attribute classification module allows the sentiment classification model to capture better attribute features. By enhancing the sentiment classification model's focus on attribute word information, it enables the model to achieve better results in attribute-level sentiment classification tasks.

[0079] The training method for the sentiment classification model proposed in this application combines the characteristics of attribute-level sentiment classification tasks with the technical features of multi-task learning and cue-based learning. It guides the sentiment classification model to perform sentiment polarity analysis on a specific attribute of text data through cue templates in the cue information. By mapping label words, the label words are made closer to natural language, making it easier for the sentiment classification model to predict and classify. The text data is converted into word vector representations, facilitating the extraction of attribute and sentiment features. Finally, the sentiment classification model is trained until convergence by minimizing a weighted loss function. This solves the problem of reduced classification accuracy due to insufficient corpus in attribute-level text sentiment classification tasks, while eliminating the need for attribute and sentiment annotation on large amounts of corpus, thus reducing the manual and time costs of model training.

[0080] This application also relates to a sentiment classification prediction method, comprising: acquiring text data to be predicted; and using the sentiment classification model trained by the aforementioned sentiment classification model training method to perform sentiment classification prediction on the text data to be predicted.

[0081] The following details the implementation of the sentiment classification prediction method in this embodiment. This content is only for understanding the implementation details of this solution and is not essential for its implementation. The specific process is as follows: Figure 3 As shown, the steps may include the following:

[0082] In step 301, the text data to be predicted is obtained.

[0083] In one example, we acquire the text data for which we need to perform sentiment classification prediction.

[0084] In step 302, the sentiment classification model trained using the above-described sentiment classification model training method is used to perform sentiment classification prediction on the text data to be predicted.

[0085] In one example, the acquired text data to be predicted is input into a trained sentiment classification model. The sentiment classification model performs sentiment classification on the text data to be predicted and outputs the sentiment classification result of the text data to be predicted.

[0086] The sentiment classification prediction method proposed in this application, by using the above-trained sentiment classification model, classifies various types of text data with different expression methods into sentiment, which can effectively help various software provide users with more accurate recommendation functions based on users' comment text.

[0087] The steps of the various methods described above are only for clarity. In practice, they can be combined into one step or some steps can be split into multiple steps. As long as they include the same logical relationship, they are all within the scope of protection of this patent. Adding insignificant modifications or introducing insignificant designs to the algorithm or process, but without changing the core design of the algorithm and process, are also within the scope of protection of this patent.

[0088] Embodiments of this application also provide an electronic device, such as... Figure 4 As shown, it includes at least one processor 401; and a memory 402 communicatively connected to the at least one processor 401; wherein the memory 402 stores instructions that can be executed by the at least one processor 401, the instructions being executed by the at least one processor 401 to enable the at least one processor to perform the above-described training method for the sentiment classification model, or to perform the above-described sentiment classification prediction method.

[0089] The memory and processor are connected via a bus, which can include any number of interconnecting buses and bridges, connecting various circuits of one or more processors and memories. The bus can also connect various other circuits, such as peripheral devices, voltage regulators, and power management circuits, which are well known in the art and will not be described further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be a single element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices over a transmission medium. Data processed by the processor is transmitted over the wireless medium via an antenna, which further receives data and transmits it to the processor.

[0090] The processor manages the bus and general processing, and also provides various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory is used to store data used by the processor during operation.

[0091] The above-mentioned products can perform the methods provided in the embodiments of this application, and have the corresponding functional modules and beneficial effects of performing the methods. For technical details not described in detail in this embodiment, please refer to the methods provided in the embodiments of this application.

[0092] Embodiments of this application also provide a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, it implements the above-described method embodiments.

[0093] Those skilled in the art will understand that all or part of the steps in the methods of the above embodiments can be implemented by a program instructing related hardware. This program is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as a USB flash drive, a portable hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0094] The above embodiments are provided for those skilled in the art to implement and use this application. Those skilled in the art can make various modifications or changes to the above embodiments without departing from the inventive concept of this application. Therefore, the protection scope of this application is not limited to the above embodiments, but should conform to the maximum scope of the innovative features mentioned in the claims.

Claims

1. A training method for an emotion classification model, characterized in that, include: Receive text data and the corresponding actual attribute tags and actual sentiment tags of the text data, and obtain the word vector representation and attribute word vector matrix of the text data. The text data is obtained by concatenating the comment text of users in the same domain and the prompt information. The prompt information is used to guide the sentiment classification model to be trained to classify the attributes of the text data for sentiment. Based on the word vector representation and attribute word vector matrix, attribute features and sentiment features of the text data are extracted; Based on the attribute features, the predicted attribute labels of the text data are obtained, and based on the sentiment features, the predicted sentiment labels of the text data are obtained. Based on a preset loss function, the actual attribute label, the actual sentiment label, the predicted attribute label, and the predicted sentiment label are combined to train the sentiment classification model to be trained until convergence, thereby obtaining a trained sentiment classification model. The step of extracting attribute features from the text data based on the word vector representation and the attribute word vector matrix includes: The word vector representation is input into the bidirectional encoding representation converter to obtain the hidden layer state matrix of the bidirectional encoding representation converter; The last layer of the hidden layer state matrix is ​​subjected to average pooling to obtain the average representation of the text data. The attribute word vector matrix is ​​multiplied by the average representation of the text data to obtain the attribute features of the text data. The step of training the sentiment classification model to be trained until convergence based on a preset loss function, combined with the actual attribute labels, the actual sentiment labels, the predicted attribute labels, and the predicted sentiment labels, includes: The attribute classification loss is obtained by calculating the cross-entropy loss between the actual attribute labels of the text data and the predicted attribute labels. The cross-entropy loss is calculated by comparing the actual sentiment labels of the text data with the predicted sentiment labels to obtain the sentiment classification loss. The model loss is obtained by weighted summation of the attribute classification loss and the sentiment classification loss. The sentiment classification model to be trained is trained based on the model loss until it converges. 2.The method of claim 1, wherein, The process of obtaining the word vector representation and attribute word vector matrix of the text data includes: The text data is projected into the embedding space of the sentiment classification model to be trained to obtain the word vector representation of the text data; The attribute set in the text data is encoded to obtain the attribute word vector matrix of the text data. 3.The method of claim 1, wherein, The step of obtaining the predicted attribute label of the text data based on the attribute features includes: A fully connected layer is used to perform a linear transformation on the attribute features of the text data; wherein, the fully connected layer is pre-set with Dropout release parameters; The linearly transformed attribute features are projected into the attribute label space to obtain the predicted attribute labels of the text data; wherein, the attribute label space is composed of the attribute word vector matrix. 4.The method of claim 1, wherein, The prompt information includes N prompt templates, where N is an integer greater than 1; The process of extracting the emotional features includes: The word vector representation is input into the masking language model, and based on each of the N prompt templates, the predicted label word vector is obtained from the output of the masking language model. The sentiment features of the text data are obtained by summing the predicted tag word vectors corresponding to the N prompt templates. 5.The method of claim 4, wherein, The prompt information includes the correspondence between emotional tag words and preset emotional tags; wherein, each type of preset emotional tag corresponds to at least one emotional tag word; The step of obtaining the predicted sentiment label of the text data based on the sentiment features includes: For each sentiment tag, a similarity calculation is performed between it and the sentiment feature; The preset sentiment tag corresponding to the sentiment tag word with the highest similarity is selected as the predicted sentiment tag of the text data.

6. An affective classification prediction method, characterized by, include: Obtain the text data to be predicted; The sentiment classification model trained using the sentiment classification model training method as described in any one of claims 1 to 5 is used to perform sentiment classification prediction on the text data to be predicted.

7. An electronic device, comprising: include: At least one processor; as well as, A memory communicatively connected to the at least one processor; wherein, The memory stores instructions that can be executed by the at least one processor, the instructions being executed by the at least one processor to enable the at least one processor to perform the training method of the sentiment classification model as described in any one of claims 1 to 5, or to perform the sentiment classification prediction method as described in claim 6.

8. A computer readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the training method of the sentiment classification model as described in any one of claims 1 to 5, or it can execute the sentiment classification prediction method as described in claim 6.