Dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning

By using a dual-graph attention neural network and a contrastive learning method, the problems of noise generation and data imbalance in graph neural networks for dialogue emotion recognition are solved, achieving a more efficient dialogue emotion recognition effect.

CN119938928BActive Publication Date: 2025-11-14CHONGQING UNIV OF POSTS & TELECOMM
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510028268.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-11-14
Estimated Expiration
2045-01-08

AI Technical Summary

Technical Problem

In existing technologies, dialogue emotion recognition models based on graph neural networks are prone to noise during the iteration process, and the imbalance of the dataset results in poor ability to classify emotion categories with few samples.

Method used

We employ a dual-graph attention neural network and a contrastive learning method. The dual-graph attention neural network extracts speech sentiment features related to the dialogue context, and an asymmetric graph update strategy is introduced. Combined with a cross-attention mechanism and a contrastive learning module, we optimize the model training process.

Benefits of technology

It effectively solves the problem of noise generation in graph neural networks during the iteration process, improves the classification accuracy of emotion categories with few samples, and enhances the overall recognition performance of the model.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119938928B_ABST
    Figure CN119938928B_ABST
Patent Text Reader

Abstract

This invention belongs to the field of natural language processing and dialogue emotion recognition, specifically relating to a dialogue emotion recognition method based on a dual-graph attention neural network and contrastive learning. The method includes: preprocessing a dataset; inputting the preprocessed data into a trained dialogue emotion recognition model to obtain the probability that each utterance in the dialogue belongs to each emotion category. The dialogue emotion recognition model includes a dual-graph attention neural network model and a contrastive learning module. This invention utilizes a dual-graph attention neural network model containing two heterogeneous graph neural networks to obtain context-dependent emotional features of utterances, solving the problems of weak information extraction capabilities of simple graph neural networks and the tendency for noise generation in complex graph neural networks in previous methods. Furthermore, the contrastive learning module calculates the similarity between the utterance features extracted by the model and calculates the loss accordingly, addressing the problem of low emotion classification accuracy with few samples in previous methods.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of natural language processing technology and dialogue emotion recognition, specifically involving a dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning. Background Technology

[0002] Dialogue emotion recognition is a crucial research area in natural language processing, with significant application value. Early approaches to dialogue emotion recognition employed dictionary-based methods. This involved obtaining the emotion values ​​of emotion words from an emotion dictionary and then using the sum or average of these values ​​to calculate the overall emotion of the sentence or document, thereby determining the emotional tendency of the text dialogue. For example, Li et al. combined an emotion dictionary called NRC-Valence arousal dominance to obtain word-level emotion distributions, assigning emotions of greater intensity to emotion words. However, these keyword-based classification methods still have several problems. First, words can have different meanings depending on usage and context, leading to ambiguity. Second, these dictionaries cannot recognize the emotion in text that does not contain emotion keywords. Finally, the accuracy of emotion recognition based on emotion dictionaries is often affected by the flexibility of the dialogue text data, the specialized nature of the text data, and the lack of language-related information.

[0003] In recent years, with the rapid development of deep learning models, researchers have gradually applied them to the field of natural language processing. Gupta et al. first clearly defined dialogue emotion recognition and used LSTM for sentence context modeling, achieving good results. To meaningfully distinguish between different parties in a dialogue, Majumder et al. proposed the DialogueRNN model, which uses three GRUs to capture speaker information, context, and emotion information from previous utterances. However, these LSTM or GRU-based sequence models have the problem of failing to characterize long-distance or global dependencies between clauses, thus ignoring deep dependencies between clauses. To address this issue, researchers have attempted to apply Graph Neural Networks (GNNs) to dialogue emotion recognition methods. Unlike LSTM and GRU, which only perform cyclic modeling on sequence data, GNNs treat dialogue emotion recognition as a problem of connections and message propagation between nodes in a graph, modeling dependencies between nodes. Two nodes connected by an edge can transmit information regardless of temporal distance. Ghosal et al. proposed Dialogue Graph Convolutional Network (DialogueGCN), which utilizes intra-speaker and inter-speaker dependencies to construct a graph neural network structure, simulating dialogue context for emotion recognition. Through graph neural networks, DialogueGCN addresses the context propagation problem present in current DialogueRNN-based methods, but neglects the sequential information between utterances and information about different speakers. Based on this, Liang et al. proposed a speaker-and-position-aware graph neural network model for dialogue emotion recognition (S+PAGE), combining the advantages of relational graph convolutional networks and Transformers to achieve better context modeling. Furthermore, Zhang et al. proposed DualGraph Attention Neural Network (DualGAT), which overcomes the lack of fine-grained information in simplified graph structures by combining information extracted from a directed acyclic graph simulating the temporal sequence of context and a speaker-perceived complete graph.

[0004] However, in the above-mentioned existing technologies, GNNs with complex model structures often generate a lot of noise during the iteration process. Furthermore, since dialogue emotion recognition datasets often suffer from data imbalance, models trained on these datasets have poor classification ability for certain emotion categories with few samples. Summary of the Invention

[0005] To address the aforementioned technical problems, this invention provides a dialogue emotion recognition method based on a dual-graph attention neural network and contrastive learning, comprising:

[0006] The dialogue dataset is preprocessed; the preprocessed data is input into the trained dialogue emotion recognition model to obtain the probability that each utterance in the dialogue belongs to a certain emotion category, and the emotion category to which each utterance belongs is output according to the probability.

[0007] The dialogue emotion recognition model includes: RoBERTa model, dual-graph attention neural network, cross-attention mechanism module, softmax classification layer and contrastive learning module;

[0008] The process of training a dialogue emotion recognition model includes:

[0009] S1: Obtain the original dialogue dataset, divide the dataset into training and test sets; preprocess the data in the training set;

[0010] S2: Input the preprocessed data into the RoBERTa model to generate the initial semantic representation of each statement;

[0011] S3: Input the initial semantic representation into the dual-graph attention neural network to obtain the local context semantic representation and the global context semantic representation respectively;

[0012] S4: Input the local and global contextual semantic representations into the cross-attention mechanism module for interaction to obtain the fused dialogue semantic representation;

[0013] S5: Obtain dialogue sentiment representations for sentiment classification based on the fused dialogue semantic representations;

[0014] S6: Perform softmax classification on the sentiment representation of the dialogue to obtain the sentiment category of each utterance; set the initial value for the number of iterations;

[0015] S7: Input the dialogue sentiment representation into the contrastive learning module assisted by the auxiliary set, and calculate the contrastive learning loss;

[0016] S8: The cross-entropy loss function is used to calculate the loss for sentiment classification, and together with the contrastive learning loss, it is used to train the model.

[0017] S9: The model is optimized using the Adam algorithm;

[0018] S10: Determine if the number of iterations has reached the maximum number of iterations. If it has, complete the training of the dialogue emotion recognition model. Otherwise, return to step S8 and increment the number of iterations by 1.

[0019] The beneficial effects of this invention are:

[0020] This invention utilizes a dual-graph attention neural network model containing two graph neural networks with different structures to obtain context-dependent emotional features of speech in dialogues. It also introduces an asymmetric graph update strategy, addressing the problems of weak global information extraction capabilities of simple graph neural networks and the generation of excessive noise in complex graph neural networks, which are common in previous methods. Furthermore, a contrastive learning module is used to compare the similarity of emotional features between speech of the same and different emotional categories, and loss is calculated accordingly. This allows the graph neural network to generate more similar emotional features for speech of the same emotional category and more differentiated emotional features for speech of different emotional categories. This solves the problem of high misclassification probability for a small number of classes caused by imbalanced training datasets in previous dialogue emotion recognition models. Attached Figure Description

[0021] Figure 1 This is a flowchart of the training process of the present invention;

[0022] Figure 2 This is a structural diagram of the dual-graph neural network model of the present invention. Detailed Implementation

[0023] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0024] A dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning, such as... Figure 1 The method includes: preprocessing the dialogue dataset; inputting the preprocessed data into a trained dialogue emotion recognition model to obtain the probability that each utterance in the dialogue belongs to a certain emotion category, and outputting the emotion category to which each utterance belongs based on the probability; the dialogue emotion recognition model includes a dual-graph attention neural network model and a contrastive learning module.

