Emotion recognition method and device, computer device, and storage medium
By constructing a domain subgraph of the target domain and enhancing sentences with external knowledge, combined with graph convolutional coding and feature interaction, the problems of neglecting domain differences and task relevance in E2E ABSA are solved, achieving higher emotion recognition accuracy.
Patent Information
- Application Number
- CN202410012883.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-01-02
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2044-01-02
AI Technical Summary
Existing End-to-End Aspect-Based Sentiment Analysis (E2E ABSA) methods suffer from large differences in aspect term distributions, limited model performance, and neglect of ATE and ASC task relevance in cross-domain applications, resulting in insufficient sentiment recognition accuracy.
Construct a domain subgraph of the target domain, combine external knowledge to enhance sentences, and perform feature interaction through graph convolutional coding, word encoding, aspect vector extraction, and sentiment vector extraction to achieve aspect-level sentiment classification and improve the accuracy of sentiment recognition.
By integrating graph features, aspect features and sentiment features, the accuracy of cross-domain sentiment recognition is improved, the problems of ignoring domain differences and task relevance are solved, and the accuracy of sentiment recognition is improved.
Smart Images

Figure CN117972087B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of device emotion recognition, and in particular to an emotion recognition method, device, computer equipment and storage medium. Background Art
[0002] End-to-End Aspect-Based Sentiment Analysis (E2E ABSA) is a branch of sentiment classification that aims to jointly identify specific aspect terms and their sentiment polarity in a sentence. It involves two subtasks: aspect term extraction (ATE) and aspect-level sentiment classification (ASC). The former aims to extract aspect terms from a sentence, while the latter aims to identify the sentiment polarity of aspect terms. For example, given the sentence "the price is reasonable although the service is poor," the ATE task aims to extract the aspect terms "price" and "service" from the sentence. The ASC task, on the other hand, aims to identify that the sentiment polarity of "price" is positive and that of "service" is negative. Existing research typically relies on large amounts of annotated data. However, many domains lack sufficient annotated data, and labeling domains is a time-consuming and resource-intensive process. To address this issue, some research has attempted to use unsupervised domain adaptation techniques. In unsupervised domain adaptation, given some unlabeled target domain data and labeled source domain data, common knowledge from the source domain is transferred to target domain test data.
[0003] However, E2E ABSA is a fine-grained task. Most aspect terms are related to specific domains, resulting in significant differences in the distribution of aspect terms across different domains. For example, the term "battery" that appears in the laptop domain is unlikely to appear in the restaurant domain. Therefore, reducing the domain differences in aspect terms has become a major challenge in cross-domain E2E ABSA. In recent years, knowledge graphs (KGs) have been widely used in natural language processing (NLP) tasks because they can provide a large amount of rich structured knowledge and entity relationships, effectively improving domain adaptation capabilities.
[0004] However, existing methods for leveraging external knowledge for domain adaptation are often coarse-grained. For fine-grained tasks like E2E ABSA, a large number of domain-specific terms, such as "battery" in the laptop domain, often hinder model performance. On the other hand, ATE and ASC tasks are strongly correlated. Most previous methods employ a unified joint annotation scheme, which ignores the correlation and interaction between ATE and ASC tasks, making it difficult to understand the impact of aspect terms from different domains on overall sentiment evaluation and domain-specific sentiment tendencies. Summary of the Invention
[0005] Based on this, the purpose of the present invention is to provide a sentiment recognition method, apparatus, computer equipment and storage medium, which constructs a domain subgraph associated with the sentence to be recognized based on the text data of the target domain, so as to construct the external knowledge enhanced sentence corresponding to the sentence to be recognized and the graph feature information integrated with the external knowledge, extract feature information of the sentence to be recognized and the external knowledge enhanced sentence, obtain aspect feature information and sentiment feature information, and combine the graph feature information, aspect feature information and sentiment feature information to realize aspect-level sentiment classification of the sentence to be recognized, thereby improving the sentiment recognition accuracy of the sentence to be recognized.
[0006] In a first aspect, an embodiment of the present application provides an emotion recognition method, comprising the following steps:
[0007] Obtaining target domain text data, sentences to be recognized, and a preset emotion recognition model, wherein the target domain text data includes a plurality of target domain sentences, and the emotion recognition model includes a graph convolutional encoding module, a word encoding module, an aspect vector extraction module, a emotion vector extraction module, a feature interaction module, and an emotion recognition module;
[0008] Based on a plurality of target domain sentences and sentences to be recognized in the text data of the target domain, construct a domain subgraph corresponding to the sentences to be recognized, and input the domain subgraph into the graph convolutional coding module to obtain a graph feature vector, wherein the domain subgraph is used to indicate the domain knowledge relationship between the sentences to be recognized and the target domain;
[0009] According to the domain subgraph, construct an external knowledge enhanced sentence corresponding to the sentence to be recognized, input the sentence to be recognized and the external knowledge enhanced sentence into the word encoding module to obtain a word embedding feature vector;
[0010] Inputting the word embedding feature vector into the aspect vector extraction module for feature extraction to obtain an aspect feature vector, and inputting the aspect feature vector into the emotion vector extraction module for feature extraction to obtain an emotion feature vector;
[0011] Inputting the aspect feature vector and the emotion feature vector into the feature interaction module to perform feature interaction, thereby obtaining an interaction aspect feature vector and an interaction emotion feature vector;
[0012] The graph feature vector, the interaction aspect feature vector and the interaction emotion feature vector are input into the emotion recognition module for analysis to obtain the emotion recognition result of the sentence to be recognized.
[0013] In a second aspect, an embodiment of the present application provides an emotion recognition device, comprising:
[0014] A data acquisition module, configured to obtain text data of a target domain, sentences to be recognized, and a preset emotion recognition model, wherein the text data of the target domain includes a plurality of target domain sentences, and the emotion recognition model includes a graph convolutional encoding module, a word encoding module, an aspect vector extraction module, an emotion vector extraction module, a feature interaction module, and an emotion recognition module;
[0015] a first feature extraction module, configured to construct a domain subgraph corresponding to a plurality of target domain sentences and a sentence to be identified in the text data of the target domain, and input the domain subgraph into the graph convolutional coding module to obtain a graph feature vector, wherein the domain subgraph is used to indicate the domain knowledge relationship between the sentence to be identified and the target domain;
[0016] A second feature extraction module is configured to construct an external knowledge-enhanced sentence corresponding to the sentence to be recognized based on the domain subgraph, and input the sentence to be recognized and the external knowledge-enhanced sentence into the word encoding module to obtain a word embedding feature vector;
[0017] a third feature extraction module, configured to input the word embedding feature vector into the aspect vector extraction module for feature extraction to obtain an aspect feature vector, and input the aspect feature vector into the emotion vector extraction module for feature extraction to obtain an emotion feature vector;
[0018] A feature interaction module, configured to input the aspect feature vector and the emotion feature vector into the feature interaction module for feature interaction, thereby obtaining an interaction aspect feature vector and an interaction emotion feature vector;
[0019] The sentiment analysis module is used to input the graph feature vector, the interaction aspect feature vector and the interaction sentiment feature vector into the sentiment recognition module for analysis to obtain the sentiment recognition result of the sentence to be recognized.
[0020] In a third aspect, an embodiment of the present application provides a computer device comprising: a processor, a memory, and a computer program stored on the memory and executable on the processor; when the computer program is executed by the processor, the steps of the emotion recognition method as described in the first aspect are implemented.
[0021] In a fourth aspect, an embodiment of the present application provides a storage medium, which stores a computer program, and when the computer program is executed by a processor, it implements the steps of the emotion recognition method as described in the first aspect.
[0022] In an embodiment of the present application, a sentiment recognition method, apparatus, computer device and storage medium are provided. Based on text data of a target domain, a domain subgraph associated with a sentence to be recognized is constructed to construct an external knowledge-enhanced sentence corresponding to the sentence to be recognized and graph feature information incorporating external knowledge. Feature information is extracted from the sentence to be recognized and the external knowledge-enhanced sentence to obtain aspect feature information and sentiment feature information. By combining the graph feature information, aspect feature information and sentiment feature information, aspect-level sentiment classification of the sentence to be recognized is realized, thereby improving the sentiment recognition accuracy of the sentence to be recognized.
[0023] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A flowchart of an emotion recognition method provided in one embodiment of the present application;
[0025] Figure 2 A schematic diagram of the process of step S2 in the emotion recognition method provided in one embodiment of the present application;
[0026] Figure 3 A schematic diagram of the process of step S3 in the emotion recognition method provided in one embodiment of the present application;
[0027] Figure 4 A schematic diagram of the flow of step S4 in the emotion recognition method provided in one embodiment of the present application;
[0028] Figure 5 A schematic diagram of the flow of S5 in the emotion recognition method provided in one embodiment of the present application;
[0029] Figure 6 A schematic diagram of the flow of S6 in the emotion recognition method provided in one embodiment of the present application;
[0030] Figure 7 A schematic diagram of the flow of step S7 in the emotion recognition method provided in another embodiment of the present application;
[0031] Figure 8A flowchart of step S7 in the emotion recognition method provided in another embodiment of the present application;
[0032] Figure 9 A schematic diagram of the structure of an emotion recognition device provided in one embodiment of the present application;
[0033] Figure 10 A schematic diagram of the structure of a computer device provided in one embodiment of the present application. DETAILED DESCRIPTION
[0034] Exemplary embodiments will be described in detail herein, with examples illustrated in the accompanying drawings. In the following description, when referring to the drawings, identical numerals in different figures represent identical or similar elements, unless otherwise indicated. The embodiments described in the following exemplary embodiments are not intended to represent all embodiments consistent with the present application. Rather, they are merely examples of apparatus and methods consistent with certain aspects of the present application, as detailed in the appended claims.
[0035] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. As used in this application and the appended claims, the singular forms "a," "an," "the," and "the" are intended to include the plural forms, unless the context clearly indicates otherwise. It should also be understood that the term "and / or" as used herein refers to and encompasses any and all possible combinations of one or more of the associated listed items.
[0036] It should be understood that although the terms first, second, third, etc. may be used in this application to describe various information, such information should not be limited to these terms. These terms are only used to distinguish information of the same type from each other. For example, without departing from the scope of this application, first information may also be referred to as second information, and similarly, second information may also be referred to as first information. Depending on the context, the words "if" / "if" as used herein may be interpreted as "at the time of" or "when" or "in response to a determination."
[0037] See also Figure 1 , Figure 1 A flowchart of an emotion recognition method provided in one embodiment of the present application is provided, wherein the method comprises the following steps:
[0038] S1: Obtain the text data of the target domain, the sentences to be recognized, and the preset emotion recognition model.
[0039] The execution subject of the emotion recognition method is a recognition device of the emotion recognition method (hereinafter referred to as the recognition device). In an optional embodiment, the recognition device can be a computer device, a server, or a server cluster composed of multiple computer devices.
[0040] In this embodiment, the recognition device can obtain user input, or obtain text data of the target domain and sentences to be recognized from a preset database, wherein the text data of the target domain includes several target domain sentences, and the target domain sentences and sentences to be recognized both include several words.
[0041] The emotion recognition model includes a graph convolutional encoding module, a word encoding module, an aspect vector extraction module, a emotion vector extraction module, a feature interaction module and an emotion recognition module.
[0042] S2: Based on several target domain sentences and sentences to be recognized in the text data of the target domain, construct a domain subgraph corresponding to the sentences to be recognized, input the domain subgraph into the graph convolutional coding module, and obtain a graph feature vector.
[0043] In this embodiment, the recognition device constructs a domain subgraph corresponding to the sentence to be recognized based on several target domain sentences and the sentence to be recognized in the text data of the target domain, wherein the domain subgraph is used to indicate the domain knowledge relationship between the sentence to be recognized and the target domain.
[0044] Specifically, the recognition device extracts nouns, verbs, adjectives and adverbs from several target domain sentences and sentences to be recognized in the text data of the target domain, constructs several word nodes, groups the several word nodes into a set, filters the external knowledge base ConceptNet through it, and constructs a domain subgraph corresponding to the sentences to be recognized, wherein the domain subgraph includes several word nodes and several relationship nodes between the word nodes, and the relationship nodes are used to indicate the dependency relationship between the word nodes.
[0045] The recognition device inputs the domain subgraph into the graph convolutional coding module to obtain a graph feature vector, wherein the graph convolutional coding module includes a graph convolutional network, and the graph convolutional network includes several graph convolutional layers. Figure 2 , Figure 2 The flowchart of S2 in the emotion recognition method provided in one embodiment of the present application includes steps S21 to S22, which are specifically as follows:
[0046] S21: Input the domain subgraph into the graph convolution network, and obtain the graph convolution vectors of the word nodes output by the last graph convolution layer of the graph convolution encoding module according to the word nodes in the domain subgraph and a preset graph convolution algorithm.
[0047] The graph convolution algorithm is:
[0048]
[0049] Where u and j are word indices, is the graph convolution vector of the uth word node output by the lth graph convolution layer of the graph convolution network, R is a set of relationship nodes, including relationship nodes between several of the word nodes, r is a relationship node, is the set of adjacent word nodes of the u-th word node under the r relationship node, are respectively the second weight parameter and the first weight parameter of the lth graph convolution layer of the graph convolution network, is the graph convolution vector of the j-th word node output by the l-1-th graph convolution layer of the graph convolution network, is the graph convolution vector of the u-th word node output by the l-1-th graph convolution layer of the graph convolutional network, and σ(·) is the activation function.
[0050] In this embodiment, the recognition device inputs the domain subgraph into the graph convolution network, and obtains the graph convolution vectors of the several word nodes output by the last graph convolution layer of the graph convolution encoding module based on the several word nodes in the domain subgraph and the preset graph convolution algorithm.
[0051] S22: Obtain the graph feature vector according to the graph convolution vectors of the plurality of word nodes output by the last graph convolution layer of the graph convolution network and a preset graph feature vector calculation algorithm.
[0052] The graph feature vector calculation algorithm is:
[0053]
[0054] Where G is the graph feature vector, U is the number of word nodes, g′ u It is the graph convolution vector of the u-th word node output by the last graph convolution layer of the graph convolution encoding module.
[0055] In this embodiment, the recognition device obtains the graph feature vector by using an averaging processing method based on the graph convolution vectors of several word nodes output by the last graph convolution layer of the graph convolution network and a preset graph feature vector calculation algorithm.
[0056] S3: According to the domain subgraph, construct an external knowledge enhanced sentence corresponding to the sentence to be recognized, input the sentence to be recognized and the external knowledge enhanced sentence into the word encoding module, and obtain a word embedding feature vector.
[0057] In this embodiment, the recognition device constructs an external knowledge enhanced sentence corresponding to the sentence to be recognized based on the domain subgraph, and uses the external knowledge enhanced sentence to enhance the connection between the sentence to be recognized and the target domain, increase the transferability of domain-specific words, and improve the accuracy of emotion recognition of the sentence to be recognized.
[0058] Specifically, the recognition device constructs a plurality of triples based on a plurality of word nodes and a plurality of relationship nodes between the word nodes in the domain subgraph, wherein the triples include two word nodes and a relationship node between the two word nodes.
[0059] The recognition device extracts nouns, verbs, adjectives and adverbs from several target domain sentences in the target domain text data, constructs several candidate word nodes, and groups the several candidate word nodes into a candidate word node set. The recognition device takes several triples in which one word node belongs to the sentence to be recognized and another word node belongs to the candidate word node set as the first triple, and the recognition device marks the word nodes in the several first triples belonging to the candidate word node set as v x , the recognition device will have the word node v x As the second triplet, traverse the second triplet, if another word node v in the second triplet y At the same time, it belongs to the candidate word node set, and the word node v x As the target word node, the word corresponding to the target word node is obtained, and the external knowledge enhanced sentence corresponding to the sentence to be recognized is constructed.
[0060] The recognition device inputs the sentence to be recognized and the external knowledge enhanced sentence into the word encoding module to obtain the word embedding feature vector. Figure 3 , Figure 3 The flowchart of S3 in the emotion recognition method provided in one embodiment of the present application includes steps S31 to S34, which are specifically as follows:
[0061] S31: According to the sentence to be recognized, the external knowledge enhanced sentence and a preset word embedding encoding algorithm, obtain the word embedding sequence of the sentence to be recognized and the external knowledge enhanced sentence.
[0062] The word embedding encoding algorithm is:
[0063] E={e1,e2,...,e n}=BERT({x1,x2,...,x n})
[0064]
[0065] Where E is the word embedding sequence of the sentence to be recognized, e n is the word embedding vector of the nth word in the word embedding sequence of the sentence to be recognized, x n is the word vector of the nth word in the sentence to be recognized, E c Enhance the word embedding sequence of the sentence for the external knowledge, The word embedding vector of the mth word in the word embedding sequence of the external knowledge enhanced sentence, c m The word vector of the mth word in the sentence is enhanced with the external knowledge, and BERT(·) is the word embedding encoding function.
[0066] In this embodiment, the recognition device adopts the BERT (Bidirectional Encoder Representation from Transformers) word embedding model to obtain the word embedding sequence of the sentence to be recognized and the external knowledge enhanced sentence according to the sentence to be recognized, the external knowledge enhanced sentence and a preset word embedding encoding algorithm, wherein the word embedding sequence includes word embedding vectors of several words.
[0067] S32: Obtain the number of occurrences of several words in the external knowledge enhanced sentence, obtain the association score data of the external knowledge enhanced sentence based on the number of occurrences of several words in the external knowledge enhanced sentence and a preset association score calculation algorithm, and obtain the aggregated word embedding sequence of the external knowledge enhanced sentence based on the association score data and word embedding sequence of the external knowledge enhanced sentence.
[0068] In order to make full use of external knowledge and improve the accuracy of emotion recognition of the sentence to be recognized, in this embodiment, the recognition device obtains the number of occurrences of several words in the external knowledge enhanced sentence, and obtains the association score data of the external knowledge enhanced sentence based on the number of occurrences of several words in the external knowledge enhanced sentence and a preset association score calculation algorithm, wherein the association score data of the external knowledge enhanced sentence includes the association score vectors of the several words, the aggregate word embedding sequence includes the aggregate word embedding vectors of the several words, and the association score calculation algorithm is:
[0069]
[0070] Where sc i The associated score vector of the i-th word in the sentence is enhanced with the external knowledge, The number of occurrences of the i-th word in the sentence is used to enhance the external knowledge.
[0071] The recognition device aggregates the association score vector and word embedding vector of the same word based on the association score data and word embedding sequence of the external knowledge enhanced sentence to obtain the aggregated word embedding sequence of the external knowledge enhanced sentence, as follows:
[0072]
[0073] Where, The aggregate word embedding vector of the i-th word in the aggregate word embedding sequence of the external knowledge enhanced sentence, The word embedding vector of the i-th word in the word embedding sequence of the sentence is enhanced with the external knowledge.
[0074] S33: According to the word embedding sequence of the sentence to be recognized, the aggregated word embedding sequence of the external knowledge enhanced sentence and a preset context encoding algorithm, the context representation sequence of the sentence to be recognized and the external knowledge enhanced sentence is obtained.
[0075] The context coding algorithm is:
[0076]
[0077]
[0078] Where, is the context representation sequence of the sentence to be recognized, is the context vector of the nth word in the context representation sequence of the sentence to be recognized, enhancing the context representation sequence of the sentence for the external knowledge, The context vector of the mth word in the sequence of the context representation of the sentence enhanced by the external knowledge, is the aggregate word embedding vector of the mth word in the aggregate word embedding sequence of the external knowledge enhanced sentence, and PLM(·) is the context encoding function.
[0079] In this embodiment, the recognition device adopts a pre-trained language model (PLM) to obtain the context representation sequence of the sentence to be recognized and the external knowledge enhanced sentence based on the word embedding sequence of the sentence to be recognized, the aggregated word embedding sequence of the external knowledge enhanced sentence and a preset context encoding algorithm, wherein the context feature sequence includes context vectors of several words.
[0080] S34: Obtain the word embedding feature vector according to the context vector corresponding to the same word index in the context representation sequence of the sentence to be recognized and the external knowledge enhanced sentence and a preset word embedding feature extraction algorithm.
[0081] The word embedding feature extraction algorithm is:
[0082]
[0083] Where Z is the word embedding feature vector, W z is the weight parameter of the word encoding module, σ(·) is the activation function, is the concatenation symbol, and ⊙ is the element-wise multiplication symbol.
[0084] In this embodiment, the recognition device obtains the word embedding feature vector based on the context vector corresponding to the same word index in the context representation sequence of the sentence to be recognized and the external knowledge enhanced sentence and a preset word embedding feature extraction algorithm.
[0085] S4: Inputting the word embedding feature vector into the aspect vector extraction module for feature extraction to obtain an aspect feature vector, and inputting the aspect feature vector into the emotion vector extraction module for feature extraction to obtain an emotion feature vector.
[0086] The aspect vector extraction module includes a stacked convolutional network, which includes several stacked convolutional layers; the emotion vector extraction module includes a multi-head self-attention network.
[0087] In this embodiment, the recognition device adopts an end-to-end framework combination, inputs the word embedding feature vector into the aspect vector extraction module for feature extraction, obtains the aspect feature vector, inputs the aspect feature vector into the emotion vector extraction module for feature extraction, obtains the emotion feature vector, so as to extract the aspect words and emotion polarity of the sentence to be recognized.
[0088] See also Figure 4 , Figure 4 The flowchart of S4 in the emotion recognition method provided in one embodiment of the present application includes steps S41 to S43, which are specifically as follows:
[0089] S41: Using the word embedding feature vector as the first layer input of the stacked convolutional network, and according to a preset stacked convolution algorithm, obtaining the stacked convolution vector output by the last stacked convolution layer of the stacked convolutional network as the aspect feature vector.
[0090] The stacked convolution algorithm is:
[0091] a l =σ(a l-1 *k l-1 +b l-1 )
[0092] Where a l is the stacked convolution vector output by the lth stacked convolution layer of the stacked convolution network, al-1 is the stacked convolution vector output by the l-1th stacked convolution layer of the stacked convolution network, k l-1 is the convolution kernel group of the l-1th stacked convolution layer of the stacked convolution network, b l-1 is the bias parameter of the l-1th stacked convolutional layer of the stacked convolutional network, and σ(·) is the activation function.
[0093] In this embodiment, the recognition device uses the word embedding feature vector as the first-layer input of the stacked convolutional network, and obtains the stacked convolution vector output by the last stacked convolution layer of the stacked convolutional network according to a preset stacked convolution algorithm as the aspect feature vector, which is used to extract the sentiment feature vector and realize aspect-level sentiment classification of the sentence to be recognized.
[0094] S42: Obtain a first matrix, a second matrix, and a third matrix according to the aspect eigenvector and a preset matrix construction algorithm.
[0095] The matrix construction algorithm is:
[0096] Q=a′W Q
[0097] K=a′W K
[0098] V=a′W V
[0099] Where a′ is the aspect eigenvector, Q is the first matrix, and W Q is the first weight parameter of the emotion vector extraction module, V is the second matrix, W K is the second weight parameter of the emotion vector extraction module, V is the third matrix, W V It is the third weight parameter of the emotion vector extraction module.
[0100] In this embodiment, the recognition device obtains the first matrix, the second matrix, and the third matrix according to the aspect feature vector and a preset matrix construction algorithm.
[0101] S43: Input the first matrix, the second matrix and the third matrix into the multi-head self-attention network, obtain the attention feature vectors output by several self-attention heads according to the preset multi-head self-attention extraction algorithm, and splice the attention feature vectors output by several self-attention heads to obtain the emotion feature vector.
[0102] The multi-head self-attention extraction algorithm is:
[0103]
[0104] In the formula, o j is the attention feature vector output by the j-th self-attention head, softmax(·) is the normalization function, T is the transpose symbol, and d is the dimension parameter.
[0105] In this embodiment, the recognition device inputs the first matrix, the second matrix and the third matrix into the multi-head self-attention network, and obtains the attention feature vectors output by several self-attention heads according to the preset multi-head self-attention extraction algorithm. In order to better model the relationship between the aspect feature vector and the context, the recognition device constructs the matrix parameters corresponding to the aspect feature vector and adopts the multi-head self-attention mechanism to extract the emotion feature vector with higher accuracy in the sentence to be recognized, thereby improving the accuracy of emotion recognition of the sentence to be recognized.
[0106] The recognition device concatenates the attention feature vectors output by the plurality of self-attention heads to obtain the emotion feature vector, as follows:
[0107] s=Concat(o1,o2,…o j )
[0108] Wherein, s is the sentiment feature vector, and Concat(·) is the concatenation function.
[0109] S5: Inputting the aspect feature vector and the emotion feature vector into the feature interaction module for feature interaction to obtain an interactive aspect feature vector and an interactive emotion feature vector.
[0110] In order to fully utilize the correlation between the aspect feature vector and the emotion feature vector, in this embodiment, the recognition device inputs the aspect feature vector and the emotion feature vector into the feature interaction module for feature interaction to obtain the interaction aspect feature vector and the interaction emotion feature vector.
[0111] See also Figure 5 , Figure 5 The flowchart of S5 in the emotion recognition method provided in one embodiment of the present application includes steps S51 to S52, which are specifically as follows:
[0112] S51: Obtain the interaction aspect feature vector according to the aspect feature vector, the emotion feature vector and a preset first feature interaction algorithm.
[0113] The first feature interaction algorithm is:
[0114] I a =β·s+(1-β)·a′
[0115] Where, I a is the interaction aspect feature vector, β is, and a′ is the aspect feature vector.
[0116] In this embodiment, the recognition device obtains the interaction aspect feature vector based on the aspect feature vector, the emotion feature vector and a preset first feature interaction algorithm.
[0117] S52: Obtain the interactive emotional feature vector according to the aspect feature vector, the emotional feature vector and a preset second feature interaction algorithm.
[0118] The second feature interaction algorithm is:
[0119] I s =β·a′+(1-β)·s
[0120] Where, I s is the interactive emotion feature vector.
[0121] In this embodiment, the recognition device obtains the interactive emotional feature vector based on the aspect feature vector, the emotional feature vector and a preset second feature interaction algorithm.
[0122] S6: Inputting the graph feature vector, the interaction aspect feature vector and the interaction emotion feature vector into the emotion recognition module for analysis to obtain the emotion recognition result of the sentence to be recognized.
[0123] In this embodiment, the recognition device inputs the graph feature vector, the interaction aspect feature vector, and the interaction emotion feature vector into the emotion recognition module for analysis to obtain the emotion recognition result of the sentence to be recognized.
[0124] See also Figure 6 , Figure 6 The flowchart of S6 in the emotion recognition method provided in one embodiment of the present application includes steps S61 to S63, which are specifically as follows:
[0125] S61: linearly process the graph feature vector to obtain the graph feature vector after linear processing, and respectively splice the interaction aspect feature vector and the interaction emotion feature vector with the graph feature vector after linear processing to obtain a spliced aspect feature vector and a spliced emotion feature vector.
[0126] In this embodiment, the recognition device performs linear processing on the graph feature vector to obtain the graph feature vector after linear processing, as follows:
[0127] G′=sigmoid(FC(G))
[0128] Where G′ is the graph feature vector after linear processing, sigmoid(·) is the activation function, and FC(·) is the linear function.
[0129] In order to further make the interaction aspect feature vector and the interaction emotion feature vector have stronger domain invariance, the recognition device splices the interaction aspect feature vector and the interaction emotion feature vector with the linearly processed graph feature vector to obtain the spliced aspect feature vector and the spliced emotion feature vector, as follows:
[0130] A=[G′,I a ]
[0131] S=[G′,I s ]
[0132] Wherein, A is the splicing aspect feature vector, and S is the splicing emotion feature vector.
[0133] S62: Obtain a predicted aspect probability distribution vector based on the spliced aspect feature vector and a preset predicted aspect probability distribution vector calculation algorithm; obtain a predicted emotion probability distribution vector based on the spliced emotion feature vector and a preset predicted emotion probability distribution vector calculation algorithm.
[0134] In this embodiment, the recognition device obtains the predicted aspect probability distribution vector based on the splicing aspect feature vector and a preset prediction aspect probability distribution vector calculation algorithm, wherein the prediction aspect probability distribution vector calculation algorithm is:
[0135]
[0136] Where, is the probability distribution vector of the prediction aspect, W a is the weight parameter of the aspect prediction module, and softmax(·) is the normalization function;
[0137] The recognition device obtains a predicted emotion probability distribution vector based on the spliced emotion feature vector and a preset predicted emotion probability distribution vector calculation algorithm, wherein the predicted emotion probability distribution vector calculation algorithm is:
[0138]
[0139] Where, To predict the emotion probability distribution vector, W s is the weight parameter of the emotion prediction module.
[0140] S63: According to the predicted aspect probability distribution vector, obtain the aspect prediction type corresponding to the dimension with the largest probability; according to the predicted emotion probability distribution vector, obtain the emotion prediction type corresponding to the dimension with the largest probability; according to the aspect prediction type and the emotion prediction type, obtain the emotion recognition result of the sentence to be recognized.
[0141] In this embodiment, the recognition device obtains the aspect prediction type corresponding to the dimension with the largest probability based on the predicted aspect probability distribution vector, obtains the emotion prediction type corresponding to the dimension with the largest probability based on the predicted emotion probability distribution vector, and obtains the emotion recognition result of the sentence to be recognized based on the aspect prediction type and the emotion prediction type. Based on the text data of the target domain, a domain subgraph associated with the sentence to be recognized is constructed to construct the external knowledge enhanced sentence corresponding to the sentence to be recognized and the graph feature information incorporating the external knowledge, and feature information is extracted from the sentence to be recognized and the external knowledge enhanced sentence to obtain aspect feature information and emotion feature information. By combining the graph feature information, aspect feature information and emotion feature information, aspect-level emotion classification of the sentence to be recognized is realized, thereby improving the emotion recognition accuracy of the sentence to be recognized.
[0142] In an optional embodiment, step S7 is further included: training the emotion recognition model, see Figure 7 , Figure 7 The flowchart of step S7 in the emotion recognition method provided in another embodiment of the present application includes steps S71 to S75, which are specifically as follows:
[0143] S71: Obtain a training text dataset, construct a domain subgraph corresponding to the training text dataset based on the training text dataset, and obtain external knowledge enhanced word sentences corresponding to several sentences in the text data of the source domain based on the domain subgraph.
[0144] In this embodiment, the recognition device obtains a training text data set, wherein the training text data set includes text data in a source domain and text data in a target domain, the text data includes a plurality of sentences, and the sentences include a plurality of words.
[0145] The recognition device constructs a domain subgraph corresponding to the training text dataset based on the training text dataset to introduce external knowledge and provide additional and diversified data, thereby effectively expanding the training data. This can enhance the emotion recognition model's understanding of professional terms, general facts and other knowledge in a specific field, thereby effectively alleviating the differences between fields and increasing the portability of the emotion recognition model.
[0146] Based on the domain subgraph, the recognition device obtains external knowledge-enhanced word sentences corresponding to several sentences in the text data of the source domain, and uses them as training data for the emotion recognition model to enhance the connection between the two domains and increase the domain adaptability of the emotion recognition model. For a specific embodiment, please refer to step S2 and will not be repeated here.
[0147] S72: Combine several sentences in the text data of the source domain and the corresponding external knowledge enhanced word sentences to construct several training sentence groups, input the several training sentence groups into the emotion recognition model, and obtain the splicing aspect feature vectors, splicing emotion feature vectors, predicted aspect probability distribution vectors and predicted emotion probability distribution vectors corresponding to the several training sentence groups.
[0148] In this embodiment, the recognition device combines several sentences in the text data of the source field and the corresponding external knowledge enhanced word sentences to construct several training sentence groups, inputs several of the training sentence groups into the emotion recognition model, and obtains the splicing aspect feature vectors, splicing emotion feature vectors, predicted aspect probability distribution vectors and predicted emotion probability distribution vectors corresponding to the several training sentence groups. For specific embodiments, please refer to steps S61 to S62, which will not be repeated here.
[0149] S73: Perform maximum pooling processing on the spliced aspect feature vectors and the spliced emotion feature vectors respectively to obtain the pooled aspect feature vectors and the pooled emotion feature vectors corresponding to the several training sentence groups, and obtain the prediction field label data corresponding to the several training sentence groups based on the pooled aspect feature vectors, the pooled emotion feature vectors and the preset prediction field algorithm.
[0150] In this embodiment, the recognition device performs maximum pooling processing on the spliced aspect feature vectors and the spliced emotion feature vectors respectively to obtain pooled aspect feature vectors and pooled emotion feature vectors corresponding to the plurality of training sentence groups, as follows:
[0151] M a =Maxpool(A)
[0152] M s =Maxpool(S)
[0153] Where M a is the pooled aspect feature vector, M s is the concatenated sentiment feature vector.
[0154] The recognition device adopts a domain classifier, introduces a gradient reversal layer to perform domain distinction based on the pooled aspect feature vectors, pooled sentiment feature vectors and a preset prediction domain algorithm corresponding to the plurality of training sentence groups, and obtains the predicted domain label data corresponding to the plurality of training sentence groups, wherein the preset prediction domain algorithm is:
[0155]
[0156] Where, To predict the domain label data, Wd is a preset learnable parameter, GRL λ (·) is the gradient reversal function, λ is the scaling factor, MLP(·) is the multi-layer perceptron function, and softmax(·) is the normalization function.
[0157] S74: Obtain real domain label data corresponding to the plurality of training sentence groups, and obtain a first loss value based on the real domain label data corresponding to the plurality of training sentence groups, the predicted domain label data, and a preset first loss function.
[0158] The first loss function is:
[0159]
[0160] Where, is the first loss value, y d is the real domain label data, For the prediction domain label data.
[0161] In this embodiment, the recognition device obtains real domain label data corresponding to several of the training sentence groups, and obtains a first loss value based on the real domain label data corresponding to the several training sentence groups, the predicted domain label data, and a preset first loss function. Through domain adversarial training, combined with the characteristic of the gradient reversal layer that can reverse the gradient direction during the training process, the feature vector is encouraged to remain domain-invariant, further improving the domain invariance, so as to improve the accuracy of sentence emotion recognition.
[0162] S75: Obtain the real aspect probability distribution vectors and the real emotion probability distribution vectors corresponding to the several training sentence groups, obtain the second loss value according to the real aspect probability distribution vectors, the real emotion probability distribution vectors, the predicted aspect probability distribution vectors, the predicted emotion probability distribution vectors and the preset second loss function corresponding to the several training sentence groups, and train the emotion recognition module according to the first loss value and the second loss value.
[0163] The second loss function is:
[0164]
[0165] Where, is the second loss value, y a is the true aspect probability distribution vector, is the probability distribution vector of the prediction aspect, To predict the probability distribution vector of emotion, y s is the true emotion probability distribution vector.
[0166] In this embodiment, the recognition device obtains the true aspect probability distribution vectors and the true emotion probability distribution vectors corresponding to the plurality of training sentence groups, obtains the second loss value based on the true aspect probability distribution vectors, the true emotion probability distribution vectors, the predicted aspect probability distribution vectors, the predicted emotion probability distribution vectors, and the preset second loss function corresponding to the plurality of training sentence groups, and trains the emotion recognition module based on the first loss value and the second loss value to understand the influence of aspect words in different fields on the overall emotion evaluation and the field-specific emotion tendency, thereby improving the accuracy of emotion recognition, as follows:
[0167]
[0168] Where, is the final loss value.
[0169] See also Figure 8 , Figure 8 The flowchart of step S7 in the emotion recognition method provided in another embodiment of the present application further includes steps S76 to S77, which are specifically as follows:
[0170] S76: Construct a positive triple set according to a plurality of word nodes and relationship nodes between the plurality of word nodes in the domain subgraph corresponding to the training text dataset.
[0171] In this embodiment, the recognition device constructs a positive triple set based on several word nodes and several relationship nodes between word nodes in the domain subgraph corresponding to the training text data set, wherein the positive triple set includes several positive triples, and the positive triple includes two word nodes and a relationship node between the two word nodes.
[0172] S77: Based on several positive triplets in the positive triplet set, construct several negative triplets corresponding to the positive triplets, construct a negative triplet set, obtain a third loss value based on the positive triplet set, the negative triplet set and a preset third loss function, and train the graph convolutional coding module based on the third loss value.
[0173] In this embodiment, the recognition device constructs a number of negative triples corresponding to the positive triples based on the positive triples in the positive triple set, thereby constructing a negative triple set. Specifically, the recognition device randomly modifies the word nodes or relationship nodes in the positive triples to construct an equal number of negative triples.
[0174] The recognition device obtains a third loss value based on the positive triple set, the negative triple set, and a preset third loss function, and trains the graph convolutional encoding module based on the third loss value to learn graph features, wherein the first loss function is:
[0175]
[0176]
[0177] Where, is the third loss value, s(v u ,r u,j ,v j ) is a positive triplet, v u is the u-th word node, v j is the jth word node, r u,j is the relationship node between the u-th word node and the j-th word node, is the graph convolution vector of the u-th word node, T is the transpose symbol, R r is the diagonal matrix corresponding to the relationship node set, g j is the graph convolution vector of the j-th word node, is a training triplet set constructed by combining the positive triplet set and the negative triplet set, y is a triplet label representation, y∈{0,1}, y=0 indicates that the triplet is a negative triplet, and y=1 indicates that the triplet is a positive triplet.
[0178] Please refer to Figure 9 , Figure 9 This is a schematic diagram of the structure of an emotion recognition device provided in one embodiment of the present application. The device can implement all or part of the emotion recognition device through software, hardware, or a combination of both. The device 9 includes:
[0179] A data acquisition module 91 is configured to obtain target domain text data, sentences to be recognized, and a preset emotion recognition model, wherein the target domain text data includes a plurality of target domain sentences, and the emotion recognition model includes a graph convolutional encoding module, a word encoding module, an aspect vector extraction module, an emotion vector extraction module, a feature interaction module, and an emotion recognition module;
[0180] A first feature extraction module 92 is configured to construct a domain subgraph corresponding to a plurality of target domain sentences and a sentence to be identified in the target domain text data, and input the domain subgraph into the graph convolutional coding module to obtain a graph feature vector, wherein the domain subgraph is used to indicate the domain knowledge relationship between the sentence to be identified and the target domain;
[0181] A second feature extraction module 93 is configured to construct an external knowledge-enhanced sentence corresponding to the sentence to be recognized based on the domain subgraph, and input the sentence to be recognized and the external knowledge-enhanced sentence into the word encoding module to obtain a word embedding feature vector;
[0182] A third feature extraction module 94 is configured to input the word embedding feature vector into the aspect vector extraction module for feature extraction to obtain an aspect feature vector, and input the aspect feature vector into the emotion vector extraction module for feature extraction to obtain an emotion feature vector;
[0183] A feature interaction module 95 is configured to input the aspect feature vector and the emotion feature vector into the feature interaction module for feature interaction, thereby obtaining an interaction aspect feature vector and an interaction emotion feature vector;
[0184] The sentiment analysis module 96 is used to input the graph feature vector, the interaction aspect feature vector and the interaction sentiment feature vector into the sentiment recognition module for analysis to obtain the sentiment recognition result of the sentence to be recognized.
[0185] In an embodiment of the present application, a data acquisition module is used to obtain text data of a target domain, sentences to be recognized, and a preset emotion recognition model, wherein the text data of the target domain includes several target domain sentences, and the emotion recognition model includes a graph convolutional coding module, a word coding module, an aspect vector extraction module, an emotion vector extraction module, a feature interaction module, and an emotion recognition module; a first feature extraction module is used to construct a domain subgraph corresponding to the sentence to be recognized based on several target domain sentences and sentences to be recognized in the text data of the target domain, and the domain subgraph is input into the graph convolutional coding module to obtain a graph feature vector, wherein the domain subgraph is used to indicate the domain knowledge relationship between the sentence to be recognized and the target domain; a second feature extraction module is used to construct a domain subgraph corresponding to the sentence to be recognized based on the domain subgraph. For external knowledge-enhanced sentences, the sentence to be recognized and the external knowledge-enhanced sentence are input into the word encoding module to obtain a word embedding feature vector; the word embedding feature vector is input into the aspect vector extraction module through a third feature extraction module for feature extraction to obtain an aspect feature vector; the aspect feature vector is input into the emotion vector extraction module for feature extraction to obtain an emotion feature vector; the aspect feature vector and the emotion feature vector are input into the feature interaction module through a feature interaction module for feature interaction to obtain an interactive aspect feature vector and an interactive emotion feature vector; the graph feature vector, the interactive aspect feature vector, and the interactive emotion feature vector are input into the emotion recognition module through a sentiment analysis module for analysis to obtain an emotion recognition result for the sentence to be recognized. Based on the text data of the target domain, a domain subgraph associated with the sentence to be recognized is constructed to construct the external knowledge-enhanced sentence corresponding to the sentence to be recognized and the graph feature information incorporating external knowledge. Feature information is extracted from the sentence to be recognized and the external knowledge-enhanced sentence to obtain aspect feature information and emotion feature information. The graph feature information, aspect feature information, and emotion feature information are combined to achieve aspect-level emotion classification of the sentence to be recognized, thereby improving the accuracy of emotion recognition of the sentence to be recognized.
[0186] Please refer to Figure 10 , Figure 10 The computer device 100 is a schematic diagram of a computer device according to an embodiment of the present invention. The computer device 100 includes a processor 101, a memory 102, and a computer program 103 stored in the memory 102 and executable on the processor 101. The computer device may store multiple instructions, which are suitable for being loaded and executed by the processor 101. Figures 1 to 8 The specific execution process can be found in the method steps shown in Figures 1 to 8 The specific description shown will not be repeated here.
[0187] The processor 101 may include one or more processing cores. The processor 101 utilizes various interfaces and lines to connect to various components within the server. By running or executing instructions, programs, code sets, or instruction sets stored in the memory 102, and by accessing data within the memory 102, the processor 101 performs various functions and processes data of the emotion recognition device 9. Optionally, the processor 101 may be implemented in the form of at least one of a digital signal processing (DSP), a field-programmable gate array (FPGA), and a programmable logic array (PLA). The processor 101 may integrate one or a combination of a central processing unit (CPU), a graphics processing unit (GPU), and a modem. The CPU primarily processes the operating system, user interface, and application programs; the GPU is responsible for rendering and drawing the content required to be displayed on the touch screen; and the modem handles wireless communications. It is understood that the modem may not be integrated into the processor 101 and may be implemented as a separate chip.
[0188] Among them, the memory 102 may include a random access memory 102 (Random Access Memory, RAM), and may also include a read-only memory 102 (Read-Only Memory). Optionally, the memory 102 includes a non-transitory computer-readable storage medium. The memory 102 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 102 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch instructions, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 102 may also optionally be at least one storage device located away from the aforementioned processor 101.
[0189] The embodiment of the present application also provides a storage medium, which can store multiple instructions, which are suitable for the processor to load and execute the above Figures 1 to 8 The specific execution process can be found in the method steps shown in Figures 1 to 8 The specific description shown will not be repeated here.
[0190] Those skilled in the art can clearly understand that, for the convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated into one processing unit, or each unit can exist physically alone, or two or more units can be integrated into one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, and will not be repeated here.
[0191] In the above embodiments, the description of each embodiment has its own focus. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant description of other embodiments.
[0192] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraint algorithm of the technical solution. Professionals and technicians can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the present invention.
[0193] In the embodiments provided by the present invention, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0194] The units described as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected to achieve the purpose of this embodiment according to actual needs.
[0195] In addition, the functional units in the various embodiments of the present invention may be integrated into a single processing unit, each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0196] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the process in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, it can implement the steps of the above-mentioned various method embodiments. The computer program includes computer program code, which can be in source code form, object code form, executable file or some intermediate form.
[0197] The present invention is not limited to the above-mentioned embodiments. If various changes or modifications of the present invention do not depart from the spirit and scope of the present invention, and if these changes and modifications fall within the scope of the claims of the present invention and equivalent technologies, the present invention is also intended to include these changes and modifications.
Claims
1. A method for emotion recognition, characterized in that: The following steps are involved: Obtaining target domain text data, sentences to be recognized, and a preset emotion recognition model, wherein the target domain text data includes a plurality of target domain sentences, and the emotion recognition model includes a graph convolutional encoding module, a word encoding module, an aspect vector extraction module, a emotion vector extraction module, a feature interaction module, and an emotion recognition module; Based on a plurality of target domain sentences and sentences to be recognized in the text data of the target domain, construct a domain subgraph corresponding to the sentences to be recognized, and input the domain subgraph into the graph convolutional coding module to obtain a graph feature vector, wherein the domain subgraph is used to indicate the domain knowledge relationship between the sentences to be recognized and the target domain; According to the domain subgraph, construct an external knowledge enhanced sentence corresponding to the sentence to be recognized, input the sentence to be recognized and the external knowledge enhanced sentence into the word encoding module to obtain a word embedding feature vector; Inputting the word embedding feature vector into the aspect vector extraction module for feature extraction to obtain an aspect feature vector, and inputting the aspect feature vector into the emotion vector extraction module for feature extraction to obtain an emotion feature vector; The aspect feature vector and the emotion feature vector are input into the feature interaction module, and an interaction aspect feature vector is obtained according to the aspect feature vector, the emotion feature vector and a preset first feature interaction algorithm, wherein the first feature interaction algorithm is: I a =β·s+(1-β)·a′ Where, I a is the interaction aspect feature vector, β is, s is the emotion feature vector, and a′ is the aspect feature vector; An interactive emotional feature vector is obtained according to the aspect feature vector, the emotional feature vector, and a preset second feature interaction algorithm, wherein the second feature interaction algorithm is: I s =β·a′+(1-β)·s Where, I s is the interactive emotion feature vector; The graph feature vector, the interaction aspect feature vector and the interaction emotion feature vector are input into the emotion recognition module for analysis to obtain the emotion recognition result of the sentence to be recognized.
2. The emotion recognition method according to claim 1, characterized in that: The domain subgraph includes a plurality of word nodes and a plurality of relationship nodes between the word nodes, the graph convolutional encoding module includes a graph convolutional network, and the graph convolutional network includes a plurality of graph convolutional layers; The step of inputting the domain subgraph into the graph convolutional coding module to obtain the graph feature vector of the sentence to be recognized comprises the following steps: The domain subgraph is input into the graph convolution network. According to the word nodes in the domain subgraph and the preset graph convolution algorithm, the graph convolution vectors of the word nodes output by the last graph convolution layer of the graph convolution encoding module are obtained. The graph convolution algorithm is: Where u and j are word indices, is the graph convolution vector of the uth word node output by the lth graph convolution layer of the graph convolution network, R is a set of relationship nodes, including relationship nodes between several of the word nodes, r is a relationship node, is the set of adjacent word nodes of the u-th word node under the r relationship node, are respectively the second weight parameter and the first weight parameter of the lth graph convolution layer of the graph convolution network, is the graph convolution vector of the j-th word node output by the l-1-th graph convolution layer of the graph convolution network, is the graph convolution vector of the u-th word node output by the l-1-th graph convolution layer of the graph convolutional network, and σ(·) is the activation function; The graph feature vector is obtained according to the graph convolution vectors of the plurality of word nodes output by the last graph convolution layer of the graph convolution network and a preset graph feature vector calculation algorithm, wherein the graph feature vector calculation algorithm is: Where G is the graph feature vector, U is the number of word nodes, g′ u It is the graph convolution vector of the u-th word node output by the last graph convolution layer of the graph convolution encoding module.
3. The emotion recognition method according to claim 1 or 2, characterized in that: The target domain sentence and the sentence to be recognized both include a number of words; The step of inputting the sentence to be recognized and the external knowledge enhanced sentence into the word encoding module to obtain a word embedding feature vector comprises the following steps: According to the sentence to be recognized, the external knowledge enhanced sentence and the preset word embedding coding algorithm, a word embedding sequence of the sentence to be recognized and the external knowledge enhanced sentence is obtained, wherein the word embedding sequence includes word embedding vectors of several words, and the word embedding coding algorithm is: E={e1,e2,...,e n }=BERT({x1,x2,...,x n }) Where E is the word embedding sequence of the sentence to be recognized, e n is the word embedding vector of the nth word in the word embedding sequence of the sentence to be recognized, x n is the word vector of the nth word in the sentence to be recognized, E c Enhance the word embedding sequence of the sentence for the external knowledge, The word embedding vector of the word in the word embedding sequence of the external knowledge enhanced sentence, c m The word vector of the mth word in the sentence is enhanced with external knowledge, and BERT(·) is the word embedding encoding function; Obtain the number of occurrences of several words in the external knowledge augmented sentence, obtain association score data of the external knowledge augmented sentence based on the number of occurrences of several words in the external knowledge augmented sentence and a preset association score calculation algorithm, and calculate the association score data of the external knowledge augmented sentence based on the association score data and a word embedding sequence, wherein the association score data of the external knowledge augmented sentence includes association score vectors of several words, the word embedding sequence includes aggregated word embedding vectors of several words, and the association score calculation algorithm is: Where sc i The associated score vector of the i-th word in the sentence is enhanced with the external knowledge, The number of occurrences of the i-th word in the sentence is enhanced for the external knowledge; According to the word embedding sequence of the sentence to be recognized, the word embedding sequence of the external knowledge enhanced sentence, and a preset context encoding algorithm, a context representation sequence of the sentence to be recognized and the external knowledge enhanced sentence is obtained, wherein the context feature sequence includes context vectors of several words, and the context encoding algorithm is: Where, is the context representation sequence of the sentence to be recognized, is the context vector of the nth word in the context representation sequence of the sentence to be recognized, enhancing the context representation sequence of the sentence for the external knowledge, The context vector of the word in the sequence of the context representation of the sentence enhanced by the external knowledge, is the aggregate word embedding vector of the word in the word embedding sequence of the external knowledge enhanced sentence, and PLM(·) is the context encoding function; The word embedding feature vector is obtained according to the context vector corresponding to the same word index in the context representation sequence of the sentence to be recognized and the external knowledge enhanced sentence and a preset word embedding feature extraction algorithm, wherein the word embedding feature extraction algorithm is: Where Z is the word embedding feature vector, W z is the weight parameter of the word encoding module, σ(·) is the activation function, is the concatenation symbol, and ⊙ is the element-wise multiplication symbol.
4. The emotion recognition method according to claim 1 or 3, characterized in that: The aspect vector extraction module includes a stacked convolutional network, which includes several stacked convolutional layers; the sentiment vector extraction module includes a multi-head self-attention network; The step of inputting the word embedding feature vector into the aspect vector extraction module for feature extraction to obtain an aspect feature vector, and inputting the aspect feature vector into the emotion vector extraction module for feature extraction to obtain an emotion feature vector comprises the following steps: The word embedding feature vector is used as the first layer input of the stacked convolutional network, and the stacked convolution vector output by the last stacked convolution layer of the stacked convolutional network is obtained as the aspect feature vector according to a preset stacked convolution algorithm, wherein the stacked convolution algorithm is: a l =σ(a l-1 *k l-1 +b l-1 ) Where a l is the stacked convolution vector output by the lth stacked convolution layer of the stacked convolution network, a l-1 is the stacked convolution vector output by the l-1th stacked convolution layer of the stacked convolution network, k l-1 is the convolution kernel group of the l-1th stacked convolution layer of the stacked convolution network, b l-1 is the bias parameter of the l-1th stacked convolutional layer of the stacked convolutional network, and σ(·) is the activation function; According to the aspect eigenvector and a preset matrix construction algorithm, a first matrix, a second matrix and a third matrix are obtained, wherein the matrix construction algorithm is: Q=a′W Q K=a′W K V=a′W V Where a′ is the aspect eigenvector, Q is the first matrix, and W Q is the first weight parameter of the emotion vector extraction module, V is the second matrix, W K is the second weight parameter of the emotion vector extraction module, V is the third matrix, W V is the third weight parameter of the emotion vector extraction module; The first matrix, the second matrix, and the third matrix are input into the multi-head self-attention network. According to a preset multi-head self-attention extraction algorithm, attention feature vectors output by several self-attention heads are obtained. The attention feature vectors output by the several self-attention heads are spliced to obtain the emotion feature vector. The multi-head self-attention extraction algorithm is: In the formula, o j is the attention feature vector output by the j-th self-attention head, softmax(·) is the normalization function, T is the transpose symbol, and d is the dimension parameter.
5. The emotion recognition method according to claim 1, characterized in that The step of inputting the graph feature vector, the interaction aspect feature vector, and the interaction emotion feature vector into the emotion recognition module for analysis to obtain the emotion recognition result of the sentence to be recognized comprises the following steps: Performing linear processing on the graph feature vector to obtain a linearly processed graph feature vector, and respectively splicing the interaction aspect feature vector and the interaction emotion feature vector with the linearly processed graph feature vector to obtain a spliced aspect feature vector and a spliced emotion feature vector; According to the spliced aspect feature vector and a preset prediction aspect probability distribution vector calculation algorithm, a prediction aspect probability distribution vector is obtained; according to the spliced emotion feature vector and a preset prediction emotion probability distribution vector calculation algorithm, a prediction emotion probability distribution vector is obtained, wherein the prediction aspect probability distribution vector calculation algorithm is: Where, is the probability distribution vector of the prediction aspect, W a is the weight parameter of the aspect prediction module, A is the concatenated aspect feature vector, and softmax(·) is the normalization function; The algorithm for calculating the predicted emotion probability distribution vector is: Where, To predict the emotion probability distribution vector, W s is the weight parameter of the emotion prediction module, and S is the concatenated emotion feature vector; According to the predicted aspect probability distribution vector, the aspect prediction type corresponding to the dimension with the largest probability is obtained; according to the predicted emotion probability distribution vector, the emotion prediction type corresponding to the dimension with the largest probability is obtained; according to the aspect prediction type and the emotion prediction type, the emotion recognition result of the sentence to be recognized is obtained.
6. The emotion recognition method according to claim 2, characterized in that The method further includes the steps of: training the emotion recognition model; The training of the emotion recognition model comprises the steps of: Obtaining a training text dataset, constructing a domain subgraph corresponding to the training text dataset based on the training text dataset, and obtaining external knowledge-enhanced word sentences corresponding to a plurality of sentences in text data of a source domain based on the domain subgraph, wherein the training text dataset includes text data of the source domain and text data of a target domain, the text data includes a plurality of sentences, and the sentences include a plurality of words; Combining a plurality of sentences in the text data of the source domain and corresponding external knowledge-enhanced word sentences to construct a plurality of training sentence groups, inputting the plurality of training sentence groups into the emotion recognition model, and obtaining splicing aspect feature vectors, splicing emotion feature vectors, predicted aspect probability distribution vectors, and predicted emotion probability distribution vectors corresponding to the plurality of training sentence groups; Performing maximum pooling processing on the spliced aspect feature vectors and the spliced emotion feature vectors respectively to obtain pooled aspect feature vectors and pooled emotion feature vectors corresponding to the plurality of training sentence groups; obtaining prediction domain label data corresponding to the plurality of training sentence groups based on the pooled aspect feature vectors, pooled emotion feature vectors, and a preset prediction domain algorithm, wherein the preset prediction domain algorithm is: Where, To predict the domain label data, W d is a preset learnable parameter, M a is the pooled aspect feature vector, M s To concatenate sentiment feature vectors, GRL λ (·) is the gradient reversal function, λ is the scale factor, MLP(·) is the multi-layer perceptron function, and softmax(·) is the normalization function; Obtaining real domain label data corresponding to the plurality of training sentence groups, and obtaining a first loss value based on the real domain label data corresponding to the plurality of training sentence groups, the predicted domain label data, and a preset first loss function, wherein the first loss function is: Where, is the first loss value, y d is the real domain label data, To predict domain label data; Obtain a true aspect probability distribution vector and a true emotion probability distribution vector corresponding to the plurality of training sentence groups; obtain a second loss value based on the true aspect probability distribution vector, the true emotion probability distribution vector, the predicted aspect probability distribution vector, the predicted emotion probability distribution vector, and a preset second loss function corresponding to the plurality of training sentence groups; and train the emotion recognition module based on the first loss value and the second loss value, wherein the second loss function is: Where, is the second loss value, y a is the true aspect probability distribution vector, is the probability distribution vector of the prediction aspect, To predict the probability distribution vector of emotion, y s is the true emotion probability distribution vector.
7. The emotion recognition method according to claim 6, characterized in that The training of the emotion recognition model further includes the steps of: Constructing a positive triple set according to a plurality of word nodes and a plurality of relationship nodes between the word nodes in a domain subgraph corresponding to the training text data set, wherein the positive triple set includes a plurality of positive triples, and the positive triples include two word nodes and a relationship node between the two word nodes; According to several positive triplets in the positive triplet set, several negative triplets corresponding to the positive triplets are constructed to construct a negative triplet set. According to the positive triplet set, the negative triplet set and a preset third loss function, a third loss value is obtained. According to the third loss value, the graph convolutional coding module is trained, wherein the first loss function is: Where, is the third loss value, s(v u ,r u,j ,v j ) is a positive triplet, v u is the u-th word node, v j is the jth word node, r i,j is the relationship node between the u-th word node and the j-th word node, is the graph convolution vector of the u-th word node, T is the transpose symbol, R r is the diagonal matrix corresponding to the relationship node set, g j is the graph convolution vector of the j-th word node, is a training triplet set constructed by combining the positive triplet set and the negative triplet set, y is a triplet label representation, y∈{0,1}, y=0 indicates that the triplet is a negative triplet, and y=1 indicates that the triplet is a positive triplet.
8. An emotion recognition device, characterized in that: include: A data acquisition module, configured to obtain text data of a target domain, sentences to be recognized, and a preset emotion recognition model, wherein the text data of the target domain includes a plurality of target domain sentences, and the emotion recognition model includes a graph convolutional encoding module, a word encoding module, an aspect vector extraction module, an emotion vector extraction module, a feature interaction module, and an emotion recognition module; a first feature extraction module, configured to construct a domain subgraph corresponding to a plurality of target domain sentences and a sentence to be identified in the text data of the target domain, and input the domain subgraph into the graph convolutional coding module to obtain a graph feature vector, wherein the domain subgraph is used to indicate the domain knowledge relationship between the sentence to be identified and the target domain; A second feature extraction module is configured to construct an external knowledge-enhanced sentence corresponding to the sentence to be recognized based on the domain subgraph, and input the sentence to be recognized and the external knowledge-enhanced sentence into the word encoding module to obtain a word embedding feature vector; a third feature extraction module, configured to input the word embedding feature vector into the aspect vector extraction module for feature extraction to obtain an aspect feature vector, and input the aspect feature vector into the emotion vector extraction module for feature extraction to obtain an emotion feature vector; A feature interaction module is configured to input the aspect feature vector and the emotion feature vector into the feature interaction module for feature interaction, and obtain an interaction aspect feature vector based on the aspect feature vector, the emotion feature vector, and a preset first feature interaction algorithm, wherein the first feature interaction algorithm is: I a =β·s+(1-β)·a′ Where, I a is the interaction aspect feature vector, β is, s is the emotion feature vector, and a′ is the aspect feature vector; An interactive emotional feature vector is obtained according to the aspect feature vector, the emotional feature vector, and a preset second feature interaction algorithm, wherein the second feature interaction algorithm is: I s =β·a′+(1-β)·s Where, I s is the interactive emotion feature vector; The sentiment analysis module is used to input the graph feature vector, the interaction aspect feature vector and the interaction sentiment feature vector into the sentiment recognition module for analysis to obtain the sentiment recognition result of the sentence to be recognized.
9. A computer device, characterized in that: include: A processor, a memory, and a computer program stored in the memory and executable on the processor; when the computer program is executed by the processor, the steps of the emotion recognition method according to any one of claims 1 to 7 are implemented.
Citation Information
Patent Citations
Aspect-level sentiment classification method based on knowledge enhancement syntactic heterogeneous graph
CN115269847A
Graph feature processing method and device
WO2021169454A1