CN116226381A - Emotion classification model training method, emotion classification prediction method and electronic equipment - Google Patents

Emotion classification model training method, emotion classification prediction method and electronic equipment Download PDF

Info

Publication number
CN116226381A
CN116226381A CN202310086789.6A CN202310086789A CN116226381A CN 116226381 A CN116226381 A CN 116226381A CN 202310086789 A CN202310086789 A CN 202310086789A CN 116226381 A CN116226381 A CN 116226381A
Authority
CN
China
Prior art keywords
emotion
attribute
text data
tag
emotion classification
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202310086789.6A
Other languages
Chinese (zh)
Inventor
过弋
刘欣怡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
East China University of Science and Technology
Original Assignee
East China University of Science and Technology
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by East China University of Science and Technology filed Critical East China University of Science and Technology
Priority to CN202310086789.6A priority Critical patent/CN116226381A/en
Publication of CN116226381A publication Critical patent/CN116226381A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/35Clustering; Classification
    • G06F16/353Clustering; Classification into predefined classes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/30Information retrieval; Database structures therefor; File system structures therefor of unstructured textual data
    • G06F16/33Querying
    • G06F16/3331Query processing
    • G06F16/334Query execution
    • G06F16/3346Query execution using probabilistic model
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N20/00Machine learning
    • YGENERAL TAGGING OF NEW TECHNOLOGICAL DEVELOPMENTS; GENERAL TAGGING OF CROSS-SECTIONAL TECHNOLOGIES SPANNING OVER SEVERAL SECTIONS OF THE IPC; TECHNICAL SUBJECTS COVERED BY FORMER USPC CROSS-REFERENCE ART COLLECTIONS [XRACs] AND DIGESTS
    • Y02TECHNOLOGIES OR APPLICATIONS FOR MITIGATION OR ADAPTATION AGAINST CLIMATE CHANGE
    • Y02DCLIMATE CHANGE MITIGATION TECHNOLOGIES IN INFORMATION AND COMMUNICATION TECHNOLOGIES [ICT], I.E. INFORMATION AND COMMUNICATION TECHNOLOGIES AIMING AT THE REDUCTION OF THEIR OWN ENERGY USE
    • Y02D10/00Energy efficient computing, e.g. low power processors, power management or thermal management

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Data Mining & Analysis (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Databases & Information Systems (AREA)
  • Software Systems (AREA)
  • Computational Linguistics (AREA)
  • Artificial Intelligence (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Evolutionary Computation (AREA)
  • Medical Informatics (AREA)
  • Probability & Statistics with Applications (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The application relates to the field of model training, and discloses a training method of emotion classification models, an emotion classification prediction method and electronic equipment, wherein the training method comprises the following steps: receiving text data and an actual attribute tag and an actual emotion tag corresponding to the text data, acquiring word vector representation and an attribute word vector matrix of the text data, and splicing comment texts of users in the same field with prompt information to obtain the text data, wherein the prompt information is used for guiding an emotion classification model to perform emotion classification on attributes of the text data; extracting attribute features and emotion features based on the word vector representation and the attribute word vector matrix; acquiring a predicted attribute tag based on the attribute characteristics, and acquiring a predicted emotion tag based on the emotion characteristics; based on the loss function, the emotion classification model is trained by combining the actual attribute label, the actual emotion label, the predicted attribute label and the predicted emotion label until convergence, so that the trained emotion classification model is obtained, the accuracy of emotion classification is improved, and the time and labor cost are reduced.

Description

Emotion classification model training method, emotion classification prediction method and electronic equipment
Technical Field
The invention relates to the field of model training, in particular to a training method of emotion classification models, an emotion classification prediction method and electronic equipment.
Background
With the rapid development of networks, users can share their own preferences and evaluations among various types of software, and thus, a large amount of discussion information for objects such as products, characters, events, shops, etc. is generated in the networks. In the big data age, a great deal of emotion information of users is contained in various discussion information, and the information contains great values which are mined and analyzed, so the requirement of automatically classifying emotion promotes emotion classification to be one of the popular fields of current natural language processing (Natural Language Processing, NLP).
However, along with explosive growth of data, expression modes of different users are different, and selection of various software recommendations meeting requirements and preferences of people becomes time-consuming and labor-consuming, so that the general emotion analysis method has the problems of low analysis accuracy, high time cost and high labor cost.
Disclosure of Invention
The invention aims to solve the problems, and provides a training method of an emotion classification model, an emotion classification prediction method and electronic equipment, which solve the problems of low text emotion analysis accuracy, high time cost and high labor cost.
To solve the above problems, an embodiment of the present application provides a training method of an emotion classification model, including: receiving text data and an actual attribute tag and an actual emotion tag corresponding to the text data, and obtaining word vector representation and an attribute word vector matrix of the text data, wherein the text data is obtained by splicing comment texts of users in the same field and prompt information, and the prompt information is used for guiding an emotion classification model to be trained to carry out emotion classification on attributes of the text data; extracting attribute features and emotion features of the text data based on the word vector representation and the attribute word vector matrix; acquiring a predicted attribute tag of the text data based on the attribute characteristics, and acquiring a predicted emotion tag of the text data based on the emotion characteristics; based on a preset loss function, training the emotion classification model to be trained by combining the actual attribute tag, the actual emotion tag, the predicted attribute tag and the predicted emotion tag until convergence, and obtaining the trained emotion classification model.
To solve the above problems, an embodiment of the present application provides an emotion classification prediction method, including: acquiring text data to be predicted; and training the obtained emotion classification model by using the training method of the emotion classification model, and carrying out emotion classification prediction on the text data to be predicted.
To solve the above problems, embodiments of the present application further provide an electronic device, including: at least one processor; and a memory communicatively coupled to the at least one processor; the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the training method of the emotion classification model or the emotion classification prediction method.
To solve the above problems, embodiments of the present application further provide a computer-readable storage medium storing a computer program that implements the training method of the emotion classification model described above when executed by a processor, or performs the emotion classification prediction method described above.
According to the training method for the emotion classification model, text data spliced with prompt information are input into the emotion classification model to be trained together for training, so that the to-be-trained emotion classification model processes the input comment text according to the prompt information, the problem that classification accuracy is reduced due to insufficient corpus in an attribute-level text emotion classification task is solved, a large amount of corpus is not required to be subjected to attribute and emotion labeling, and labor cost and time cost of model training are reduced.
In one example, obtaining a word vector representation and an attribute word vector matrix of text data includes: projecting the text data to an embedding space of the emotion classification model to be trained to obtain word vector representation of the text data; and encoding the attribute set in the text data to obtain an attribute word vector matrix of the text data.
In one example, extracting the attribute features of the text data based on the word vector representation and the attribute word vector matrix includes: inputting the word vector representation into a bidirectional coding representation converter to obtain a hidden layer state matrix of the bidirectional coding representation converter; carrying out average pooling treatment on the last layer of the hidden layer state matrix to obtain average representation of text data; and carrying out dot multiplication calculation on the attribute word vector matrix and the average representation of the text data to obtain the attribute characteristics of the text data.
In one example, obtaining a predicted attribute tag for text data based on an attribute feature includes: performing linear transformation on attribute characteristics of the text data by using a full connection layer; wherein, the full connection layer is preset with Dropout release parameters; projecting the attribute characteristics subjected to linear transformation into an attribute tag space to obtain a predicted attribute tag of the text data; wherein the attribute tag space is composed of an attribute word vector matrix.
In one example, the hint information includes N hint templates, where N is an integer greater than 1; the extraction process of emotion characteristics comprises the following steps: inputting word vector representation into a shielding language model, and respectively acquiring predicted tag word vectors from output results of the shielding language model based on each prompting template in N prompting templates; and adding the predictive tag word vectors corresponding to the N prompting templates to obtain the emotion characteristics of the text data.
In one example, the prompt message includes a correspondence between an emotion tag word and a preset emotion tag; wherein each type of preset emotion label corresponds to at least one emotion label word; the predictive emotion tag for obtaining text data based on emotion characteristics comprises: aiming at each emotion tag word, similarity calculation is carried out on each emotion tag word and emotion characteristics; and selecting a preset emotion label corresponding to the emotion label word with the highest similarity as a predictive emotion label of the text data.
In one example, performing cross entropy loss calculation on an actual attribute tag and a predicted attribute tag of text data to obtain attribute classification loss; performing cross entropy loss calculation on the actual emotion labels and the predicted emotion labels of the text data to obtain emotion classification loss; carrying out weighted summation on the attribute classification loss and the emotion classification loss to obtain model loss; training the emotion classification model to be trained based on model loss until convergence.
Drawings
One or more embodiments are illustrated by way of example and not limitation in the figures of the accompanying drawings, in which like references indicate similar elements, and in which the figures of the drawings are not to be taken in a limiting sense, unless otherwise indicated.
FIG. 1 is a flowchart of a training method of emotion classification models according to an embodiment of the present application;
FIG. 2 is a diagram illustrating verification of the effect of emotion classification models provided by an embodiment of the present application;
FIG. 3 is a schematic diagram of an emotion classification prediction method according to an embodiment of the present application;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
For the purposes of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the following detailed description of each embodiment of the present application will be given with reference to the accompanying drawings. However, those of ordinary skill in the art will understand that in various embodiments of the present application, numerous technical details have been set forth in order to provide a better understanding of the present application. However, the technical solutions claimed in the present application can be implemented without these technical details and with various changes and modifications based on the following embodiments.
An embodiment of the present application relates to a training method of emotion classification model, including: receiving text data and an actual attribute tag and an actual emotion tag corresponding to the text data, and obtaining word vector representation and an attribute word vector matrix of the text data, wherein the text data is obtained by splicing comment texts of users in the same field and prompt information, and the prompt information is used for guiding an emotion classification model to be trained to carry out emotion classification on attributes of the text data; extracting attribute features and emotion features of the text data based on the word vector representation and the attribute word vector matrix; acquiring a predicted attribute tag of the text data based on the attribute characteristics, and acquiring a predicted emotion tag of the text data based on the emotion characteristics; based on a preset loss function, training the emotion classification model to be trained by combining the actual attribute tag, the actual emotion tag, the predicted attribute tag and the predicted emotion tag until convergence, obtaining the trained emotion classification model, and solving the problems of low text emotion analysis accuracy, high time cost and high labor cost.
The implementation details of the training method of the emotion classification model in this embodiment are specifically described below, and the following is only for facilitating understanding of the implementation details of the present embodiment, and is not necessary for implementing the present embodiment. The specific flow is shown in fig. 1, and may include the following steps:
in step 101, text data and an actual attribute tag and an actual emotion tag corresponding to the text data are received, and a word vector representation and an attribute word vector matrix of the text data are obtained.
The text data are obtained by splicing comment texts of users in the same field with prompt information, and the prompt information is used for guiding an emotion classification model to be trained to perform emotion classification on the attribute of the text data.
In one example, text data is obtained by splicing a preprocessed comment text and prompt information, text data used for training an emotion feature model and an actual attribute tag and an actual emotion tag corresponding to the text data are received, and word vector representation and an attribute word vector matrix corresponding to the text data are obtained.
In one example, before the emotion model to be trained receives text data for training, user comment texts in the restaurant field are obtained, wherein the comment texts are in UTF-8 plain text format, and the comment texts are preprocessed, and the method specifically comprises the following steps: analyzing the XML structure file, splitting a feature column, constructing comment texts in a text-attribute word-emotion tendency mode based on the feature column, and dividing the constructed comment texts into comment texts for training emotion models and comment texts for testing emotion features, namely a training set and a testing set.
In one example, the comment text is parsed using a standard library XML of Python, each piece of comment text of the user is split into three parts, namely a "text", "an attribute word" and an "emotion tendency", according to the corresponding tag in the XML data file, and the three parts are converted into three feature columns of the data set by using a Features method in a dataset library. The contents corresponding to the three feature columns of each piece of text data are text, actual attribute labels and actual emotion labels of the text data. And when the comment texts are subjected to feature classification, each comment text and the corresponding actual attribute label and actual emotion label can be obtained.
In one example, the user's comment text sequence is spliced with the prompt message to form a new text sequence, i.e., text data, for model training. For example: and splicing each comment text with the prompt information to obtain text data for training a model, and for each attribute in the comment text, respectively splicing the comment text with the prompt information, splitting the comment text into a plurality of comment texts with single attribute to obtain text data for training.
In the embodiment of the application, text data is projected to an embedding space of an emotion classification model to be trained, and word vector representation of the text data is obtained; and encoding the attribute set in the text data to obtain an attribute word vector matrix of the text data.
In one example, in the coding layer of the emotion classification model, a word segmentation device using a BERT (Bidirectional Encoder Representations from Transformers, bi-directional coding representation converter) model maps words in received text data into a model embedding space to obtain word vector representations of the text data, and encodes attribute sets in the text data to obtain word vector representation sets of the attribute sets, namely an attribute word vector matrix a= { a 1 ,a 2 ,…,a n }。
In step 102, attribute features and emotion features of the text data are extracted based on the word vector representation and the attribute word vector matrix.
In the embodiment of the application, word vector representation is input into a bidirectional coding representation converter model to obtain a hidden layer state matrix of the bidirectional coding representation converter; carrying out average pooling treatment on the last layer of the hidden layer state matrix to obtain average representation of text data; and carrying out dot multiplication calculation on the attribute word vector matrix and the average representation of the text data to obtain the attribute characteristics of the text data.
In one example, in the feature layer of the emotion classification model, word vector representations of text data are fed into the BERT model, obtaining a hidden layer state matrix h= { e, H of the bi-directional coding representation converter model 0 ,h 1 ,…,h 11 Where e is a vector representation of the entire sentence, h i And outputting a hidden layer state vector for the ith layer. After obtaining the hidden layer state matrix of the model, the last layer h in the hidden layer state matrix is obtained 11 ={h 1 ,h 2 ,…,h 768 Average pooling to obtain an average representation e of text data mean The specific formula is as follows:
e mean ={c,c,…,c}
Figure BDA0004069054600000041
wherein c represents a hidden layer.
Average representation e of attribute word vector matrix A with text data mean Performing point multiplication calculation to obtain a feature e of the information related to the fusion attribute asp I.e. the attribute characteristics of the text data, the calculation formula is as follows:
e asp =A·e mean
e asp ={b 1 ,b 2 ,…,b n }
wherein b n Representing attributes of the text data.
In the embodiment of the application, the prompt information comprises N prompt templates, wherein N is an integer greater than 1; the extraction process of emotion characteristics comprises the following steps: inputting word vector representation into a shielding language model, and respectively acquiring predicted tag word vectors from output results of the shielding language model based on each prompting template in N prompting templates; and adding the predictive tag word vectors corresponding to the N prompting templates to obtain the emotion characteristics of the text data.
In one example, a prompt template is constructed based on the comment text of the user and the characteristics of an attribute-level emotion classification task, wherein the attribute-level emotion classification task is to classify emotion polarities of a certain attribute of an evaluated target object, and according to the characteristics, various prompt templates are constructed, and the template content is as follows:
1、The{aspect}is[MASK]
2、I felt the{aspect}was[MASK]
3、I[MASK]the{aspect}
4、The{aspect}made me feel[MASK]
where { aspect } represents the attribute word corresponding to the fill-in here, and [ MASK ] represents that the emotion classification model will predict the emotion tag word corresponding to the fill-in attribute here. Each emotion label word has a preset emotion label corresponding to the emotion label word, and one preset emotion label corresponds to a plurality of emotion label words.
In one example, the preset emotion tag includes: positive, negative, neural and conflict, text data with conflict emotion labels removed in the model training process is used as data for inputting emotion classification models to be trained, so that noise is prevented from being hidden in the model process. Constructing label mapping according to the constructed prompting template, wherein the specific mapping is as follows: (1) active→good, negative→bad, neural→ok (2) active→save, neutral→ok (3) active→love, negative→ate, neutral→display ike (4) active→happy, negative→sad, neutral→index. The label words are closer to natural language semantics through the mapping, so that the emotion classification model can be used for predicting and classifying emotion labels of all attributes conveniently.
In one example, word vector representations are input to an MLM (Masked Language Model, MASK language model), and based on each of the above-described alert templates, a predictive tag word vector is extracted from the output result of the MLM, that is, the tag word vector representations at the locations corresponding to the respective alert templates are predicted, and the predictive tag word vectors obtained by the prediction are added to each other to obtain emotion feature t= { T of text data 1 ,t 2 ,…,t 768 }. Wherein the MLM is the pre-prediction proposed by the BERT model for the contextual representation of the learning textTraining tasks that mask words using tokens, thereby learning their contextual content features to predict the masked words.
In step 103, a predictive attribute tag of the text data is obtained based on the attribute feature, and a predictive emotion tag of the text data is obtained based on the emotion feature.
In the embodiment of the application, the attribute characteristics of the text data are subjected to linear transformation by using a full connection layer; wherein, the full connection layer is preset with Dropout release parameters; projecting the attribute characteristics subjected to linear transformation into an attribute tag space to obtain a predicted attribute tag of the text data; wherein the attribute tag space is composed of an attribute word vector matrix.
In one example, the full connection layer is used for carrying out linear transformation on the attribute features of the text data, the attribute features after the linear transformation are projected into the attribute label control, and the predicted attribute label of the text data is obtained, wherein the specific formula is as follows:
y asp =e asp ·W T +b
wherein W is a learnable weight matrix, b is a learnable bias vector, y asp And labeling the predicted attribute obtained by prediction. In addition, dropout=0.3 is arranged in the full connection layer to improve the generalization capability of the model and avoid the overfitting of the model.
In the embodiment of the application, the prompt information comprises a corresponding relation between an emotion label word and a preset emotion label; wherein each type of preset emotion label corresponds to at least one emotion label word; acquiring a predicted emotion tag of text data based on emotion characteristics, comprising: aiming at each emotion tag word, similarity calculation is carried out on each emotion tag word and emotion characteristics; and selecting a preset emotion label corresponding to the emotion label word with the highest similarity as a predictive emotion label of the text data.
In one example, attribute-level emotion classification of text data is completed by adopting a traditional prompt learning method, and a prediction result of an emotion classification model at a position of 'MASK', namely, a prediction tag word vector representation of the text data and each tag word in tag mapping are respectively subjected to similarity calculation, wherein cosine similarity is selected as a measurement standard, and the formula is as follows:
Figure BDA0004069054600000051
wherein t= { T 1 ,t 2 ,…,t 768 The } is the acquired emotion feature representation, l= { L 1 .l 2 …,l 768 The label word vector is represented, and a label corresponding to the label word with the highest similarity of the predicted result is selected as a predicted emotion label y of the text data sen
In step 104, training the emotion classification model to be trained by combining the actual attribute tag, the actual emotion tag, the predicted attribute tag and the predicted emotion tag until convergence based on the preset loss function to obtain the trained emotion classification model.
In the embodiment of the application, the cross entropy loss calculation is carried out on the actual attribute label and the predicted attribute label of the text data, so as to obtain attribute classification loss; performing cross entropy loss calculation on the actual emotion labels and the predicted emotion labels of the text data to obtain emotion classification loss; carrying out weighted summation on the attribute classification loss and the emotion classification loss to obtain model loss; training the emotion classification model to be trained based on model loss until convergence.
In one example, a multi-class cross entropy loss function is used to calculate attribute class loss and emotion class loss, respectively, as follows:
Figure BDA0004069054600000061
in the attribute classification loss calculation, N represents the number of samples of text data, M represents the number of attribute categories of data text, y ij E {0.1} indicates whether sample i belongs to category j, p ij The predicted probability that sample i belongs to category j.
In the case of performing emotion classification loss calculation, N represents the number of samples of text data, and M representsThe number of emotion categories, y, of the data text ij E {0.1} indicates whether sample i belongs to category j, p ij The predicted probability that sample i belongs to category j.
Predicted attribute label y obtained by prediction asp Performing cross entropy loss calculation with the corresponding actual attribute label to obtain attribute classification loss 1 The method comprises the steps of carrying out a first treatment on the surface of the Predictive emotion tag y sen Performing cross entropy loss calculation with the corresponding actual emotion label to obtain emotion classification loss 2 The model loss is obtained by a weighted summation mode, and the formula is as follows:
loss=aloss 1 +loss 2
wherein, a is an adjustable weight parameter, and is assigned according to specific situations in the practical application of emotion classification.
Training the emotion classification model to be trained based on the model loss function until convergence.
In one example, the emotion classification model comprises a coding layer, a feature extraction layer and a classification layer which are sequentially connected, wherein the coding layer is used for receiving input text data, a BERT word segmentation device is adopted to project the text data to a representation space of the model, and word vector representation of the text data is obtained and used as input of the feature extraction layer; the feature extraction layer is used for extracting attribute features and emotion features of the input text data, and the extraction result is used as input of the classification layer; the classifying layer is used for classifying and predicting the input text data according to the attribute features and the emotion features obtained by the feature extracting layer.
In order to verify that the emotion classification model trained by the training method of the emotion classification model provided by the embodiment of the application has effectiveness, experiments are carried out on the following four commonly used public data sets:
a)SemEval-2014 Task4 Restaurants(Res14)
b)SemEval-2014 Task4 Laptops(Lap14)
c)SemEval-2015 Task12 Restaurants(Res15)
d)SemEval-2016 Task5 Restaurants(Res16)
the data sets comprise comment texts from the restaurant field and the notebook computer field, each data set is divided into a training set and a testing set, wherein attribute words in the data sets are marked, and corresponding emotion labels are divided into positive, negative and neutral.
In the test, the validity of attribute classification of the test model is tested, and an emotion classification model with the attribute classification module removed are used for respectively carrying out emotion tendency test on an attribute word 'food' in a sample 'the food here was moderate at best', and the specific content is shown in fig. 2, wherein (a) is an attention visualization result of the emotion classification model with the attribute classification module removed on the sample, and (b) is an attention visualization result of the emotion classification model (AWP-BERT) on the sample.
The upper and lower lines in the figure are full sentence representations "[ CLS ]" and the attribute word "food" respectively, for each word's attention weight in the text. (b) The visual result of the attention of the AWP-BERT to the sample is represented, the visual result is obtained from the first row of the figure, the semantic representation of the AWP-BERT is more focused on the attribute words, and in (a), the semantic representation obtained from the model with the attribute classification removed is higher in attention score to the attribute words, but higher in "here" than the attribute words, which means that the AWP-BERT can focus on the attribute words more accurately, and further verifies that the attribute classification module can play a role in prompting the model to pay more attention to the related information of the attribute words.
As can be seen from the visual result of the "good" line in the attention graph, the AWP-BERT model in (b) has the highest attention score of "modem", and the word with the highest attention score in (a) is "best", which means that the emotion classification model after removing the attribute classification module may misjudge "best" as the word containing emotion information when performing emotion classification, thereby affecting the prediction accuracy. By comparing the two graphs, the AWP-BERT model provided by the method can pay more attention to emotion words related to emotion tendency prediction, and further illustrates that the attribute classification module is introduced to capture better attribute characteristics of the emotion classification model, and the emotion classification model is promoted to obtain better results in attribute-level emotion classification tasks by enhancing the attention of the emotion classification model to attribute word information.
According to the training method of the emotion classification model, which is provided by the embodiment of the application, the emotion classification model to be trained is guided to carry out emotion polarity analysis on a certain attribute of text data through the prompt template in prompt information by combining the characteristics of attribute-level emotion classification tasks, multi-task learning and technical characteristics of prompt learning, and tag word mapping is adopted, so that tag words are closer to natural language, the emotion classification model is more convenient to predict and classify, text data is converted into word vector representation, and attribute feature extraction and emotion feature extraction of the text data are more convenient to carry out. Finally, training the emotion classification model until convergence is achieved by minimizing the weighting loss function, so that the problem of classification accuracy reduction caused by insufficient corpus in an attribute-level text emotion classification task is solved, and meanwhile, attribute and emotion labeling on a large amount of corpus is not needed, and the labor cost and time cost of model training are reduced.
The embodiment of the application also relates to an emotion classification prediction method, which comprises the following steps: acquiring text data to be predicted; and training the obtained emotion classification model by using the training method of the emotion classification model, and carrying out emotion classification prediction on the text data to be predicted.
The implementation details of the emotion classification prediction method in this embodiment are specifically described below, and the following is only for facilitating understanding of the implementation details of this embodiment, and is not necessary for implementing this embodiment. The specific flow is shown in fig. 3, and may include the following steps:
in step 301, text data to be predicted is acquired.
In one example, text data that requires emotion classification prediction is obtained.
In step 302, the emotion classification model obtained by training the training method of the emotion classification model is used for performing emotion classification prediction on the text data to be predicted.
In one example, the obtained text data to be predicted is input into a trained emotion classification model, the emotion classification model performs emotion classification on the text data to be predicted, and an emotion classification result of the text data to be predicted is output.
According to the emotion classification prediction method, the trained emotion classification model is used for emotion classification of various text data with different expression modes, so that various software can be effectively helped to provide more accurate recommendation functions for users through comment texts of the users.
The above steps of the methods are divided, for clarity of description, and may be combined into one step or split into multiple steps when implemented, so long as they include the same logic relationship, and they are all within the protection scope of this patent; it is within the scope of this patent to add insignificant modifications to the algorithm or flow or introduce insignificant designs, but not to alter the core design of its algorithm and flow.
Embodiments of the present application also provide an electronic device, as shown in fig. 4, comprising at least one processor 401; and a memory 402 communicatively coupled to the at least one processor 401; the memory 402 stores instructions executable by the at least one processor 01, where the instructions are executed by the at least one processor 401, so that the at least one processor can execute the training method of the emotion classification model or can execute the emotion classification prediction method.
Where the memory and the processor are connected by a bus, the bus may comprise any number of interconnected buses and bridges, the buses connecting the various circuits of the one or more processors and the memory together. The bus may also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art, and therefore, will not be described any further herein. The bus interface provides an interface between the bus and the transceiver. The transceiver may be one element or may be a plurality of elements, such as a plurality of receivers and transmitters, providing a means for communicating with various other apparatus over a transmission medium. The data processed by the processor is transmitted over the wireless medium via the antenna, which further receives the data and transmits the data to the processor.
The processor is responsible for managing the bus and general processing and may also provide various functions including timing, peripheral interfaces, voltage regulation, power management, and other control functions. And memory may be used to store data used by the processor in performing operations.
The product may perform the method provided by the embodiment of the present application, and have corresponding functional modules and beneficial effects of the performing method, and technical details not described in detail in the embodiment of the present application may be referred to the method provided by the embodiment of the present application.
Embodiments of the present application also provide a computer-readable storage medium storing a computer program. The computer program implements the above-described method embodiments when executed by a processor.
Those skilled in the art will appreciate that all or part of the steps in implementing the methods of the embodiments described above may be implemented by a program stored in a storage medium, where the program includes several instructions for causing a device (which may be a single-chip microcomputer, a chip or the like) or a processor (processor) to perform all or part of the steps of the methods described in the embodiments of the present application. And the aforementioned storage medium includes: a usb disk, a removable hard disk, a Read-only Memory (ROM), a random access Memory (RAM, random Access Memory), a magnetic disk, or an optical disk, or other various media capable of storing program codes.
The embodiments described hereinabove are intended to provide those of ordinary skill in the art with a variety of modifications and variations to the embodiments described herein without departing from the inventive concepts of the present application, and thus the scope of the present application is not limited by the embodiments described hereinabove, but is to be accorded the broadest scope of the innovative features recited in the claims.

Claims (10)

1. A method of training an emotion classification model, comprising:
receiving text data and an actual attribute tag and an actual emotion tag corresponding to the text data, and obtaining word vector representation and an attribute word vector matrix of the text data, wherein the text data is obtained by splicing comment texts of users in the same field and prompt information, and the prompt information is used for guiding an emotion classification model to be trained to carry out emotion classification on the attributes of the text data;
extracting attribute features and emotion features of the text data based on the word vector representation and the attribute word vector matrix;
acquiring a predicted attribute tag of the text data based on the attribute characteristics, and acquiring a predicted emotion tag of the text data based on the emotion characteristics;
based on a preset loss function, training the emotion classification model to be trained by combining the actual attribute tag, the actual emotion tag, the predicted attribute tag and the predicted emotion tag until convergence to obtain a trained emotion classification model.
2. The method of training an emotion classification model of claim 1, wherein said obtaining a word vector representation and an attribute word vector matrix of said text data comprises:
projecting the text data to an embedding space of the emotion classification model to be trained to obtain word vector representation of the text data;
and encoding the attribute set in the text data to obtain an attribute word vector matrix of the text data.
3. The method of training a model of claim 1, wherein the extracting the attribute features of the text data based on the word vector representation and an attribute word vector matrix comprises:
inputting the word vector representation into a bidirectional coding representation converter to obtain a hidden layer state matrix of the bidirectional coding representation converter;
carrying out average pooling treatment on the last layer of the hidden layer state matrix to obtain average representation of the text data;
and carrying out dot multiplication calculation on the attribute word vector matrix and the average representation of the text data to obtain the attribute characteristics of the text data.
4. A training method for emotion classification models as claimed in claim 3, characterized in that said obtaining a predictive attribute tag of said text data based on said attribute features comprises:
performing linear transformation on the attribute characteristics of the text data by using a full connection layer; wherein, the full connection layer is preset with a Dropout release parameter;
projecting the attribute characteristics after linear transformation into an attribute tag space to obtain a predicted attribute tag of the text data; wherein the attribute tag space is formed by the attribute word vector matrix.
5. The method for training an emotion classification model according to claim 1, wherein the hint information includes N hint templates, wherein N is an integer greater than 1;
the extraction process of the emotion characteristics comprises the following steps:
inputting the word vector representation into a shielding language model, and respectively acquiring a predicted tag word vector from an output result of the shielding language model based on each prompting template in the N prompting templates;
and adding the predictive tag word vectors corresponding to the N prompting templates to obtain the emotion characteristics of the text data.
6. The method for training an emotion classification model according to claim 5, wherein the prompt information includes a correspondence between emotion tag words and preset emotion tags; wherein each type of preset emotion label corresponds to at least one emotion label word;
the obtaining the predicted emotion tag of the text data based on the emotion characteristics comprises the following steps:
aiming at each emotion tag word, similarity calculation is carried out on each emotion tag word and each emotion feature;
and selecting a preset emotion label corresponding to the emotion label word with the highest similarity as a predicted emotion label of the text data.
7. The method for training an emotion classification model according to any one of claims 1 to 6, wherein the training the emotion classification model to be trained based on a preset loss function in combination with the actual attribute tag, the actual emotion tag, the predicted attribute tag, and the predicted emotion tag until convergence includes:
performing cross entropy loss calculation on the actual attribute tag of the text data and the predicted attribute tag to obtain attribute classification loss;
performing cross entropy loss calculation on the actual emotion label of the text data and the predicted emotion label to obtain emotion classification loss;
carrying out weighted summation on the attribute classification loss and the emotion classification loss to obtain model loss;
and training the emotion classification model to be trained based on the model loss until convergence.
8. An emotion classification prediction method, comprising:
acquiring text data to be predicted;
emotion classification prediction is performed on the text data to be predicted using an emotion classification model trained using the training method of an emotion classification model according to any one of claims 1 to 7.
9. An electronic device, comprising:
at least one processor; the method comprises the steps of,
a memory communicatively coupled to the at least one processor; wherein, the liquid crystal display device comprises a liquid crystal display device,
the memory stores instructions executable by the at least one processor to enable the at least one processor to perform the training method of the emotion classification model of any one of claims 1 to 7 or to perform the emotion classification prediction method of claim 8.
10. A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the method of training the emotion classification model of any one of claims 1 to 7, or is capable of performing the emotion classification prediction method of claim 8.
CN202310086789.6A 2023-01-18 2023-01-18 Emotion classification model training method, emotion classification prediction method and electronic equipment Pending CN116226381A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310086789.6A CN116226381A (en) 2023-01-18 2023-01-18 Emotion classification model training method, emotion classification prediction method and electronic equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310086789.6A CN116226381A (en) 2023-01-18 2023-01-18 Emotion classification model training method, emotion classification prediction method and electronic equipment

Publications (1)

Publication Number Publication Date
CN116226381A true CN116226381A (en) 2023-06-06

Family

ID=86572496

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310086789.6A Pending CN116226381A (en) 2023-01-18 2023-01-18 Emotion classification model training method, emotion classification prediction method and electronic equipment

Country Status (1)

Country Link
CN (1) CN116226381A (en)

Similar Documents

Publication Publication Date Title
US11501182B2 (en) Method and apparatus for generating model
CN111488931B (en) Article quality evaluation method, article recommendation method and corresponding devices
CN109034203B (en) Method, device, equipment and medium for training expression recommendation model and recommending expression
CN111738016A (en) Multi-intention recognition method and related equipment
CN112100401B (en) Knowledge graph construction method, device, equipment and storage medium for science and technology services
CN112632226B (en) Semantic search method and device based on legal knowledge graph and electronic equipment
CN111259647A (en) Question and answer text matching method, device, medium and electronic equipment based on artificial intelligence
CN113239169A (en) Artificial intelligence-based answer generation method, device, equipment and storage medium
Puccetti et al. Technology identification from patent texts: A novel named entity recognition method
CN114510570A (en) Intention classification method and device based on small sample corpus and computer equipment
US20230237084A1 (en) Method and apparatus for question-answering using a database consist of query vectors
Ayyadevara Neural Networks with Keras Cookbook: Over 70 recipes leveraging deep learning techniques across image, text, audio, and game bots
CN113255328A (en) Language model training method and application method
CN116186237A (en) Entity relationship joint extraction method based on event cause and effect inference
Wang et al. Mitigating fine-grained hallucination by fine-tuning large vision-language models with caption rewrites
CN110852071A (en) Knowledge point detection method, device, equipment and readable storage medium
CN113505786A (en) Test question photographing and judging method and device and electronic equipment
CN113705207A (en) Grammar error recognition method and device
US11288265B2 (en) Method and apparatus for building a paraphrasing model for question-answering
US20210165800A1 (en) Method and apparatus for question-answering using a paraphrasing model
CN114911940A (en) Text emotion recognition method and device, electronic equipment and storage medium
CN113157932B (en) Metaphor calculation and device based on knowledge graph representation learning
CN115470790A (en) Method and device for identifying named entities in file
CN114357964A (en) Subjective question scoring method, model training method, computer device, and storage medium
CN116226381A (en) Emotion classification model training method, emotion classification prediction method and electronic equipment

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination