A method for automatic recognition of conversation emotions based on deep learning
By constructing a neural network model for key historical segment perception in the automatic recognition of dialogue emotions, and using the segment emotion correlation loss and the emotion representation distance diminishing loss function, the insufficient utilization of dialogue emotion label information and imperfect timing modeling in traditional methods are solved. problem, achieving higher emotion recognition accuracy.
Patent Information
- Application Number
- CN202210363151.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-04-07
- Publication Date
- 2024-08-27
- Estimated Expiration
- 2042-04-07
AI Technical Summary
Traditional dialogue emotion recognition technology cannot effectively utilize the emotion label information in historical dialogue segments, and there are imperfections in timing modeling based on graph neural networks or pre-trained language models, resulting in insufficient perception of dialogue timing information.
An automatic dialogue emotion recognition method based on deep learning is adopted. By constructing a neural network model for key historical segment perception, the segment emotion correlation loss and the emotion representation distance diminishing loss function are used to make full use of historical dialogue emotion label information and improve dialogue timing. Modeling of features.
It improves the accuracy of dialogue emotion recognition, can more effectively perceive the emotional characteristics and dialogue timing characteristics in key historical segments, and has higher emotion recognition accuracy than existing methods.
Smart Images

Figure CN114742073B
Abstract
Description
Technical Field
[0001] The present invention relates to artificial intelligence, and in particular to a method for automatically identifying dialogue emotions based on deep learning. Background Art
[0002] The emotion recognition task in the intelligent dialogue system is the basic task of semantic understanding of the intelligent dialogue system, and its purpose is to identify the emotions contained in the speaker in each round of dialogue. Effective and accurate user emotion recognition can enhance the intelligent dialogue system's ability to understand the dialogue history and improve the accuracy of reply sentence selection. It is a basic task to provide users with appropriate reply feedback and subsequent personalized services. Existing research work on this task is mainly based on graph neural networks or pre-trained language models. Its research focus is mainly on the modeling of historical text information. By designing a reasonable network structure, the emotional inertia features related to a single speaker and the emotional contagion features between speakers are extracted from the text information of the historical dialogue segments, and are comprehensively used in the final automatic emotion recognition.
[0003] However, traditional methods do not fully utilize the emotional label information provided by historical dialogue segments. At the same time, although the existing graph neural network or pre-trained language model solves the long-distance dependency problem in the recurrent neural network model through the attention mechanism, it also partially loses the characterization of the timing information in the recurrent neural network model due to the imperfect timing modeling of the mechanism. The model's perception of the timing of dialogue sentences is very important, because in a dialogue, the topics of the two parties are likely to change as the dialogue deepens, and two segments with a large time gap may be completely different in semantics. Therefore, it is necessary to find a modeling method that can take into account both the long-distance dependency in the dialogue and the perception of the timing characteristics of the dialogue.
[0004] It should be noted that the information disclosed in the above background technology section is only used for understanding the background of the present application, and therefore may include information that does not constitute prior art known to ordinary technicians in the field. Summary of the invention
[0005] The main purpose of the present invention is to provide a method for automatic recognition of conversation emotions based on deep learning, so as to solve the problem that traditional conversation emotion recognition technology cannot effectively utilize the emotion label information provided in historical conversation segments, and the problem that graph neural network or pre-trained language model partially loses the ability to model conversation timing information due to the imperfect timing modeling of attention mechanism.
[0006] To achieve the above object, the present invention adopts the following technical solutions:
[0007] A method for automatic recognition of conversation emotions based on deep learning, comprising the following steps:
[0008] Process the original conversation text and historical conversation emotion labels; perform text encoding based on the pre-trained language model to obtain the context-related segment representation vector of each conversation segment;
[0009] Construct and train a neural network model based on key historical segment perception; the error modeling of the model includes: classification error calculation, segment sentiment relevance loss calculation, and sentiment representation distance reduction loss calculation;
[0010] The classification error calculation includes: performing emotion classification according to the context-related segment representation vector, and calculating the classification error cross entropy value between the true emotion label and the emotion label;
[0011] The segment emotion relevance loss calculation includes: constructing segment pairs with the same emotion label as positive segment pairs and segment pairs with different emotion labels as negative segment pairs from the historical dialogue segments according to the historical dialogue emotion label information, respectively extracting context representation vectors using the pre-trained language model, and calculating the loss value according to the segment emotion relevance loss function;
[0012] The emotion representation distance decreasing loss calculation includes: according to the context representation vectors mapped from the adjacent segments of the dialogue to the emotion representation space, constraining the similarity gap between the adjacent segments according to the emotion representation distance decreasing loss function and calculating the loss value;
[0013] The dialogue text to be predicted is input into the trained neural network model, and the neural network model outputs the predicted value to obtain the final predicted emotion label.
[0014] Furthermore, the processing of the original conversation text and historical conversation emotion labels includes: constructing an input based on the original conversation text and historical conversation emotion labels, processing the original conversation text and historical conversation emotion labels into a word string form that can be read and recognized by a model, and then obtaining a context-aware representation vector of each word example of each conversation segment through text encoding, thereby obtaining a context-related segment representation vector.
[0015] Furthermore, the classification error calculation includes: normalizing the context-related segment representation vector through a classification fully connected layer and a softmax function to obtain the output probability of the segment to be predicted in each emotion category, comparing it with the true emotion label, and calculating the classification error value using a cross entropy loss function.
[0016] Furthermore, the segment emotion relevance loss calculation includes: after constructing positive and negative segment pairs according to historical dialogue emotion tags, calculating the segment emotion relevance loss value of the model according to a loss function based on dot product similarity;
[0017] Preferably, the designed sentence sentiment relevance loss function L emo As shown in formula (3), f() is used to measure the similarity between two representation vectors, and the dot product similarity after exponential operation is selected, as shown in formula (4):
[0018]
[0019]
[0020] Among them, the temperature parameter τ is used to adjust the similarity distance between samples, which is set as a learnable parameter. is the sentiment representation vector of the paragraph, χ neg is a set of negative segments with different sentiment labels from the reference sample x; by optimizing the loss function, the model achieves the positive segment pair (x, x + ) represents the maximization of the similarity between vectors and the negative segment pair (x,x - ) represents the minimization of vector similarity.
[0021] Furthermore, the emotion representation distance decreasing loss calculation includes: after constructing the representation vector of the emotion representation space of the adjacent segments of the dialogue, constraining the similarity gap between the adjacent segments through a loss function based on hinge loss, and calculating the penalty item value that does not meet the constraint as the emotion representation distance decreasing loss value;
[0022] Preferably, a distance decreasing function L of emotion representation based on the dialogue sequence is designed. seq As shown in formula (6):
[0023]
[0024] in, is the representation vector of segment U in the emotion representation space, g() is the distance between two segments in the emotion representation space, N seq is the number of selected segments; for a pair of segments U i and U j , j Appear in U i Afterwards, time i < time j < time t, which is a learnable distance scaling parameter.
[0025] Furthermore, the training of the neural network model based on key historical segment perception includes: adding the classification error, the segment emotion relevance loss function value and the emotion representation distance decreasing loss value to obtain the model training loss value, and updating the model parameters through the back propagation mechanism, and iterating until the model converges.
[0026] Furthermore, the neural network model outputs a prediction value to obtain a final predicted emotion label, including: the model's prediction result is based on a paragraph-level context representation vector generated by a pre-trained language model, and the vector is projected into a predefined emotion label space using a fully connected layer to obtain a final predicted emotion label.
[0027] Furthermore, the pre-trained language model is RoBERTa.
[0028] Furthermore, the segment sentiment relevance loss calculation includes: selecting the sentence closest to the segment to be predicted as the reference sample x, constructing and obtaining an input string with a historical dialogue window length of 2, and obtaining the representation vector at the first word example through the RoBERTa model and the fully connected mapping layer as the sentiment representation vector of the reference sample, and for the positive segment, finding the sentence with the same sentiment label as the reference sample x from back to front in the chronological order of the dialogue as the positive segment x + , construct an input string with the same historical dialogue window length of 2, and use the same method to obtain the emotion representation vector of the positive segment; for the negative segment, randomly select segments with different emotion labels from the reference sample x from the historical segments as the negative segment set, and obtain their emotion representation vectors; calculate the segment emotion relevance loss value of the model based on the loss function based on dot product similarity;
[0029] Furthermore, the calculation of the emotion representation distance decreasing loss includes: selecting historical segments from the historical dialogue information from back to front in the chronological order of the dialogue as the optimization target of the loss function, constructing and obtaining input strings with a historical dialogue window length of 2 respectively, and inputting them into the same RoBERTa model and a fully connected layer for mapping vectors to the emotion representation space, to obtain the representation vector of the segment in the emotion representation space; using cosine similarity as the distance between two segments in the emotion representation space, constraining the similarity gap between adjacent segments through a loss function based on hinge loss, and calculating the emotion representation distance decreasing loss value of the model.
[0030] A computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for automatically identifying conversation emotions is implemented.
[0031] The present invention has the following beneficial effects:
[0032] The present invention provides a method for automatic recognition of conversation emotions based on deep learning, wherein a neural network model based on key historical segment perception is proposed, so that historical conversation emotion label information can be fully utilized in the analysis process of conversation emotion recognition, effectively solving the problem that traditional conversation emotion recognition technology cannot effectively utilize the emotion label information provided in historical conversation segments, and reasonably perceives the timing characteristics of the conversation in the analysis process of conversation emotion recognition, solving the problem that the timing modeling ability of conversation timing information is partially lost due to the imperfect attention mechanism of timing modeling based on graph neural network or pre-trained language model, and achieving higher emotion recognition accuracy.
[0033] For automatic recognition of dialogue emotions, the proposed modeling methods of paragraph emotion correlation loss and emotion representation distance reduction loss are complementary. The modeling of paragraph emotion correlation loss enables the model to perceive the emotional characteristics in key historical paragraphs, while the modeling of emotion representation distance reduction loss focuses on the perception of dialogue timing characteristics. Compared with existing methods, this method has a higher emotion recognition accuracy while supporting real-time recognition. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 The present invention is a schematic diagram of the workflow of a method for automatically identifying conversation emotions based on key historical segment perception according to an embodiment of the present invention.
[0035] Figure 2 This is a schematic diagram of the model structure of a method for automatic recognition of conversation emotions based on key historical segment perception according to an embodiment of the present invention.
[0036] Figure 3 Schematic diagram of the construction of positive and negative paragraph pairs in the paragraph sentiment relevance loss function of an embodiment of the present invention.
[0037] Figure 4 A schematic diagram of constructing a distance decreasing loss function for emotion representation according to an embodiment of the present invention. DETAILED DESCRIPTION
[0038] The following is a detailed description of the embodiments of the present invention. It should be emphasized that the following description is only exemplary and is not intended to limit the scope and application of the present invention.
[0039] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present invention, the meaning of "plurality" is two or more, unless otherwise clearly and specifically defined.
[0040] We believe that the sentiment label information of historical segments can enhance the model's ability to perceive key historical segments. Compared with the sentiment label information of segments from other conversations, the sentiment label information within the same conversation is closer to the sentence to be predicted in terms of topic relevance. It can be regarded as the user's emotional history on the topic, which is used to assist in predicting the user's possible emotions at the moment. Intuitively, if two segments in the same conversation have the same sentiment label, then they are likely to be similar in terms of the emotional words and the way the sentences are expressed. Therefore, if there is a segment in the conversation history that is highly matched in expression with the segment being predicted for emotion, then it can be considered that the historical segment is the key historical segment in the prediction process, and the two segments will have similar emotional characteristics. Therefore, this task can also be further modeled as a historical segment text matching problem under the same conversation.
[0041] Based on the above-mentioned problem of not making full use of the sentiment labels of historical segments and the perception of the temporal characteristics of conversations, we proposed a neural network model for the perception of key historical segments. This model is based on a pre-trained language model and enhances the perception of the structure of conversation text by designing the sentiment relevance loss function of the segment and the sentiment representation distance decreasing loss function. The sentiment relevance loss function focuses on the perception of key historical segments. First, positive and negative segment pairs are constructed through the sentiment labels of historical conversations. Then, the positive segment pairs are selected from a batch of segment pairs. In the optimization process, the similarity of positive segment pairs is maximized and the similarity of negative segment pairs is minimized, so that the model can perceive the emotional characteristics in key historical segments. The sentiment representation distance decreasing loss function focuses on the perception of the temporal sequence of conversations, which can enable the model to shorten the distance between a pair of temporally adjacent segments in the sentiment representation space during the training process, and can make the distance between the pair of segments in the sentiment representation space related to the time difference between their appearances in the conversation.
[0042] In some preferred embodiments of the method for automatic recognition of conversation emotions, input is constructed based on the conversation text and historical conversation emotion labels, and the pre-trained model is fine-tuned to obtain context-related segment representation vectors; positive and negative segment pairs are constructed based on the historical conversation emotion labels, and the segment emotion correlation loss value of the model is calculated based on a loss function based on dot product similarity; the emotion representation space representation vector of adjacent segments of the conversation is constructed, the similarity gap between adjacent segments is constrained by a loss function based on hinge loss, and the penalty item value that does not meet the constraint is calculated as the emotion representation distance decreasing loss value.
[0043] Figure 1The workflow of a method for automatic recognition of dialogue emotions based on deep learning in an embodiment of the present invention is shown. The training part of the model is mainly divided into five parts: input construction, text encoding, classification error calculation, paragraph emotion relevance loss function calculation, and emotion representation distance reduction loss function calculation. The overall architecture is as follows: Figure 2 As shown. First, the input is preprocessed. The original conversation text and historical conversation emotion labels need to be processed into word strings that can be read and recognized by the model. Then, the text is encoded according to the pre-trained language model to obtain the segment-level context representation vector for each conversation segment. This representation vector is used for emotion classification, and the classification error cross entropy value between the true emotion label is calculated. Next, based on the historical conversation emotion label information, segment pairs with the same emotion label are constructed from the historical conversation segments as positive segment pairs, and segment pairs with different emotion labels are constructed as negative segment pairs. After the context representation vectors are extracted using the pre-trained language model, the error value is calculated according to the segment emotion relevance loss function. The sample construction method of positive and negative samples is as shown below. Figure 3 Finally, according to the context representation vectors of adjacent segments mapped to the emotion representation space, the similarity gap between them is constrained according to the emotion representation distance decreasing loss function and the loss value is calculated. The calculation method of the loss value is as follows Figure 4 As shown. The final model training loss value is obtained by adding the classification error, the paragraph sentiment relevance loss function value, and the sentiment representation distance reduction loss value, and the model parameters are updated through the back-propagation mechanism, and iterated until the model converges. The model's prediction result is based on the paragraph-level context representation vector generated by the pre-trained language model. This vector is projected into the pre-defined sentiment label space using a fully connected layer to obtain the final predicted sentiment label. Input construction:
[0044] For the segment U to be predicted at time t t We refer to the standard method of the pre-trained language model RoBERTa to construct the input string I of the model t For the number of dialogue history segments, we consider setting the history dialogue window length W and selecting U t The previous W segments U t-W ,…,U t-1 As a historical segment, it is used to construct the historical information string H t Each paragraph U i The L contained in it i The word examples consist of: At the end of each historical segment, an [EOU] word is inserted to separate different historical segments. t can be fully expressed as H t =U t-W [EOU]…U t-1[EOU] In order to further string the historical information H t and the segment to be predicted U t Separated by [SEP], we add a [SEP] token at the end of each of them. t A [CLS] token is inserted at the beginning of the input string, and its representation vector can be used as the sentence-level representation vector of the input string. Finally, the complete input string I t It can be represented as I t =[CLS]H t [SEP]U t [SEP]. Referring to the implementation of HuggingFace, we use the default <s> and< / s> To represent [CLS] and [SEP] words respectively, [EOU] is added to the vocabulary of the model. We also use the same input construction method for the historical paragraphs in the calculation of the paragraph sentiment relevance loss function and the sentiment representation distance reduction loss function.
[0045] Text encoding:
[0046] The pre-trained language model we use in the language model layer is RoBERTa, which optimizes some important settings in the pre-training process based on BERT, thereby achieving better results in downstream fine-tuning tasks. A core optimization point of the RoBERTa model is to abandon the two-category pre-training task NSP proposed by BERT. Its original design motivation was to infer whether two text segments are in a continuation relationship in the original text, but some subsequent related studies found that the NSP pre-training task would confuse two different types of tasks: the topic prediction task of judging whether two text segments have the same topic, and the coherence prediction task of judging whether two text segments are logically coherent. The NSP task actually focuses more on topic prediction, because if the two text segments come from different documents at the time of sampling, it is easy to learn that they are not related in terms of topic, thereby obtaining the correct answer without loss value, rather than distinguishing from the perspective of logical coherence. Abandoning the NSP pre-training task also means that the word examples of the two text segments will no longer be distinguished from the word example embedding layer. Therefore, the embedding layer of the model is obtained by adding the position embedding vector and the word embedding vector, and the segment embedding vector in the original BERT word embedding layer will no longer be retained. The word examples in the dialogue history segment and the word examples in the segment to be predicted can only be distinguished by the [SEP] word examples inserted between them.
[0047] Classification error calculation:
[0048] After the text encoding operation, we obtained the context-aware representation vector of each word. We selected the representation vector of the first word, normalized it through the classification fully connected layer and the softmax function, and obtained the output probability of the predicted paragraph in each emotion category. We compared it with the true emotion label and calculated the classification error value using the cross entropy loss function.
[0049] Calculation of the emotional relevance loss of a paragraph:
[0050] In order to enable the model to perceive key historical segments and obtain relevant emotional features through comparative learning, we first need to construct emotion-related positive and negative segment pairs based on the historical conversation emotional labels. In order to learn emotional features that are as close as possible to the segment to be predicted, we select the sentence closest to the segment to be predicted as the reference sample x, construct and obtain the input string with a historical conversation window length of 2, and obtain the representation vector at the first word example through the RoBERTa model being fine-tuned and the fully connected mapping layer as the emotional representation vector of the reference sample. Temporal proximity can make two segments closer in topic and semantics. Therefore, for the positive segment, we find the sentence with the same emotional label as the reference sample x from back to front in the chronological order of the conversation as the positive segment x. + , construct an input string with the same historical dialogue window length of 2, and use the same method to obtain the sentiment representation vector of the positive segment. In the selection of negative segments, we randomly select segments with different sentiment labels from the reference sample x as the negative segment set from the historical segments, and obtain their sentiment representation vectors. Finally, the segment sentiment relevance loss value of the model is calculated based on the loss function based on dot product similarity.
[0051] Sentiment represents the distance decreasing loss calculation:
[0052] We select historical segments from the historical dialogue information from back to front in the chronological order of the dialogue as the optimization target of the loss function, construct and obtain input strings with a historical dialogue window length of 2, and input them into the same RoBERTa model and the fully connected layer used to map the vector to the emotion representation space to obtain the representation vector of the segment in the emotion representation space. We use cosine similarity as the distance between two segments in the emotion representation space, constrain the similarity gap between adjacent segments through a loss function based on hinge loss, and calculate the model's emotion representation distance reduction loss value.
[0053] The specific embodiments of the present invention are further described below.
[0054] The error modeling of the model is mainly divided into three parts: classification error, segment sentiment relevance loss, and sentiment representation distance reduction loss. Classification error function L clsAs shown in formula (1), I{·} is an indicator function, which takes the value of 1 only when the event in the brackets occurs, otherwise it is 0; p t,i The model is for the segment to be predicted U t The output probability of emotion category i is represented by the representation vector of the first token in the language model output layer Through the classification fully connected layer FC cls And the softmax function is normalized, as shown in formula (2).
[0055]
[0056]
[0057] Sentence sentiment relevance loss function:
[0058] Sentence sentiment relevance loss function L emo The purpose of the design is to make two segments with the same emotion label in the same dialogue have similar emotion representation vectors, so that the model can perceive the emotion representation vectors for the segment to be predicted U. t The key historical passages and the emotional characteristics in these historical passages.
[0059] In order to enable the model to perceive key historical segments and obtain relevant emotional features through contrastive learning, we first need to construct emotion-related positive and negative segment pairs based on the historical dialogue emotion labels. Figure 3 The method for constructing positive and negative paragraph pairs designed by us is shown. We consider a dialogue sample containing 10 paragraphs, of which the first 9 sentences are historical paragraphs that can obtain the emotional labels of each paragraph, and the last paragraph U9 is the paragraph that needs to be predicted. In order to learn the emotional features that are as close as possible to the paragraph to be predicted U9, we select the sentence U8 that is closest to the paragraph to be predicted as the reference sample x, construct and obtain the input string with a historical dialogue window length of 2, and pass it through the RoBERTa model being fine-tuned and the fully connected mapping layer FC emo Get the representation vector at the [CLS] token Sentiment representation vector used as reference sample.
[0060] The temporal proximity can make the two segments closer in topic and semantics. Therefore, for the positive segment, we find the sentence U4 with the same emotion label as the reference sample x from the back to the front in the chronological order of the conversation as the positive segment x. + , construct an input string with the same length of 2 for the history dialog window, and use it with the encoding x + The same RoBERTa model and FC emo The emotion representation vector of the positive segment is obtained by
[0061] In the selection of negative segments, we randomly selected N from the historical segments. neg The segments with different sentiment labels from the reference sample x are taken as the negative segment set χ neg , as shown in the figure U3, U5, U6 and U7. Similarly, we also use the same RoBERTa model and FC emo The layer obtains the sentiment representation vector of each segment in the negative segment set. Thus, we obtain the subject segment pair (x,x + ) and a set of negative segments χ neg , and their respective sentiment representation vectors.
[0062] We designed the sentence sentiment relevance loss function L emo As shown in formula (3), f(·,·) is used to measure the similarity between two representation vectors. We selected the dot product similarity after exponential operation. As shown in formula (4), the temperature parameter τ is used to adjust the similarity distance between samples. Selecting a suitable temperature parameter helps the model learn the features from hard negative samples. In the experiment, we set it as a learnable parameter and use 0.07 as its initialization value. neg is a set of negative segments with different sentiment labels from the reference sample x. By optimizing this loss function, the model can achieve the positive segment pair (x, x + ) represents the maximization of the similarity between vectors and the negative segment pair (x,x - ) represents the minimization of vector similarity, so as to better perceive the emotional features in key historical passages with the same emotional labels, and the model’s text structure perception ability is enhanced.
[0063]
[0064]
[0065] Sentiment representation distance decreasing loss function:
[0066] Since we use the attention mechanism based on the pre-trained language model to extract sentence expression vectors, it is functionally equivalent to the graph neural network, so it has the ability to model long-distance dependencies, but it is defective in describing the temporal characteristics of conversations. To this end, we try to reflect the temporal nature of conversations by standardizing the relative distance differences between paragraph pairs in the emotion representation space.
[0067] Figure 4 A conversation sample containing 5 segments is shown. We need to predict the emotion of the last segment U4. We select N from the historical conversation information from the back to the front in the chronological order of the conversation.seq The loss function is optimized by constructing and obtaining input strings with a history dialogue window length of 2, and inputting them into the same RoBERTa model and the fully connected layer FC used to map the vector to the emotion representation space. seq , get the segment U i Representation vector in the emotion representation space We use cosine similarity as the distance g(·,·) between two segments in the sentiment representation space, as shown in formula (5). Next, we need to calculate the predicted segment U4 and N seq The distance between historical dialogue segments in the emotion representation space.
[0068]
[0069] In order to optimize the distance between the predicted segment and the historical dialogue segment in the emotion representation space, so that the dialogue semantic gap increases with the time interval, so as to better enable the model to perceive the characteristics of the dialogue sequence, we designed an emotion representation distance decreasing function L based on the dialogue sequence. seq , as shown in formula (6). For a pair of segments U i and U j , and U j Appear in U i After that (i<j<t), U i and the segment to be predicted U t The distance in the emotion representation space should be greater than U j with U t The distance between them should be large, and this distance difference should be related to the time difference ji when the two segments appear in the conversation, that is, the distance difference should be at least (ji)λ. λ is a learnable distance scaling parameter, and we set its initial value to 0.01.
[0070]
[0071] Finally, the loss function of the model during training is composed of the classification loss function L cls , contrastive learning loss function L emo , emotion representation distance decreasing function L seq Together they form, as shown in formula (7).
[0072] L=L cls +L emo +L seq (7)
[0073] As shown in Table 1, we conducted an evaluation on four public datasets for dialogue emotion recognition, and the test results are shown in Table 1. Compared with the existing baseline model, the model of the embodiment of the present invention has a significant improvement in the class-weighted F1 index of the four datasets, indicating that the model of the present invention is more outstanding in maximizing the ability to utilize the information of historical dialogue segments, can better model and analyze the emotional motivations in historical segments, and obtain a higher emotion recognition accuracy.
[0074] Table 1
[0075]
[0076] The background section of the present invention may contain background information about the problem or environment of the present invention, but does not necessarily describe the prior art. Therefore, the content included in the background section is not an admission by the applicant that the prior art is available.
[0077] The above content is a further detailed description of the present invention in combination with specific / preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, without departing from the concept of the present invention, it can also make several substitutions or modifications to these described embodiments, and these substitutions or modifications should be regarded as belonging to the protection scope of the present invention. In the description of this specification, the description of the reference terms "an embodiment", "some embodiments", "preferred embodiments", "examples", "specific examples", or "some examples" means that the specific features, structures, materials or characteristics described in combination with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily target the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner. In the absence of mutual contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples. Although the embodiments of the present invention and their advantages have been described in detail, it should be understood that various changes, substitutions and modifications can be made herein without departing from the scope of protection of the patent application.
Claims
1. A method for automatic recognition of conversation emotions based on deep learning, characterized in that: The steps include: Process the original conversation text and historical conversation emotion labels; perform text encoding based on the pre-trained language model to obtain the context-related segment representation vector of each conversation segment; Construct and train a neural network model based on key historical segment perception; the error modeling of the model includes: classification error calculation, segment sentiment relevance loss calculation, and sentiment representation distance reduction loss calculation; The classification error calculation includes: performing emotion classification according to the context-related segment representation vector, and calculating the classification error cross entropy value between the true emotion label and the emotion label; The segment emotion relevance loss calculation includes: constructing segment pairs with the same emotion label as positive segment pairs and segment pairs with different emotion labels as negative segment pairs from the historical dialogue segments according to the historical dialogue emotion label information, respectively extracting context representation vectors using the pre-trained language model, and calculating the loss value according to the segment emotion relevance loss function; The emotion representation distance decreasing loss calculation includes: according to the context representation vectors mapped from the adjacent segments of the dialogue to the emotion representation space, constraining the similarity gap between the adjacent segments according to the emotion representation distance decreasing loss function and calculating the loss value; The dialogue text to be predicted is input into the trained neural network model, and the neural network model outputs the predicted value to obtain the final predicted emotion label.
2. The method for automatically identifying conversation emotions according to claim 1, characterized in that: The processing of the original dialogue text and historical dialogue emotion labels includes: constructing an input according to the original dialogue text and historical dialogue emotion labels, processing the original dialogue text and historical dialogue emotion labels into a word string form that can be read and recognized by a model, and then obtaining a context-aware representation vector of each word example of each dialogue segment through text encoding, thereby obtaining a context-related segment representation vector.
3. The method for automatically identifying conversation emotions according to claim 1 or 2, characterized in that: The classification error calculation includes: normalizing the context-related paragraph representation vector through a classification fully connected layer and a softmax function to obtain the output probability of the paragraph to be predicted in each emotion category, comparing it with the true emotion label, and calculating the classification error value using a cross entropy loss function.
4. The method for automatically identifying conversation emotions according to any one of claims 1 to 3, characterized in that: The segment emotion relevance loss calculation includes: after constructing positive and negative segment pairs according to historical dialogue emotion tags, calculating the segment emotion relevance loss value of the model according to a loss function based on dot product similarity; Preferably, the designed sentence sentiment relevance loss function L emo As shown in formula (3), f() is used to measure the similarity between two representation vectors, and the dot product similarity after exponential operation is selected, as shown in formula (4): Among them, the temperature parameter τ is used to adjust the similarity distance between samples, which is set as a learnable parameter. is the sentiment representation vector of the paragraph, χ neg is a set of negative segments with different sentiment labels from the reference sample x; by optimizing the loss function, the model achieves the positive segment pair (x, x + ) represents the maximization of the similarity between vectors and the negative segment pair (x,x - ) represents the minimization of vector similarity.
5. The method for automatically identifying conversation emotions according to any one of claims 1 to 4, characterized in that: The emotion representation distance decreasing loss calculation includes: after constructing the representation vector of the emotion representation space of the adjacent segments of the dialogue, constraining the similarity gap of the adjacent segments by a loss function based on hinge loss, and calculating the penalty item value that does not meet the constraint as the emotion representation distance decreasing loss value; Preferably, a distance decreasing function L of emotion representation based on the dialogue sequence is designed. seq As shown in formula (6): in, is the representation vector of segment U in the emotion representation space, g() is the distance between two segments in the emotion representation space, N seq is the number of selected segments; for a pair of segments U i and U j , U j Appear in U i Afterwards, time i < time j < time t, and λ is a learnable distance scaling parameter.
6. The method for automatically identifying conversation emotions according to any one of claims 1 to 5, characterized in that: The training of the neural network model based on key historical segment perception includes: adding the classification error, the segment emotion relevance loss function value and the emotion representation distance decreasing loss value to obtain the model training loss value, and updating the model parameters through the back propagation mechanism, and iterating until the model converges.
7. The method for automatically identifying conversation emotions according to any one of claims 1 to 6, characterized in that: The neural network model outputs a prediction value to obtain a final predicted emotion label, including: the model's prediction result is based on a paragraph-level context representation vector generated by a pre-trained language model, and the vector is projected into a predefined emotion label space using a fully connected layer to obtain a final predicted emotion label.
8. The method for automatically identifying conversation emotions according to any one of claims 1 to 7, characterized in that: The pre-trained language model is RoBERTa.
9. The method for automatically identifying conversation emotions according to claim 8, characterized in that: The segment sentiment relevance loss calculation includes: selecting the sentence closest to the segment to be predicted as the reference sample x, constructing and obtaining an input string with a historical dialogue window length of 2, and obtaining the representation vector at the first word example through the RoBERTa model and the fully connected mapping layer as the sentiment representation vector of the reference sample, and for the positive segment, finding the sentence with the same sentiment label as the reference sample x from back to front in the chronological order of the dialogue as the positive segment x + , construct an input string with the same historical dialogue window length of 2, and use the same method to obtain the emotion representation vector of the positive segment; for the negative segment, randomly select segments with different emotion labels from the reference sample x from the historical segments as the negative segment set, and obtain their emotion representation vectors; calculate the segment emotion relevance loss value of the model based on the loss function based on dot product similarity; The emotion representation distance decreasing loss calculation includes: selecting historical segments from historical dialogue information from back to front in the chronological order of the dialogue as the optimization target of the loss function, constructing and obtaining input strings with a historical dialogue window length of 2 respectively, and inputting them into the same RoBERTa model and a fully connected layer for mapping vectors to the emotion representation space, and obtaining the representation vector of the segment in the emotion representation space; using cosine similarity as the distance between two segments in the emotion representation space, constraining the similarity gap between adjacent segments through a loss function based on hinge loss, and calculating the emotion representation distance decreasing loss value of the model.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for automatically identifying conversation emotions as described in any one of claims 1 to 9 is implemented.
