Multi-label emotion sequence generation method and system based on emotion transfer
Through character-level and clause-level modeling based on BERT and graph convolution networks, combined with self-attention mechanism and LSTM network, the problem of unused emotional relationships in social comment texts is solved, and more accurate emotion detection is achieved.
Patent Information
- Application Number
- CN202310165471.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-02-22
- Publication Date
- 2025-08-08
- Estimated Expiration
- 2043-02-22
AI Technical Summary
The prior art fails to make full use of the emotional relationship between consecutive clauses in social comment texts, resulting in inaccurate emotion detection.
A multi-label emotion sequence generation method based on emotion transfer is adopted, character vectors are obtained through the BERT word segmenter, clause vectors are extracted by graph convolutional network, and relationships between clauses are modeled using the self-attention mechanism, and discrete distribution of emotion labels is predicted in combination with the LSTM network.
It effectively handles the emotional relationship between continuous clauses, improves the accuracy of emotion detection, and is suitable for enterprise-level, product-level and technical-level emotion detection.
Smart Images

Figure CN116450818B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of multi-label emotion sequence generation, and in particular to a multi-label emotion sequence generation method, system, storage medium and electronic device based on emotion transfer. Background Art
[0002] Emotion detection, also known as sentiment analysis or sentiment classification, is a branch of sentiment analysis research. It aims to identify and analyze the emotions underlying large amounts of human behavior, including text, images, audio, and video data. These emotions include happiness, anger, likes, dislikes, and anticipation. With the rapid development of social media, more and more users are posting online reviews about various products on forums, blogs, and shopping websites. These reviews take on a wide variety of forms, including inquiries, daily diaries, experience sharing, product evaluations, and quality feedback. These online reviews not only contain rich perspectives on products but also describe the emotional changes users experience throughout the product selection, purchase, and usage process. These emotions reflect the changing psychological processes of users, mediated by their individual desires and needs, and are the outward manifestation of their potential needs. Therefore, detecting user emotions is crucial for companies to understand product demand.
[0003] In recent years, sentiment detection models for social comment text have received increasing attention, and a large number of sentiment detection studies have been proposed. These studies mainly use statistical machine learning methods or deep learning methods to predict the emotions expressed in social comment text, such as logistic regression, support vector machines, long short-term memory networks, and attention mechanisms.
[0004] However, previous research often operates at the comment level, either identifying the primary sentiment label of a comment or employing a multi-label learning paradigm to identify multiple sentiment labels for a comment. In reality, each clause in a comment may express different sentiments, and the sentiments expressed by consecutive clauses are inherently correlated. While some studies have attempted to analyze the sentiment expressed in comments at the clause level, these efforts are merely extensions of comment-level work and fail to fully exploit the relationships between the sentiments expressed by consecutive clauses. Summary of the Invention
[0005] (1) Technical problems solved
[0006] In response to the deficiencies of the prior art, the present invention provides a method, system, storage medium and electronic device for generating a multi-label emotion sequence based on emotion transfer, which solves the technical problem of insufficient utilization of the relationship between emotions expressed by consecutive clauses.
[0007] (2) Technical solution
[0008] To achieve the above objectives, the present invention is implemented through the following technical solutions:
[0009] A multi-label emotion sequence generation method based on emotion transfer, comprising:
[0010] S1. Obtain a social comment text to be processed, where the social comment text includes a plurality of consecutive clauses;
[0011] S2. Perform text joint encoding on the consecutive clauses to obtain a character vector for each clause;
[0012] S3. Use the first character vector of each word as its word vector and the adjacency matrix of each clause; use the word vector and adjacency matrix as input to the graph convolutional network to obtain the corresponding clause vector;
[0013] S4. Obtaining a relationship vector between the consecutive clauses based on the clause vector;
[0014] S5. Obtain a discrete distribution of sentiment labels for each clause based on the relationship vector.
[0015] Preferably, the BERT word segmenter is used in S2 to obtain the character vector of each clause, as shown below:
[0016]
[0017] The given review text contains K clauses R = {c1, c2, ..., c K}, clause c i Divided into w i,j Indicates the jth character of the i-th clause, l i is the length of the i-th clause; X i Indicates clause c i A collection of character vectors, Represents the character w i,j The embedding vector of , d represents the character vector dimension.
[0018] Preferably, obtaining the corresponding clause vector in S3 includes:
[0019] For a given clause containing m words, its adjacency matrix is represented as A∈R m×m , a graph convolutional network with L layers is used, and the graph convolution operation of each layer on the node is expressed as:
[0020]
[0021] Among them, σ represents the activation function, W l and b l Represent the weight and bias of the l-th layer graph convolution operation, A ijIndicates the dependency between the i-th word and the j-th word in the current clause, represents the hidden state of the i-th word after l graph convolution operations, is the initial state, represented by the first character vector of the i-th word, represents the final hidden state of the i-th word;
[0022] The hidden state generated by each layer of graph convolution operation is concatenated with the original word vector to form the word vector h for each word. i ∈R d×L ;
[0023]
[0024] According to the word vector, the initial vector representation h∈R of each clause is obtained based on the maximum pooling d×L ;
[0025] h=MaxPooling(h1,h2,…,h m )
[0026] A linear layer is used to perform dimensionality reduction on the initial vector representation of the clause to obtain the corresponding clause vector;
[0027] x c =W c h+b c
[0028] Among them, W c and b c denote the weights and biases of the linear layer respectively.
[0029] Preferably, the self-attention mechanism is used in S4 to obtain the relationship vector between the consecutive clauses, including:
[0030] For each clause vector Use the self-attention network to calculate the attention weights with all clause vectors;
[0031]
[0032] Among them, W v and b v denote weight and bias respectively, express and The vertical connection vector, α ij represents the attention weight of the i-th clause vector to the j-th clause vector;
[0033] Weighting each clause vector according to the attention weight to obtain a relationship vector between the consecutive clauses;
[0034]
[0035] Where K represents the number of clauses; Representation clause vector The relation vector between all clause vectors.
[0036] Preferably, a single-layer LSTM network is used in S5 to obtain the discrete distribution of the emotion label of each clause, including:
[0037] Initialize each preset emotion label as a learnable embedding vector M∈R N×d , where N is the number of emotion labels;
[0038] For the i-th clause, the sentiment label vector predicted by the previous clause is weighted,
[0039] v i-1 =y i-1 ·M
[0040] where · represents matrix multiplication, y i-1 ∈R 1×N represents the discrete distribution of the sentiment label of the i-1th clause, v i-1 is the weighted emotion vector representation;
[0041] Based on the LSTM network, predict the hidden state s of the i-th clause i :
[0042] s i =LSTM(v i-1 , e i |s i-1 )
[0043] Among them, e i represents the clause encoding vector calculated by the attention mechanism; s i-1 represents the hidden state of the i-1th clause;
[0044] A linear layer is used to transform the hidden state s i The relation vector with the clause is projected onto the pre-built emotion label character table V for joint decoding, and the probability distribution of each emotion is independently calculated through the sigmoid function
[0045]
[0046] Among them, W u ∈R N×d , b u ∈R N Represent the weight matrix and bias of the linear layer respectively; y i ∈R1×N represents the discrete distribution of the sentiment label of the i-th clause.
[0047] A multi-label emotion sequence generation system based on emotion transfer, comprising:
[0048] A data acquisition module, configured to acquire a social comment text to be processed, wherein the social comment text includes a plurality of consecutive clauses;
[0049] A character encoding module, configured to perform text joint encoding on the consecutive clauses to obtain a character vector for each clause;
[0050] A graph convolution module is used to take the first character vector of each word as its word vector and the pre-built adjacency matrix of each clause; the word vector and adjacency matrix are used as input to the graph convolution network to obtain the corresponding clause vector;
[0051] A relation encoding module, configured to obtain a relation vector between the consecutive clauses based on the clause vectors;
[0052] The sequence generation module is used to obtain the discrete distribution of the emotion label of each clause according to the relationship vector.
[0053] A storage medium stores a computer program for generating a multi-label emotion sequence based on emotion transfer, wherein the computer program enables a computer to execute the multi-label emotion sequence generation method as described above.
[0054] An electronic device, comprising:
[0055] One or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, the programs including instructions for executing the multi-label emotion sequence generation method as described above.
[0056] (3) Beneficial effects
[0057] The present invention provides a method, system, storage medium, and electronic device for generating a multi-label emotion sequence based on emotion transfer. Compared with the existing technology, it has the following advantages:
[0058] The core concept of this paper is to formulate the multi-label sentiment classification task of consecutive clauses as a continuous sentiment generation problem. By using a Transformer-based bidirectional encoding representation and a self-attention mechanism, implicit sentiment transfer relationships are modeled at both the character and clause levels. A generative network is then used to model explicit sentiment transfer relationships, sequentially predicting the discrete distribution of sentiment for each clause. This method effectively addresses the relationships between the emotions expressed by consecutive clauses and can be used for sentiment detection at the enterprise, product, and technology levels in specific domains. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.
[0060] Figure 1 A schematic diagram of a multi-label emotion sequence generation model based on emotion transfer provided by an embodiment of the present invention;
[0061] Figure 2 A block diagram of a method for generating a multi-label emotion sequence based on emotion transfer provided by an embodiment of the present invention;
[0062] Figure 3 An example diagram of the construction process of an adjacency matrix provided in an embodiment of the present invention;
[0063] Figure 4 A schematic diagram of a detailed process of generating an emotion sequence provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0064] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions in the embodiments of the present invention are clearly and completely described. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without inventive effort are within the scope of protection of the present invention.
[0065] The embodiments of the present application solve the technical problem of not fully utilizing the relationship between emotions expressed by consecutive clauses by providing a method, system, storage medium and electronic device for generating a multi-label emotion sequence based on emotion transfer.
[0066] The technical solution in the embodiments of the present application is to solve the above technical problems, and the overall idea is as follows:
[0067] like Figure 1 As shown, the embodiment of the present invention is based on a multi-label emotion sequence generation model (MESGM) based on emotion transfer, including a text joint encoding layer, a clause feature extraction layer, a clause relationship encoding layer and an emotion label transfer layer. Specifically:
[0068] First, at the text joint encoding layer, text joint encoding is performed on the consecutive clauses to obtain the character vector of each clause;
[0069] Secondly, in the clause feature extraction layer, the first character vector of each word is used as its word vector, and the adjacency matrix of each clause is used as the input of the graph convolutional network to obtain the corresponding clause vector;
[0070] Again, at the clause relation encoding layer, a relation vector between the consecutive clauses is obtained according to the clause vector;
[0071] Finally, in the emotion label transfer layer, the discrete distribution of the emotion label of each clause is obtained according to the relationship vector.
[0072] In order to better understand the above technical solution, the above technical solution will be described in detail below with reference to the accompanying drawings and specific implementation methods.
[0073] Example:
[0074] like Figure 2 As shown, an embodiment of the present invention provides a method for generating a multi-label emotion sequence based on emotion transfer, comprising:
[0075] S1. Obtain a social comment text to be processed, where the social comment text includes a plurality of consecutive clauses;
[0076] S2. Perform text joint encoding on the consecutive clauses to obtain a character vector for each clause;
[0077] S3. Use the first character vector of each word as its word vector and the adjacency matrix of each clause; use the word vector and adjacency matrix as input to the graph convolutional network to obtain the corresponding clause vector;
[0078] S4. Obtaining a relationship vector between the consecutive clauses based on the clause vector;
[0079] S5. Obtain a discrete distribution of sentiment labels for each clause based on the relationship vector.
[0080] The core idea of the embodiment of the present invention is to express the multi-label emotion classification task of continuous clauses as a continuous emotion generation problem; it effectively handles the relationship between the emotions expressed by continuous clauses, and can be used for emotion detection at the enterprise level, product level, and technology level for specific fields.
[0081] The following sections describe the various steps of the above solution in detail:
[0082] In step S1 , a social comment text to be processed is obtained, where the social comment text includes several consecutive clauses.
[0083] In step S2, text joint encoding is performed on the consecutive clauses to obtain a character vector of each clause.
[0084] The purpose of this step is to encode the implicit transfer relationship of emotions at the character level and generate an embedding vector for each character. In order to improve the representation ability of the encoded vector, the embodiment of the present invention uses the most popular pre-trained language model BERT to encode the character vector. Previous methods generally input each clause independently into the BERT model for processing. However, adjacent clauses have an implicit transfer relationship of emotions in semantics, so the complete text needs to be input into the BERT model to encode the implicit transfer relationship of emotions at the character level. After generating the embedding vector for each character through BERT, the vectors of the characters contained in each clause can be further extracted.
[0085] Specifically, we first use the BERT tokenizer to segment the input text and distinguish clauses by the token "[SEP]"; then we input the token segmentation result into the BERT model for bidirectional encoding to obtain the embedding vector of each character; finally, we extract the character vector of each clause based on the token "[SEP]". Assume that the given review text contains K clauses R = {c1, c2, ..., c K}, each clause c i will be split into The character vector of each clause encoded by BERT can be represented as:
[0086]
[0087] Among them, w i,j Indicates the jth character of the i-th clause, l i is the length of the i-th clause; X i Indicates clause c i A collection of character vectors, Represents the character w i,j The embedding vector of , d represents the character vector dimension.
[0088] In step S3, the first character vector of each word is used as its word vector, and the adjacency matrix of each clause is used as the input of the graph convolutional network to obtain the corresponding clause vector.
[0089] In this step, a graph convolutional network (GCNN) is used to extract the grammatical features of each clause and generate a vector representation of each clause through max pooling. A GCNN can be viewed as an extension of a convolutional neural network to the graph domain, performing convolution on each node within its local graph neighborhood.
[0090] In the field of text information extraction, each sentence can be represented as a graph G = (V, E), where V is the node set consisting of all words in the sentence, and E is the edge set of all dependencies between words. Under these conditions, compared to convolutional neural networks, which can only extract semantic information of consecutive words, graph convolutional networks can extract semantic information of sentences while fully understanding grammar, thereby greatly improving information extraction capabilities. Therefore, graph convolutional networks are chosen to extract semantic information of sentences.
[0091] Before using graph convolutional networks to extract semantic information from clauses, we first need to construct an adjacency matrix for each clause based on the dependencies between words. Word dependencies can be expressed in various forms, such as subject-verb relationships, verb-object relationships, and core relationships, and can be directly obtained using existing natural language processing tools. All relationships are considered bidirectional.
[0092] In addition, the embodiment of the present invention adds closed-loop edges to the edge set, that is, the nodes also have dependencies with themselves, which can improve the representation ability of the graph convolutional network. When constructing the adjacency matrix, this patent uses the number "0" to indicate that there is no relationship between nodes, and all other relationships are set to the number "1". For example, for the sentence "This car has a beautiful appearance", its adjacency matrix construction process is as follows Figure 3 shown.
[0093] Because the adjacency matrix represents the relationship between words, the character vectors obtained in the previous step cannot be used directly. In this step, the character vector of the first character of each word is used as the word vector representation of this word, and it is input into the graph convolutional network along with the adjacency matrix of each clause.
[0094] Specifically, obtaining the corresponding clause vector in S3 includes:
[0095] For a given clause containing m words, its adjacency matrix is represented as A∈R m×m , a graph convolutional network with L layers is used, and the graph convolution operation of each layer on the node is expressed as:
[0096]
[0097] Among them, σ represents the activation function, W l and b l Represent the weight and bias of the l-th layer graph convolution operation, A ij Indicates the dependency between the i-th word and the j-th word in the current clause, represents the hidden state of the i-th word after l graph convolution operations, is the initial state, represented by the first character vector of the i-th word, represents the final hidden state of the i-th word;
[0098] First, the hidden state generated by each layer of graph convolution operation is concatenated with the original word vector to form the word vector h for each word. i ∈R d×L ;
[0099]
[0100] Then, according to the word vector, the initial vector representation h∈R of each clause is obtained based on the maximum pooling d×L ;
[0101] h=MaxPooling(h1,h2,…,h m )
[0102] Finally, a linear layer is used to reduce the dimension of the initial vector representation of the clause to obtain the corresponding clause vector;
[0103] x c =W c h+b c
[0104] Among them, W c and b c denote the weights and biases of the linear layer respectively.
[0105] According to the above results, the social comment text consisting of K clauses can be represented as
[0106] In step S4, a relationship vector between the consecutive clauses is obtained based on the clause vector.
[0107] The purpose of this step is to encode the implicit transfer relationship of emotions at the clause level. This is essentially modeling the relationship between consecutive clauses, which is a kind of sequence modeling. At present, the attention mechanism has obvious advantages in sequence modeling. Therefore, the embodiment of the present invention adopts the attention mechanism to model the relationship between clauses and generate the hidden state of each clause. The attention mechanism is a neural network that attempts to imitate the human brain / vision to process data. It mainly attracts the attention of the attention unit by assigning different weights to different information. Compared with the traditional recurrent neural network, it does not rely on the order between the input sequences, thereby preventing the loss of information in sequential modeling, and can also perform parallel computing well, greatly improving the computing efficiency.
[0108] In this step, since the attention unit and attention information are both clause vectors obtained from the previous step, this is a special case of the attention mechanism - self-attention.
[0109] Specifically, the S4 includes:
[0110] First, for each clause vector Use the self-attention network to calculate the attention weights with all clause vectors;
[0111]
[0112] Among them, W v and b v denote weight and bias respectively, express and The vertical connection vector, α ij represents the attention weight of the i-th clause vector to the j-th clause vector;
[0113] Then, each clause vector is weighted according to the attention weight to obtain a relationship vector between the consecutive clauses;
[0114]
[0115] Where K represents the number of clauses; Representation clause vector The relation vector between all clause vectors.
[0116] According to the above results, the encoder based on the attention mechanism converts K clause vectors into clause relation vector representations of K consecutive clauses:
[0117] In step S5, the discrete distribution of the emotion labels of each clause is obtained according to the relationship vector.
[0118] The purpose of this step is to model the explicit transfer relationship of emotion labels and predict the emotion expressed by each clause. The explicit transfer of emotion is specifically manifested as the transfer of emotion labels, that is, the emotion label of each clause has a strong correlation with the emotion label of the previous clause. This is similar to the text generation problem, where the emotion label character table is the text vocabulary to be predicted. The difference is that a clause may express multiple emotions. This is a continuous label discrete distribution prediction problem, but it can still be solved using the idea of text generation, that is, the discrete distribution of emotion labels predicted in the previous clause is weighted to predict the discrete distribution of emotion labels in the current clause.
[0119] Based on this idea, the embodiment of the present invention adopts a generative network to model the explicit transfer relationship of emotions, and jointly decodes it with the hidden state of the clause to sequentially predict the discrete distribution of the emotion label of each clause.
[0120] Figure 4 The detailed process of emotion sequence generation is shown, including:
[0121] First, each preset emotion label is initialized as a learnable embedding vector M∈R N×d , where N is the number of emotion labels;
[0122] For the i-th clause, the sentiment label vector predicted by the previous clause is weighted,
[0123] v i-1 =y i-1 ·M
[0124] where · represents matrix multiplication, y i-1 ∈R 1×N represents the discrete distribution of the sentiment label of the i-1th clause, v i-1 is the weighted emotion vector representation;
[0125] Then, based on a single-layer LSTM network, the hidden state s of the i-th clause is predicted i :
[0126] s i =LSTM(v i-1 , e i |s i-1 )
[0127] Among them, e i represents the clause encoding vector calculated by the attention mechanism; s i-1 represents the hidden state of the i-1th clause;
[0128] Finally, a linear layer is used to transform the hidden state s iThe relation vector with the clause is projected onto the pre-built emotion label character table V for joint decoding, and the probability distribution of each emotion is independently calculated through the sigmoid function
[0129]
[0130] Among them, W u ∈R N×d , b u ∈R N Represent the weight matrix and bias of the linear layer respectively; y i ∈R 1×N represents the discrete distribution of the sentiment label of the i-th clause.
[0131] In order to better demonstrate the superiority of the open information extraction method provided by the embodiment of the present invention, the following specific examples are provided:
[0132] Model training: The large-scale Chinese sentiment analysis dataset Ren_CECps was used to develop the model. The dataset captured 1,487 Chinese blogs, containing 11,226 paragraphs and 35,038 clauses. Each paragraph and clause was manually scored on the following eight emotion labels: Joy, Hate, Love, Sorrow, Anxiety, Surprise, Anger, and Expect. The embodiment of the present invention takes clause-level emotions as the research object and converts its scores into discrete values of 0-1. Considering that some clauses do not contain any emotions, the embodiment of the present invention additionally sets an emotion label "Null" to handle this situation. Since the selected Chinese blogs come from a large number of fields, this ensures that the trained MESGM method can be applied to various fields. In this dataset, the emotion labels of each paragraph and the clauses it contains constitute a single (input, output) pair of MESGM.
[0133] To make model training more efficient, this embodiment of the present invention sets three filtering criteria to clean the raw data: paragraph length ≤ 510, number of clauses in a paragraph ≤ 15, and maximum clause length in a paragraph ≤ 180. The cleaned data is then randomly divided into training, validation, and test sets in an 8:1:1 ratio to develop the MESGM proposed in this embodiment of the present invention.
[0134] Taking automobiles as an example, the embodiment of the present invention collected reviews of some popular car models from the Autohome website, deleted spam comments by setting special keywords such as "HTML", "telephone" and "free", and obtained a total of 887 comment data for emotion detection, containing a total of 3138 clauses.
[0135] By using the trained MESGM to detect emotions on the above data, Table 1 shows the number of clauses expressing different numbers of emotions.
[0136] Table 1 Statistics of clauses expressing different numbers of emotions on the car emotion detection dataset
[0137]
[0138] As shown in Table 1, more than one-third of the clauses express two or more emotions, demonstrating the importance of detecting users' compound emotions.
[0139] In addition, the embodiment of the present invention further counts the number of times each emotion occurs, as shown in Table 2.
[0140] Table 2 Statistics of each emotion on the car emotion detection dataset
[0141]
[0142] It can be seen that the most expressed emotion in the car emotion detection dataset is "like" (49.2%), followed by "happy" (12.6%), indicating that users generally have a positive attitude towards these popular models; however, "disgust", "worry" and "anger" still account for a relatively large proportion (31.7%), indicating that each model still has a lot of market room for improvement; in addition, since the data analyzed is popular models, users generally have a better understanding of the models, so the emotions of "surprise" and "expectation" appear less frequently (5.3%).
[0143] Several representative examples of fragmented product information extraction are shown in Tables 3 to 6:
[0144] Table 3 Case 1
[0145]
[0146] Table 4 Case 2
[0147] Clause mood A car with a very high cost performance, good appearance and fuel efficiency, like The power response is a little slow, but the impact is not very big. Concerns I am still very happy after driving for such a long time. Happy
[0148] Table 5 Case 3
[0149] Clause mood Just bought it 2 days ago, overall I feel good. like The control is easy to use. When you step on the accelerator, you can feel the so-called push back feeling. like What's frustrating is that the reversing image doesn't work and the trunk won't close tightly. It seems I have to go to the 4S shop again. Concerns
[0150] Table 6 Case 4
[0151] Clause mood I really regret buying it. It only took a month for the problem to appear. Sad, angry The acceleration is very slow, the noise is very loud, and the steering wheel shakes violently. disgust It's so sad. I have reported it to the manufacturer and have been waiting for two days with no results. I drove it to the 4S shop and burned it. Worry, anger
[0152] An embodiment of the present invention provides a multi-label emotion sequence generation system based on emotion transfer, comprising:
[0153] A data acquisition module, configured to acquire a social comment text to be processed, wherein the social comment text includes a plurality of consecutive clauses;
[0154] A character encoding module, configured to perform text joint encoding on the consecutive clauses to obtain a character vector for each clause;
[0155] A graph convolution module is used to take the first character vector of each word as its word vector and the pre-built adjacency matrix of each clause; the word vector and adjacency matrix are used as input to the graph convolution network to obtain the corresponding clause vector;
[0156] A relation encoding module, configured to obtain a relation vector between the consecutive clauses based on the clause vectors;
[0157] The sequence generation module is used to obtain the discrete distribution of the emotion label of each clause according to the relationship vector.
[0158] An embodiment of the present invention provides a storage medium storing a computer program for generating a multi-label emotion sequence based on emotion transfer, wherein the computer program enables a computer to execute the multi-label emotion sequence generation method described above.
[0159] An embodiment of the present invention provides an electronic device, including:
[0160] One or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, the programs including instructions for executing the multi-label emotion sequence generation method as described above.
[0161] It can be understood that the multi-label emotion sequence generation system based on emotion transfer, storage medium and electronic device provided in the embodiments of the present invention correspond to the multi-label emotion sequence generation method based on emotion transfer provided in the embodiments of the present invention. The explanation, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the multi-label emotion sequence generation method, and will not be repeated here.
[0162] In summary, compared with the existing technology, the present invention has the following beneficial effects:
[0163] The core concept of this embodiment is to formulate the multi-label sentiment classification task of consecutive clauses as a continuous sentiment generation problem. This approach uses a Transformer-based bidirectional encoding representation and a self-attention mechanism to model implicit sentiment transfer relationships at both the character and clause levels. A generative network is then used to model explicit sentiment transfer relationships between sentiment labels, sequentially predicting the discrete distribution of sentiment for each clause. This effectively addresses the relationships between the emotions expressed by consecutive clauses and can be used for sentiment detection at the enterprise, product, and technical levels in specific domains.
[0164] It should be noted that, in this document, relational terms such as first and second, etc., are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply the existence of any such actual relationship or order between these entities or operations. Moreover, the terms "comprises," "comprising," or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article, or device comprising a series of elements includes not only those elements, but also other elements not explicitly listed, or elements inherent to such process, method, article, or device. In the absence of further limitations, an element defined by the phrase "comprising a ..." does not exclude the presence of other identical elements in the process, method, article, or device comprising the element.
[0165] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A multi-label emotion sequence generation method based on emotion transfer, characterized in that: include: S1. Obtain a social comment text to be processed, where the social comment text includes a plurality of consecutive clauses; S2. Perform text joint encoding on the consecutive clauses to obtain a character vector for each clause; S3. Use the first character vector of each word as its word vector and the adjacency matrix of each clause; use the word vector and adjacency matrix as input to the graph convolutional network to obtain the corresponding clause vector; S4. Obtaining a relationship vector between the consecutive clauses based on the clause vector; S5. Obtaining a discrete distribution of sentiment labels for each clause based on the relationship vector; S5 uses a single-layer LSTM network to obtain the discrete distribution of sentiment labels for each clause, including: Initialize each preset emotion label as a learnable embedding vector M∈R N×d , where N is the number of emotion labels; For the i-th clause, the sentiment label vector predicted by the previous clause is weighted, v i-1 =y i-1 ·M where · represents matrix multiplication, y i-1 ∈R 1×N represents the discrete distribution of the sentiment label of the i-1th clause, v i-1 is the weighted emotion vector representation; Based on the LSTM network, predict the hidden state s of the i-th clause i : s i =LSTM(v i-1 ,e i |s i-1 ) Among them, e i represents the clause encoding vector calculated by the attention mechanism; s i-1 represents the hidden state of the i-1th clause; A linear layer is used to transform the hidden state s i The relation vector with the clause is projected onto the pre-built emotion label character table V for joint decoding, and the probability distribution of each emotion is independently calculated through the sigmoid function Among them, W u ∈R N×d ,b u ∈R N Represent the weight matrix and bias of the linear layer respectively; y i ∈R 1×N represents the discrete distribution of the sentiment label of the i-th clause.
2. The method for generating a multi-label emotion sequence based on emotion transfer according to claim 1, wherein: In S2, the BERT tokenizer is used to obtain the character vector of each clause, as shown below: The given review text contains K clauses R = {c1, c2, ..., c K }, clause c i Divided into w i,j Indicates the jth character of the i-th clause, l i is the length of the i-th clause; X i Indicates clause c i A collection of character vectors, Represents the character w i,j The embedding vector of , d represents the character vector dimension.
3. The method for generating a multi-label emotion sequence based on emotion transfer according to claim 1, wherein: The corresponding clause vector is obtained in S3, including: For a given clause containing m words, its adjacency matrix is represented as A∈R m×m , a graph convolutional network with L layers is used, and the graph convolution operation of each layer on the node is expressed as: Among them, σ represents the activation function, W l and b l Represent the weight and bias of the l-th layer graph convolution operation, A ij Indicates the dependency between the i-th word and the j-th word in the current clause, represents the hidden state of the i-th word after l graph convolution operations, is the initial state, represented by the first character vector of the i-th word, represents the final hidden state of the i-th word; The hidden state generated by each layer of graph convolution operation is concatenated with the original word vector to form the word vector h for each word. i ∈R d×L ; According to the word vector, the initial vector representation h∈R of each clause is obtained based on the maximum pooling d×L ; h=MaxPooling(h1,h2,…,h m ) A linear layer is used to perform dimensionality reduction on the initial vector representation of the clause to obtain the corresponding clause vector; x c =W c h+b c Among them, W c and b c denote the weights and biases of the linear layer respectively.
4. The method for generating a multi-label emotion sequence based on emotion transfer according to claim 1, wherein: The self-attention mechanism is used in S4 to obtain the relationship vector between the consecutive clauses, including: For each clause vector Use the self-attention network to calculate the attention weights with all clause vectors; Among them, W v and b v denote weight and bias respectively, express and The vertical connection vector, α ij represents the attention weight of the i-th clause vector to the j-th clause vector; Weighting each clause vector according to the attention weight to obtain a relationship vector between the consecutive clauses; Where K represents the number of clauses; Representation clause vector The relation vector between all clause vectors.
5. A multi-label emotion sequence generation system based on emotion transfer, characterized in that: The method for generating a multi-label emotion sequence according to claim 1 comprises: A data acquisition module, configured to acquire a social comment text to be processed, wherein the social comment text includes a plurality of consecutive clauses; A character encoding module, configured to perform text joint encoding on the consecutive clauses to obtain a character vector for each clause; A graph convolution module is used to take the first character vector of each word as its word vector and the pre-built adjacency matrix of each clause; the word vector and adjacency matrix are used as input to the graph convolution network to obtain the corresponding clause vector; A relation encoding module, configured to obtain a relation vector between the consecutive clauses based on the clause vectors; The sequence generation module is used to obtain the discrete distribution of the emotion label of each clause according to the relationship vector.
6. A storage medium, characterized in that The computer program for generating a multi-label emotion sequence based on emotion transfer is stored therein, wherein the computer program enables a computer to execute the multi-label emotion sequence generating method according to any one of claims 1 to 4.
7. An electronic device, characterized in that: include: one or more processors; Memory; and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by the one or more processors, and the programs include instructions for executing the multi-label emotion sequence generation method according to any one of claims 1 to 4.