[0025] like Figure 1 The process of training the dialogue emotion recognition model includes:

[0026] S1: Obtain the original dialogue dataset, divide the dataset into training and test sets; preprocess the data in the training set;

[0027] S2: Input the preprocessed data into the RoBERTa model to generate the initial semantic representation of each statement;

[0028] S3: Input the initial semantic representation of the dialogue into the dual-graph attention neural network to obtain the local context semantic representation and the global context semantic representation, respectively;

[0029] S4: Input the local and global contextual semantic representations into the cross-attention mechanism module for interaction.

[0030] Obtain the fused dialogue semantic representation;

[0031] S5: Obtain dialogue sentiment representations for sentiment classification based on the fused dialogue semantic representations;

[0032] S6: Input the dialogue sentiment representation into the contrastive learning module assisted by the auxiliary set, and calculate the contrastive learning loss;

[0033] S7: Perform softmax classification on the sentiment representation of the dialogue to obtain the sentiment category of each utterance; set the initial value for the number of iterations;

[0034] S8: The cross-entropy loss function is used to calculate the loss for sentiment classification, and together with the contrastive learning loss, it is used to train the model.

[0035] S9: The model is optimized using the Adam algorithm;

[0036] S10: Determine if the number of iterations has reached the maximum number of iterations. If it has, complete the training of the dialogue emotion recognition model. Otherwise, return to step S8 and increment the number of iterations by 1.

[0037] The MELD public dialogue dataset is used as the base dataset. The dataset is divided into three parts: the training set contains 1039 dialogues and 9989 messages; the test set contains 280 dialogues and 2610 messages; and the validation set contains 114 dialogues and 1109 messages.

[0038] The preprocessing of the above data includes: removing stop words from the original dataset; for each dialogue group, setting the length of each utterance to the length of the longest utterance in the dialogue, truncating excessively long utterances from the end, and padding insufficiently long utterances; and inputting the processed single-sentence utterances into the RoBERTa model for initial representation extraction.

[0039] Input(u i = [CLS], w1, ..., w i ,…,w n [SEP]

[0040] h i =RoBERTa(Input(u i ))

[0041] Among them, u iThis indicates a statement made during a dialogue. i (1≤i≤n) represents a single word in the speech, [CLS] is the category marker, [SEP] is the end marker, and h i For speaking u i The output of the last hidden layer at position [CLS] after inputting into the RoBERTa model is used as the speaker u. i The initial representation. The data of a batch is the overall input of the model as H = (h1||h2||h3…h ... N ), where || represents vector concatenation, and N represents the total number of messages in a batch.

[0042] After obtaining the initial semantic representation, the input is used for feature extraction from a dual-graph neural network model consisting of two graph attention neural networks with different structures, such as... Figure 2 As shown; the structural definitions and feature extraction processes of the two graph neural networks are as follows:

[0043] 1) Global Context Graph Neural Network (GLGAT):

[0044] First, a directed complete graph neural network (GLBAT) is used as the source of global context information. The GLBAT graph structure is defined as follows: G gl ={V gl E gl}, where V gl ={v1,v2,v3…v N Let} be the set of nodes in the graph, where N represents the total number of messages in a batch, and each node v i (1≤i≤N) are all initialized to the value of u for each speaker in the dialogue. i Hidden layer representation h i E gl ={e1,e2,e3…e M Let} be the edge set of the graph, and M represent the total number of edges in the graph. Also define (v i ,v j ,r) represents the node v i to node v j A directed edge of relation type r. p(v i ) is the speaker mapping function, representing node v i Corresponding speech u i The speaker. For the design of global context graph neural network structures, five edge types are defined as follows:

[0045] Intra-Past: If there is a node v i ,v j When i>j, p(v)i )=p(v j ), then we have (v i ,v j ,0)∈E gl ,

[0046] Intra-Future: If there is a node v i ,v j , when i <j,p(v u )=p(v j ), then we have (v i ,v j ,1)∈E gl ,

[0047] Inter-Past: If there is a node v u ,v j When i>j, p(v) i )≠p(v j ), then we have (v i ,v j ,2)∈E gl ,

[0048] Inter-Future: If there is a node v i ,v j , when i <j,p(v i )≠p(v j ), then we have (v i ,v j ,3)∈E gl Intra-Loop: If there is a node v i Then we have (v i ,v i ,4)∈E gl .

[0049] An Intra-Past type edge (edge ​​type 0) is connected to node v. i All connected nodes, whose speakers are all connected to node v i Corresponding speech u i The speakers are the same, and the time sequence is in the speaking position u. i Previously; by an Intra-Future type edge (edge ​​type 1) and node v i All connected nodes, whose speakers are all connected to node v i Corresponding speech u i The speakers are the same, and the time sequence is in the speaking position u. i Then; the inter-past type edge (edge ​​type 2) connects to node v i All connected nodes, whose speakers are all connected to node v i Corresponding speech ui The speakers are different, and the timing is within the speaking sequence. i Previously; by an Inter-Future type edge (edge ​​type 3) and node v i All connected nodes, whose speakers are all connected to node v i Corresponding speech u i The speakers are different, and the timing is within the speaking sequence. i Then; a Self-Loop type edge (edge ​​type 4) is connected to node v. i Connected nodes are nodes v i This allows the extraction of the global context information of the current node. The representation of each node is updated based on its neighboring nodes that are connected by edges. The calculation method for updating the node representation in a graph neural network is shown below.

[0050] α ij =softmax(LRL(a T [Wh i ||Wh j ||r ij ]))

[0051]

[0052] Where α ij For node v i For neighbor node v j The attention coefficient, also known as the edge weight. softmax(.) is the normalization function, and LRL(.) refers to the LeakyReLU activation function. || represents concatenation, T represents matrix transpose, and α, W are trainable parameter matrices. h i ,h j They represent nodes v respectively i ,v j The representation vector r of the corresponding speech ij Represents connected nodes v i ,v j The one-hot vector corresponding to the edge type between them. Representative node v i Node representation updated by GLGAT. This represents node v i In the global context graph G gl The set of all neighboring nodes connected by edges. After a complete update of GLGAT, the representation of each node in its output is: Where || denotes vector concatenation, and N represents the total number of messages in a batch. The GLGAT node representation update formula can be summarized as follows:

[0053] H gl=GLGAT(H,E gl )

[0054] Where GLGAT represents a global context graph neural network, H = (h1||h2||h3…h…) N ) is the input to GLGAT, h i For speaking u i The corresponding representation is that || represents vector concatenation, and N represents the total number of messages in a batch. E gl H represents the edge set in the graph structure of GLGAT. gl The output representation is obtained after the input H is updated by GLGAT.

[0055] 2) Local Context Graph Neural Network (LOGAT):

[0056] Secondly, a graph neural network with a directed acyclic graph structure (LOGAT) is used as the source of local context information. The definition of the LOGAT graph structure is as follows: G lo ={V lo E lo}, where V gl ={v1,v2,v3…v N Let} be the set of nodes in the graph, where N represents the total number of messages in a batch, and each node v i (1≤i≤N) are all initialized to the value of u for each speaker in the dialogue. i Hidden layer representation h i E gl ={e1,e2,e3…e M Let} be the edge set of the graph, and M represent the total number of edges in the graph. Also define (v j ,v i ,r) represents the node v i to node v j A directed edge of relation type r. p(v i ) is the speaker mapping function, representing node v i Corresponding speech u i The speaker. For the design of local context graph neural network structures, two edge types are defined as follows:

[0057] Intra-Speaker: If there is a node v i ,v j When i>j, p(v) i )=p(v j And there is no arbitrary node v. k ,p(v i )=p(v k If i>k>j, then (vj ,v i ,1)∈E lo ,

[0058] Inter-Speaker: If there is a node v i ,v j When i>j, p(v) i )≠p(v j And there is no arbitrary node v. k ,p(v i )=p(v k If i>k>j, then (v j ,v i ,0)∈E lo ,

[0059] An Intra-Speaker type edge (edge ​​type 1) and node v i A connected node satisfies the following condition: it is connected to node v. i Corresponding speech u i The speakers are the same, and the speaking sequence is... i The previous nearest node. This type of relationship is used to obtain speaker-perceived context information at a distance; it consists of an Inter-Speaker type edge (edge ​​type 0) and node v. i A connected node satisfies the following condition: it is connected to node v. i Corresponding speech u i The speakers are different, and the speaking order is different. i The nearest previous node. This type of relationship is used to capture the nearest context information that has the greatest impact on the current node. These two types of context information are captured as the local context information of the current node through the update calculation of LOGAT. The specific update method of the graph neural network node representation is the same as that of GLGAT. The LOGAT node representation update formula is summarized as follows:

[0060] H lo =LOGAT(H,E lo )

[0061] Where LOGAT represents a local context graph neural network, and H = (h1||h2||h3…h…) N ) is the input for LOGAT, h i For speaking u i The corresponding representation is that || represents vector concatenation, and N represents the total number of messages in a batch. E lo H represents the edge set in the graph structure of LOGAT. lo The output representation is obtained after updating the input H with LOGAT.

[0062] After feature extraction by the dual graph neural network, a cross-attention mechanism is used to fuse the contextual semantic representations extracted by the two graph neural networks, and asymmetric updates are performed:

[0063] S1: Output H, representing the nodes of the two graphs. gl H lo The attention coefficient matrix of the two representation matrices with respect to each other is obtained by calculating the cross-attention mechanism function;

[0064]

[0065] Where softmax(.) is the normalization function, W is the trainable parameter matrix, T denotes matrix transpose, and H... l This represents the node representation output by the graph neural network after the l-th update. n is the difference hyperparameter. Previous experiments have shown that graph neural networks with overly complex graph structures should not undergo too many layers of updates to avoid generating redundant noise features. Therefore, the hyperparameter n is specifically set so that before information exchange between the two graph neural networks, LOGAT will perform n internal node updates, while GLGAT will only perform one update. A gtl A represents the attention weight matrix of GLGAT with respect to the LOGAT representation. ltg This represents the attention weight matrix of LOGAT for the GLGAT representation.

[0066] S2: Characterization matrix H gl H lo With the corresponding attention coefficient matrix A gtl A ltg Multiplying them yields the graph node representation vectors of the two graphs after the interaction;

[0067]

[0068] H′={H gl′ H lo′}

[0069] Among them, H l H represents the node representation output by the graph neural network after the l-th update. gl ′,H lo H' represents the representations obtained by GLGAT and LOGAT after cross-attention computation, respectively. H' is the total representation output by the graph neural network after one update, which will serve as the overall input for the next dual-graph neural network update. gl H is used as input for the next GLGAT. lo ' is used as the input for the next LOGAT.

[0070] The representations extracted by the dual-graph neural network, which has undergone multiple updates, are concatenated and input into the classification layer to calculate the final sentiment category probability:

[0071] S1: Obtain the speech u after being updated by the Lth graph neural network. i Final hidden layer representation:

[0072]

[0073] in, Each representing a speaker i After undergoing all updates from GLGAT and LOGAT, the output representations obtained are concatenated to obtain the speech u. i Final hidden representation for classification By concatenating all the final hidden layer representations of the dialogue data within a batch, we obtain the overall representation used for classification. Where || represents vector concatenation, and N represents the total number of messages in a batch.

[0074] S2: Regarding the speech u i The final hidden layer representation is then subjected to softmax classification to obtain the sentiment category with the highest probability.

[0075]

[0076] p i =softmax(W o o i +b o )

[0077]

[0078] Where ReLU(.) is the activation function, softmax(.) is the probability normalization function, argmax(.) is the classification function for finding the maximum value, and W... h ,b h W o ,b o For trainable parameters, o i For transitional characterization, p i For speaking u i The probability distribution of each sentiment category. For speaking u i One-hot encoding of the sentiment category predicted by the model.

[0079] Finally, for the features extracted by the model, contrastive learning is used to calculate the similarity between the representations of various sentiment categories, and the loss is calculated accordingly. This allows the model to generate more similar sentiment features for statements of the same sentiment category, and more differentiated sentiment features for statements of different sentiment categories. The difference loss between sentiment labels is L. label The calculation is as follows:

[0080]

[0081] Where, N b This represents the total number of messages in a batch. I(.) is an indicator function that has a value of 1 when the condition within the function is met, and 0 otherwise. Speech generated for a two-graph neural network model i The final emotional representation, y i For speaking u i True emotional labels This is a similarity function used to calculate the degree of similarity between vectors x and y.

[0082] In the implementation of contrastive learning, an additional auxiliary set is constructed to assist the contrastive learning algorithm. This addresses the problem in traditional contrastive learning algorithms where, when there is only one statement for a certain sentiment category within a batch, the lack of positive examples can lead to... label The problem is that it cannot be calculated correctly. The construction and application of auxiliary sets are as follows:

[0083] center c =mean(h i ),y i =c

[0084] h c =NEAREST(h i ,center c ), i = 1, 2, 3…N

[0085] support c =Relu(Linear(h) c ))

[0086] CInput = (H final ||support c )

[0087] Here, mean(.) is the average function, NEAREST(x,y) is the nearest neighbor function, which returns the vector in the set x that has the highest similarity to y, Relu(.) is the activation function, and Linear(.) is the linear function. c h is the average representation center of all statements in the dataset with sentiment category c.i For speaking u i The initial emotional representation of RoBERTa, y i For speaking u i True emotional tags, h c This indicates that among all statements with sentiment category c, the initial sentiment representation is the one with the center. c The most similar speech representations This is a similarity function. c for h c After linear transformation, the auxiliary representation representing sentiment category c is given. CInput is the input of a batch of data to the contrastive learning module. H final This is the final representation set of all dialogue data within a batch after processing by a dual-graph neural network model, where || represents vector concatenation.

[0088] After contrastive learning is completed, the loss is calculated using a combination of the cross-entropy sentiment loss function and the contrastive learning loss function. The overall model loss function is calculated as follows:

[0089]

[0090] L = L emo +λL label

[0091] Among them, L emo For the loss function of the sentiment classification model, cross-entropy loss is used, N b p represents the total number of messages within a batch. i For speaking u i The probability distribution of each sentiment category, y i For speaking u i One-hot encoding of the true sentiment label, where λ is a weight hyperparameter less than 1. L is the overall loss function of the model.

[0092] The model uses the Adam algorithm to optimize the parameters and minimize the loss function. The Adam algorithm is an optimization algorithm that can replace the traditional stochastic gradient descent process. It iteratively updates the neural network weights based on training data and can design independent adaptive learning rates for different parameters by calculating the first and second moment estimates of the gradient. The main calculation formulas are as follows:

[0093]

[0094] Where, Δθ t This represents the updated parameter values ​​during training. This represents the corrected first-order moment estimate. Let represent the corrected second-order moment estimate, and ∈ and η be the parameters that need to be adjusted during training.

[0095] In the experiment, macro-F1 was used as the evaluation index to evaluate the model, which represents the accuracy and stability of the model for classifying various types of emotional statements;

[0096] The specific process includes:

[0097] Calculate the F1 score for each sentiment category. c :

[0098]

[0099] Calculate macro-F1:

[0100]

[0101] Among them, F1-score c Recall represents the F1 score of sentiment category c. c and Precision c represents the accuracy and recall of sentiment category c, respectively; Y represents the number of sentiment categories in the dataset; and macro-F1 represents the final evaluation metric, with a higher value indicating better performance of the model in dialogue sentiment recognition.

[0102] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.

Claims

1. A dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning, characterized in that, include: Preprocess the dialogue dataset; The preprocessed data is input into the trained dialogue emotion recognition model to obtain the probability that each utterance in the dialogue belongs to a certain emotion category, and the emotion category to which each utterance belongs is output according to the probability. The dialogue emotion recognition model includes: RoBERTa model, dual-graph attention neural network, cross-attention mechanism module, softmax classification layer and contrastive learning module; The dual-graph attention neural network includes: a global context graph neural network GLGAT and a local context graph neural network LOGAT; The process of training a dialogue emotion recognition model includes: S1: Obtain the original dialogue dataset, divide the dataset into training and test sets; preprocess the data in the training set; S2: Input the preprocessed data into the RoBERTa model to generate the initial semantic representation of each statement; S3: Input the initial semantic representation into the dual-graph attention neural network to obtain the local context semantic representation H. lo and global context semantic representation H gl ; S4: Input the local and global contextual semantic representations into the cross-attention mechanism module for interaction to obtain the fused dialogue semantic representation; The local and global contextual semantic representations are input into the cross-attention mechanism module for interaction, resulting in a fused dialogue semantic representation, including: S41: Representing local and global contextual semantics H lo H gl The attention coefficient matrix of the two representation matrices with respect to each other is obtained by calculating the cross-attention mechanism function; Where softmax(.) denotes the normalization function, W denotes the trainable parameter matrix, T denotes the matrix transpose, and H... l Let A represent the node representation output by the graph neural network after the l-th update, where n is the difference hyperparameter. Before information exchange between the two graph neural networks, LOGAT will perform n internal node updates, while GLGAT will only perform one update. gtl A represents the attention weight matrix of GLGAT with respect to the LOGAT representation. ltg Represents the attention weight matrix of LOGAT for the GLGAT representation; S42: Representing local and global contextual semantics H gl H lo With the corresponding attention coefficient matrix A gtl A ltg Multiplication yields the fused semantic representation of the dialogue; H′={H gl′ ,H lo′ } Among them, H gl′ H lo′ These are the representations obtained by cross-attention calculation for GLGAT and LOGAT, respectively, and H′ represents the dialogue semantic representation output by the graph neural network after one update. S5: Obtain dialogue sentiment representations for sentiment classification based on the fused dialogue semantic representations; S6: Perform softmax classification on the sentiment representation of the dialogue to obtain the sentiment category of each utterance; set the initial value for the number of iterations; S7: Input the dialogue sentiment representation into the contrastive learning module assisted by the auxiliary set, and calculate the contrastive learning loss; S8: The cross-entropy loss function is used to calculate the loss for sentiment classification, and together with the contrastive learning loss, it is used to train the model. S9: The model is optimized using the Adam algorithm; S10: Determine if the number of iterations has reached the maximum number of iterations. If it has, complete the training of the dialogue emotion recognition model. Otherwise, return to step S8 and increment the number of iterations by 1.

2. The dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning according to claim 1, characterized in that, The preprocessing of the dialogue dataset includes: Stop words are removed from the original dialogue dataset. For each dialogue group, the length of each speech is set to the length of the longest speech in the dialogue. Speech that is too long is truncated from the end, and speech that is too short is padded.

3. The dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning according to claim 1, characterized in that, The preprocessed data is input into the RoBERTa model to generate an initial semantic representation for each utterance, including: Input(u i )=[CLS],w1,…,w i ,…,w n ,[SEP] h i =RoBERTa(Input(u i )) Among them, Input(u i ) represents the input of the RoBERTa model, u i This indicates a statement made during a dialogue. i (1≤i≤n) represents a single word in the speech, [CLS] is the category marker, [SEP] is the end marker, and h i Indicates speaking u i The output of the last hidden layer at position [CLS] after inputting into the RoBERTa model is used as the speaker u. i The initial semantic representation.

4. The dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning according to claim 1, characterized in that, The initial semantic representation is input into a dual-graph attention neural network to obtain local contextual semantic representations and global contextual semantic representations, including: Global context semantic representation: H gl =GLGAT(H,E gl ) The overall input of a batch of data to the model is H = (h1||h2||h3…h N ), || represents vector concatenation, N represents the total number of messages in a batch; h i Indicates speaking u i The initial semantic representation, E gl H represents the edge set in the graph structure of GLGAT. gl This represents the output representation obtained after the input H is updated by GLGAT; Local context semantic representation: A lo =LOGAT(H,E lo ) Among them, E lo H represents the edge set in the graph structure of LOGAT. lo This represents the output representation obtained after updating the input H using LOGAT.

5. The dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning according to claim 1, characterized in that, The dialogue sentiment representation for sentiment classification will be obtained based on the fused dialogue semantic representation, including: The dialogue semantic representation H′ after one update will be used as the overall input for the next bi-graph neural network update, where H... gl′ As input for the next GLGAT, H lo′ As input for the next LOGAT, obtain the speech u after L iterations of graph neural network updates. i Dialogue sentiment representations used for classification: in, Each representing a speaker i The output representation obtained after undergoing all updates from GLGAT and LOGAT, where || represents vector concatenation. Indicates speaking u i The dialogue sentiment representation used for classification; by concatenating all the dialogue sentiment representations used for classification within a batch of dialogue data, the overall dialogue sentiment representation used for classification is obtained. N represents the total number of messages in a batch.

6. The dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning according to claim 1, characterized in that, Softmax classification is performed on the sentiment representation of the dialogue to obtain the sentiment category of each utterance, including: p i =softmax(W o o i +b o ) Where ReLU(.) represents the activation function, softmax(.) represents the probability normalization function, argmax(.) represents the classification function that finds the maximum value, and W... h ,b h W o ,b o Represents the first, second, third, and fourth trainable parameters of the classification layer, o i p represents the transition characterization. i Indicates speaking u i The probability distribution of each sentiment category. Indicates speaking u i One-hot encoding of the sentiment category predicted by the model.

7. The dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning according to claim 1, characterized in that, The dialogue sentiment representation is input into a contrastive learning module assisted by an auxiliary set, and the contrastive learning loss is calculated, including: Among them, L label N represents the contrastive learning loss. b This represents the total number of messages spoken within a batch of dialogues. `I(.)` represents an indicator function; its value is 1 if a condition within the function is met, and 0 otherwise. Each represents a speech u i u k u k Dialogue sentiment representation used for classification, y i y k Each represents a speech u o u k The true sentiment label, F(.) represents the similarity function; To avoid the situation where there is only one statement for a certain sentiment category in a batch, the lack of positive examples would lead to L... label For problems that cannot be correctly computed, construct the following auxiliary set to assist in comparative learning: center c =mean(h i ),y i =c h c =NEAREST(h i ,center c ),i=1,2,3…N support c =Relu(Linear(h c )) CInput=(H final ||support c ) Where mean(.) is the mean function, NEAREST(x,y) is the nearest neighbor function, ReLU(.) is the activation function, Linear(.) is the linear function, and center... c h is the average representation center of all statements in the dataset with sentiment category c. i For speaking u i The initial emotional representation of RoBERTa, y i For speaking u i True emotional tags, h c This represents the initial sentiment representation of all statements with sentiment category c that is related to the center. c The most similar speech representation, support c The auxiliary representation representing sentiment category c, CInput, represents the alternative to H. final As a batch of data, H serves as the input to the contrastive learning module. final N represents the overall dialogue sentiment representation used for classification, where N is the total number of statements in a batch.

8. The dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning according to claim 1, characterized in that, The loss for sentiment classification is calculated using the cross-entropy loss function, including: Among them, L emo N represents the sentiment classification loss. b p represents the total number of messages spoken in a conversation. i Indicates speaking u i The probability distribution of each sentiment category, y i Indicates speaking u i Authentic emotional tags.

9. The dialogue emotion recognition method based on dual-graph attention neural network and contrastive learning according to claim 1, characterized in that, The Adam algorithm is used to optimize the model, including: Where, Δθ t This represents the updated parameter values ​​during training. This represents the corrected first-order moment estimate. Let represent the corrected second-order moment estimate, and ∈ and η represent the first and second parameters that need to be adjusted during the training process, respectively.

Citation Information

Patent Citations

  • Session sentiment analysis method based on multi-granularity fusion and graph convolutional network

    CN115374281A

  • Microblog comment dialogue sentiment analysis method and system based on graph neural network

    CN118228733A