Method, system and device for extracting sentiment reason pairs based on sentence vector and multi-feature fusion

By using a method based on sentence vectors and multi-feature fusion, using BERT for word embedding and a multi-layer Transformer module, combined with a directed graph matching strategy and a multi-feature fusion algorithm, the problems of insufficient semantic representation and computational complexity in the task of sentiment reason extraction are solved, and the prediction accuracy and efficiency of the model are improved.

CN114004235BActive Publication Date: 2025-09-23SHENZHEN RES INST OF XIAN JIAOTONG UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111092247.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-17
Publication Date
2025-09-23
Estimated Expiration
2041-09-17

AI Technical Summary

Technical Problem

The existing sentiment reason pair extraction tasks have problems such as insufficient sentence semantic representation features, ignored contextual conditions, overly complex sentiment reason pair matching strategies, and multi-feature extraction and fusion issues, which lead to a sharp increase in computational complexity and poor performance when processing large amounts of text.

Method used

A method based on sentence vectors and multi-feature fusion is adopted, BERT is used for word embedding, and a dynamic word embedding model and a multi-layer Transformer module are combined to capture sentence semantic information. Through a directed graph matching strategy and a multi-feature fusion algorithm, contextual conditions and sentence pair relationships are considered to improve the prediction accuracy of sentiment-cause pairs.

Benefits of technology

It effectively solves the problem of dispersion between sentiment features and cause features, improves the prediction effect of the model, avoids useless calculations and program crashes, enhances the ability to represent sentence semantics, and improves the matching accuracy of sentiment-cause pairs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114004235B_ABST
    Figure CN114004235B_ABST
Patent Text Reader

Abstract

The present invention discloses a method, system and device for extracting emotion-cause pairs based on sentence vectors and multi-feature fusion. It uses word embedding based on the dynamic word embedding method BERT to solve the problem that emotion features and cause features are relatively scattered and sentence semantic representation features are insufficient. By adopting the attention mechanism to effectively obtain the conditional factors related to the emotion cause, the influence factor of the conditional factors is improved, and the problem that the existing model ignores the corresponding conditional factors when the cause triggers the emotion is solved. By determining the possibility of each sentence pair becoming an emotion-cause pair and considering the influence of the contextual conditional factors of the sentence pair on the sentence pair. Starting from the emotion-cause sentence vector, conditional factors, position factors, the predicted status of the previous sentence pair and other factors, a variety of feature fusion strategies are adopted to finally determine the accurate prediction representation of the emotion-cause pair, thereby improving the prediction effect of the model.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of sentence extraction emotion-cause pairs, and relates to a method, system and device for extracting emotion-cause pairs based on sentence vectors and multi-feature fusion. Background Art

[0002] As software applications expand into fields ranging from politics and business to social networking, healthcare, and industry, massive amounts of text-based review data are emerging. According to statistics, Amazon alone saw 113,098,076 reviews in 2017, and this represents just the tip of the iceberg. More and more people are no longer solely focused on specific public opinion events or products; instead, they are accustomed to paying attention to public opinion about these events or products, and using these platforms to express their emotions and opinions. For example, consumers are accustomed to reviewing the products they purchased or the services they received on e-commerce platforms (such as Amazon, Taobao, and JD.com), while netizens are accustomed to expressing their opinions on social networking platforms (such as Twitter and Weibo). Review data holds immense value, and how to mine this value is currently a hot topic in natural language processing research. Fully mining and utilizing the hidden information within these reviews can significantly improve user experience and generate revenue for relevant organizations. For example, sentiment mining within the vast amount of reviews on e-commerce platforms can not only enhance user understanding of the product and optimize their purchasing decisions, but also provide data for companies to optimize their products, improving product quality and overall competitiveness.

[0003] There are three main types of research on text-based sentiment analysis tasks. The first is to classify the emotional polarity in the text, that is, sentiment polarity mining; the second is to mine the opinions of characters in the text about a certain event or item through sentiment analysis, that is, user opinion mining; the third is to mine the emotions of characters in the text and the reasons for their emotions through in-depth analysis of the text, that is, emotional cause mining. In real scenarios, such as product reviews on e-commerce platforms or event reviews on social platforms, people are more concerned about the reasons for the generation of this emotion rather than simple emotional category labels. The concept of emotional cause task was first formally proposed by Lee et al., and its purpose is to determine the clause C in the text. i (i=1,2,…,n) is the cause of the known emotion E in the text. Emotional cause tasks can be divided into sentence level and phrase level according to granularity. Current research focuses on the sentence level. Based on whether the initial emotion is known, there are two types. The first is the emotional cause extraction task (ECE), which aims to analyze the clause C when the initial emotion E is known. i(i=1,2,…,n) is the cause of emotion. The second is the emotional cause pair extraction task (ECPE), which aims to extract all the emotional cause pairs in the text when the emotion is unknown.<E,C> . Among them, there are 27 categories of emotions, including happiness, likes, disgust, fear, etc. The identification of causes requires the combination of emotions and contextual knowledge, and the final categories of emotion-cause pairs include yes or no. Compared with the ECE task, the ECPE task is more applicable to real life and more challenging. Especially in real-life scenarios, due to the existence of a large amount of text without emotional annotations, the ECE task is no longer practical, while the ECPE task can directly mine the emotional clauses and their corresponding cause clauses in the unlabeled text. At the same time, because the emotional ECPE task can take into account the extraction of emotions and causes at the same time, the computational requirements are even greater, and the requirements for the semantic understanding of the text are more stringent.

[0004] Currently, technologies such as recurrent neural networks and attention mechanisms have been widely applied to the task of extracting sentiment-cause pairs. These deep learning-based solutions are roughly divided into three modules: sentence representation acquisition module, sentence interaction module, and sentiment-cause pair matching module. Although current models have achieved excellent results, due to the wide range of content, high feature dispersion, complex context, and colloquialism inherent in text, many problems still exist in the task of extracting sentiment-cause pairs. In particular, these include insufficient sentence semantic representation features, neglected contextual factors, overly complex sentiment-cause pair matching strategies, and problems with multi-feature extraction and fusion. These issues have a significant impact on both the extraction of sentiment-cause features and the matching of sentiment clauses with cause clauses. Summary of the Invention

[0005] The purpose of the present invention is to solve the problems in the prior art and provide a method, system and device for extracting emotion-cause pairs based on sentence vectors and multi-feature fusion. The method uses word embedding based on the dynamic word embedding method BERT to solve the problem that the emotion features and the cause features are relatively scattered and the semantic representation features of the sentences are insufficient. By determining the possibility of each sentence pair becoming an emotion-cause pair and considering the influence of the contextual condition factors of the sentence pair on the sentence pair, the method solves the problem that when there are many text sentences, the result of the Cartesian product method increases exponentially, the amount of calculation increases sharply, and even the program crashes, and there are a lot of useless calculations. The method starts from the emotion-cause sentence vector, conditional factors, position factors, the predicted status of the previous sentence pair and other factors, adopts multiple feature fusion strategies, and finally determines the accurate prediction representation of the emotion-cause pair, thereby improving the prediction effect of the model.

[0006] In order to achieve the above object, the present invention adopts the following technical solutions:

[0007] The sentiment reason pair extraction method based on sentence vector and multi-feature fusion includes:

[0008] Process the input text to obtain the sentence vector representation of the text;

[0009] Enhance the sentence vector representation to obtain the deep semantic information of each sentence vector representation;

[0010] Select a sentence pair in the text in turn, predict the sentence pair, and obtain the prediction result of the sentence pair;

[0011] Based on the prediction results of sentence pairs, different sentences are introduced to form new sentence pairs, and the sentiment-cause pair prediction is performed iteratively;

[0012] Through the multi-feature fusion algorithm, the correlation between sentiment features and cause feature sentence pairs is obtained.

[0013] A further improvement of the present invention is:

[0014] The input text is processed to obtain a sentence vector representation of the text, including: initial processing of the input text, and then obtaining a sentence vector based on the dynamic word embedding model Bert.

[0015] Perform initial processing on the input text, including:

[0016] Given a text X containing n sentences, N}, each text X includes N sentences S, each sentence S x There are d words S x ={W x,1 ,W x,2 ,…,W x,d};

[0017] Among them, W x,i Representative sentence S x where Y represents the final prediction result of the sentence pair, and Y∈{Rt, Rn, Lt, Ln, S, Ca}, where for the sentence pair γ1 and γ2, Rt represents that γ1 is an emotion and γ2 is a corresponding reason; Rn represents that γ1 is an emotion and γ2 is a non-corresponding reason; Lt represents that γ1 is a reason and γ2 is the emotion it triggers; Ln represents that γ2 is an emotion and γ1 is a non-corresponding reason; S represents the initial state; and Ca represents that the emotion clause and the reason clause are in the same sentence.

[0018] Enhance sentence vector representations to obtain the deep semantic information corresponding to each sentence vector representation. This includes: obtaining sentence vectors based on the dynamic word embedding model BERT, while using the multi-layer Transformer module in BERT to accurately capture the contextual information of each word and the sentence vector representation containing rich sentence semantic information;

[0019]

[0020] in, Represents the sentence vector representation of the i-th sentence in the sentence; BERT b Represents a dynamic word embedding model, W i,t Represents the t-th word input of the i-th sentence in the sentence;

[0021] By using the Bertb pre-training result R = {h1,h2,…,h N After Bi-LSTM, the hidden layer representation for emotion is obtained: The vector representation for sentence sentiment prediction is obtained through sentiment-related Softmax:

[0022]

[0023] in, represents the sentiment prediction hidden layer representation of the i-th sentence, is the sentiment auxiliary prediction result of the i-th sentence;

[0024] By using the Bertb pre-training result R = {h1,h2,…,h N} Obtain the hidden layer representation for the cause through Bi-LSTM respectively Obtain vector representation for sentence reason prediction through reason-related Softmax

[0025]

[0026] in, Represents the hidden layer representation of the reason prediction of the i-th sentence, Assist in predicting the cause of the i-th sentence;

[0027] The sentence vector is concatenated with the sentiment prediction vector representation and the cause prediction vector representation to obtain the enhanced sentence vector representation β={β1,β2 , …,β N}:

[0028]

[0029] Among them, β i represents the final representation of the i-th sentence, is the sentiment auxiliary prediction result of the i-th sentence, The reason auxiliary prediction result for the i-th sentence, Represents vector splicing, i.e. β i The final representation is the sentence vector representation h of sentence i i and and Spliced ​​together.

[0030] Select a sentence pair from the text, specifically, take two sentences from the text to form a sentence pair.

[0031] Different sentences are introduced to form new sentence pairs, and sentiment-cause pair prediction is performed iteratively. This includes: proposing a sentiment-cause pair matching strategy based on a directed graph. The sentiment-cause matching model framework is divided into three containers, and the order of sentences in each container is strictly arranged according to the text order; container α stores sentences that have been predicted; container γ aims to make corresponding predictions for both the sentiment and the cause; and container β stores sentences that have not yet been predicted.

[0032] There is at least one sentence in container α and container β, and container α stores at least the first sentence of the text, and container β stores at least the last sentence of the text. One unpredicted sentence is taken from container β and placed in container γ for sentence pair prediction.

[0033] Select two sentences γ1 and γ2. The prediction types of the two sentences are divided into 5 types. When the initial state is S, the container γ is empty. It is necessary to take out two unprocessed sentences γ1 and γ2 from the container β and store them in the container γ for sentence pair prediction; among them:

[0034] Rt is represented in container γ, γ1 is the emotion, and γ2 is the corresponding reason; the sentence completion features are taken from container β and added to container γ for prediction;

[0035] Rn means that in container γ, γ1 is the emotion, and γ2 is not its corresponding reason. After taking out γ2, take out sentences from container β from left to right in turn, and perform emotion-reason pair detection with γ1 until its corresponding reason clause is found;

[0036] Lt indicates that in container γ, γ1 is the cause and γ2 is the emotion it triggers. When γ2 is taken out, considering that γ1 may be the cause of other sentences, it is retained. Then, the sentence completion container γ is taken out from container β, and the emotion cause pair detection is performed with γ1, and subsequent operations are performed;

[0037] Ln means that in container γ, γ2 is an emotion, and γ1 is not the cause of the emotion. After taking out γ1, take out sentences from container β from left to right and perform emotion-cause pair detection with γ2 until the corresponding cause clause is found;

[0038] In the case where the emotion and the reason that triggered the emotion exist in the same sentence, two identical clauses are allowed to exist in the container γ. At the same time, the sentence vector of the semantic enhancement layer is subjected to double-layer linear compression. The difference between the characteristics of this sentence and those of other sentences is then determined. After updating the parameters, accurate prediction of this special sentence pattern is achieved.

[0039] Through the multi-feature fusion algorithm, the correlation between sentiment features and cause feature sentence pairs is obtained, including:

[0040] The prediction of sentiment feature and reason feature pair is composed of 6 features, among which γ2 is the reason clause representation, γ1 is the sentiment clause representation, H f is the above-mentioned related conditional factor characteristics, H o is the characteristic of the relevant conditional factors below, H A Represents all the predicted result features before, H p is the relative position feature;

[0041] Introducing contextual factors; Since conditional factors usually exist in the context of a sentence, and there is a close relationship between sentiment clauses and reason clauses; Therefore, an attention mechanism is used to capture conditional factors. In particular, since conditional factors vary in context, the sentiment reason vector is used to represent the previous and next contexts, respectively, to obtain the conditional factors in the previous and next contexts, which are applied to the final feature prediction; The input of this module consists of four parts, namely, the container γ, the first clause representation The second clause of container γ indicates The clause in the container α above represents The clauses in the container β below represent

[0042] The specific calculation process is as follows: 1) After concatenating the vectors in the container γ, BI-LSTM processing is performed on the previous and next contexts respectively; 2) the conditional factor vector representation of the previous and next contexts is obtained through the attention mechanism, where:

[0043]

[0044]

[0045]

[0046]

[0047]

[0048]

[0049]

[0050] Among them, H γ Represents the vector representation of the concatenation of container two γ, and α t and β t They are the BI-LSTM hidden layer outputs of the above and below texts respectively, and H γ The attention weight after paying attention to the context, and are the above conditional features and the below conditional features respectively;

[0051] Introduce the previous sentence to predict the result features; Considering the prediction results A before the present invention t-1 and the current text state S t The prediction result A of the sentence pair in the container γ t Therefore, all prediction results are introduced, and considering the sequential and irreversible characteristics of the prediction results, a unidirectional LSTM is used to capture all previous prediction features, and the previous prediction results and the current text state are used to predict the container γ sentence pair;

[0052]

[0053] W t-1 =LSTM(A 1 ,…,A t-1 ) (13)

[0054] Among them, A t is the state prediction result in the current environment, S t is the current environment state, W t-1 is the unidirectional LSTM state of the previous prediction result;

[0055] Relative position feature introduction: The relative distance between the sentence pairs γ1 and γ2 in the container γ is also a very important feature. Therefore, the relative distance feature is introduced. The absolute value of the distance difference between γ1 and γ2 is used and vector embedding is performed to capture the corresponding relative position features.

[0056]

[0057] Reversal prediction is introduced; after fusing multiple features by feature splicing, they are input into the lower network; considering that in container γ, if sentence pair γ1 and γ2 are a sentiment-cause pair and are predicted as Rt, then the prediction result after reversal should be Lt. Similarly, if the prediction result of the sentence pair is Rn, then the prediction result after reversal should be Ln; to address this phenomenon, a reverse prediction module for sentiment-cause pairs is proposed, that is, when fusing multiple features, the order of γ1 and γ2 in container γ is reversed, while other features are not affected by the reversal and therefore remain unchanged; this reverse prediction method improves the accuracy of the current prediction on the one hand, and verifies the current prediction result on the other hand;

[0058]

[0059]

[0060] The main goal of the sentiment prediction layer is to predict γ1 and γ2 in both the forward and reverse directions, thereby obtaining the correlation between them and using the reverse prediction for verification. Because the vector representation is too long after concatenating and fusing multiple features, an MLP is used to compress the vector. The MLP consists of two linear layers. Through compression and a Softmax layer, the vector length is ultimately controlled to 6 to accommodate six different prediction results.

[0061]

[0062]

[0063] in, is the positive prediction for the sentiment-reason sentence pair, and Backward prediction for sentiment-reason sentence pairs.

[0064] The sentiment reason pair extraction system based on sentence vector and multi-feature fusion includes:

[0065] A text processing module, which is used to process input text and obtain sentence vector representations of the text;

[0066] An enhancement module is used to enhance the sentence vector representation and obtain the deep semantic information of the sentence corresponding to each sentence vector representation;

[0067] a first prediction module, configured to sequentially select a sentence pair from the text, predict the sentence pair, and obtain a prediction result for the sentence pair;

[0068] A second prediction module, which is used to introduce different sentences to form new sentence pairs based on the prediction results of the sentence pairs, and iteratively predict the emotion-cause pairs;

[0069] The multi-feature fusion algorithm module is used to obtain the correlation between the sentiment feature and the cause feature sentence pair through the multi-feature fusion algorithm.

[0070] A terminal device comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the above method when executing the computer program.

[0071] A computer-readable storage medium stores a computer program, which implements the steps of the above method when executed by a processor.

[0072] Compared with the prior art, the present invention has the following beneficial effects:

[0073] This invention discloses a method, system, and device for extracting sentiment-cause pairs based on sentence vectors and multi-feature fusion. Using word embedding based on the dynamic word embedding method BERT, this method addresses the problem of dispersed sentiment and cause features, and insufficient semantic representation of sentences. A novel method for capturing conditional factors is also proposed. By employing an attention mechanism, the method effectively captures conditional factors related to sentiment causes, improving the influence of conditional factors and resolving the issue of existing models ignoring the presence of corresponding conditional factors when the cause triggers emotion. A novel sentiment-cause matching method based on a directed graph is also proposed. This method determines the likelihood of each sentence pair becoming a sentiment-cause pair and considers the influence of the sentence pair's contextual conditional factors on the sentence pair. This method addresses the exponential growth of results, the dramatic increase in computational complexity, and even program crashes, as well as the significant amount of wasted computations, resulting from the Cartesian product method when the text contains a large number of sentences. A novel multi-feature fusion strategy for sentiment-cause pairs is also proposed. This strategy utilizes multiple feature fusion strategies based on factors such as sentiment-cause sentence vectors, conditional factors, positional factors, and the predicted status of previous sentence pairs, ultimately determining an accurate predicted representation of the sentiment-cause pair, thereby improving the model's prediction performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other relevant drawings can be obtained based on these drawings without paying any creative work.

[0075] Figure 1 This is a flowchart of a method for extracting sentiment reason pairs by integrating sentence vectors and multiple features according to an embodiment of the present invention;

[0076] Figure 2 The overall framework diagram of the SRMF model of the present invention; wherein, (a) is the sentence semantic enhancement diagram; (b) is the sentiment cause pair prediction diagram;

[0077] Figure 3 A diagram of the Cartesian product method used by existing methods;

[0078] Figure 4 This is an example diagram of conditional factors in the present invention;

[0079] Figure 5 The following are the sentence distribution results of the standard dataset for emotional reasons; (a) is the statistical distribution graph of the Chinese dataset; (b) is the statistical distribution graph of the English dataset;

[0080] Figure 6 The following are the result diagrams of sentence distribution of the standard dataset of emotional reasons; (a) is the logarithmic distribution diagram of the emotional reason sentences of the Chinese dataset; (b) is the logarithmic distribution diagram of the emotional reason sentences of the English dataset;

[0081] Figure 7 A comparison chart of the results of the present invention and the ECPE model;

[0082] Figure 8 A comparison chart of the ablation experiment results of the present invention. DETAILED DESCRIPTION

[0083] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the embodiments of the present invention will be clearly and completely described below in conjunction with the accompanying drawings of the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings herein can be arranged and designed in various different configurations.

[0084] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention as claimed, but rather merely represents selected embodiments of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort shall fall within the scope of protection of the present invention.

[0085] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, it does not need to be further defined or explained in subsequent drawings.

[0086] In the description of the embodiments of the present invention, it should be noted that if the terms "upper," "lower," "horizontal," "inner," etc. appear, the orientation or positional relationship indicated is based on the orientation or positional relationship shown in the accompanying drawings, or the orientation or positional relationship in which the inventive product is typically placed when in use. These terms are merely for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or component referred to must have a specific orientation, be constructed, or operate in a specific orientation. Therefore, they should not be construed as limitations on the present invention. In addition, the terms "first," "second," etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0087] In addition, if the term "horizontal" appears, it does not mean that the component must be absolutely horizontal, but can be slightly tilted. For example, "horizontal" only means that its direction is more horizontal than "vertical", and does not mean that the structure must be completely horizontal, but can be slightly tilted.

[0088] In the description of the embodiments of the present invention, it should be noted that, unless otherwise expressly specified or limited, the terms "disposed," "installed," "connected," and "connected" should be understood in a broad sense. For example, they can refer to fixed connections, detachable connections, or integral connections; they can refer to mechanical connections or electrical connections; they can refer to direct connections or indirect connections through an intermediate medium; and they can refer to internal connections between two components. Those skilled in the art will understand the specific meanings of the above terms in the present invention based on specific circumstances.

[0089] The present invention is described in further detail below with reference to the accompanying drawings:

[0090] See also Figure 1 , Figure 1 This is a flowchart of the present invention's emotion-cause pair extraction method based on sentence vectors and multi-feature fusion. This method enhances sentence representations using emotion and cause auxiliary tasks, introduces contextual factors through an attention mechanism, and introduces a new emotion-cause matching method. Finally, a multi-feature fusion strategy is used to obtain predicted vector representations. The present invention primarily involves the following three modules: 1) Sentence semantic enhancement and interaction module; 2) Emotion-cause pair matching module; and 3) Multi-feature fusion and prediction module. It is characterized by:

[0091] Module 1: The purpose of this module is to embed the input text into words and enhance the sentence representation so that each sentence vector representation captures the deep semantic information of the sentence. First, the dynamic word embedding model Bert is used to obtain sentence vectors. The advantage of Bert is that it dynamically learns word vector representations during the pre-training process, so that each word or symbol can have rich semantic information, and the multi-layer Transformer module can accurately capture the contextual information of each word and the sentence vector representation containing rich sentence semantic information. At the same time, considering that sentiment features and cause features are relatively discrete, the present invention uses separate sentiment clause prediction and cause clause prediction as auxiliary tasks for subsequent modules.

[0092] Module 2: This module uses a novel sentiment-cause pair matching strategy based on a directed graph. Each time, two sentence pairs are extracted from the text. Based on the prediction results of these two sentence pairs, different sentences are introduced for the next step of sentiment-cause detection. This approach eliminates unnecessary computation and weights attention to useful sentiment-cause-related sentence pairs in the text.

[0093] Module 3: This module primarily consists of a multi-feature fusion layer and a sentiment-cause pair prediction layer. Its purpose is to capture the correlation between sentiment and cause sentence pairs and perform joint predictions. To fully capture the correlation between sentiment and cause features within the sentiment-cause pair, this paper employs multi-feature fusion to capture the nuanced distinctions between sentiment and cause features from multiple perspectives.

[0094] The specific structure of the present invention is as follows Figure 2 (a) and Figure 2 (b) shown.

[0095] The specific steps include:

[0096] Phase 0: Data Initialization

[0097] Step 0: Given a text X containing n sentences, N}, each text X includes N sentences S, each sentence S x There are d words S x ={W x,1 ,W x,2 ,…,W x,d}, where W x,i Representative sentence S xThe i-th word in , Y represents the final prediction result of the sentence pair, and Y∈{Rt, Rn, Lt, Ln, S, Ca}, where for the sentence pair γ1 and γ2, 1) Rt represents γ1 as emotion and γ2 as the corresponding reason; 2) Rn represents γ1 as emotion and γ2 as the non-corresponding reason; 3) Lt represents γ1 as the reason and γ2 as the emotion caused by it; 4) Ln represents γ2 as emotion and γ1 as the non-corresponding reason; 5) S represents the initial state; 6) Ca represents that the emotion clause and the reason clause are in the same sentence.

[0098] Phase 1: Sentence Semantic Enhancement and Interaction Module

[0099] Step 1: The purpose of the embedding layer is to map the input text into a vector space and enhance the sentence representation so that each sentence vector representation can capture the deep semantic information of the sentence. This paper uses the dynamic word embedding model BERT to obtain sentence vectors. At the same time, the multi-layer Transformer module in BERT can accurately capture the contextual information of each word and the sentence vector representation containing rich sentence semantic information;

[0100]

[0101] in, Represents the sentence vector representation of the i-th sentence in the sentence; BERT b represents the dynamic word embedding model used in the present invention, W i,t Represents the t-th word input of the i-th sentence in the sentence;

[0102] Step 2: Considering that the emotional features are relatively discrete, the present invention proposes to use separate emotional clause prediction as an auxiliary task for subsequent modules for the prediction of emotional reason pairs. Figure 2 (a) shows that by using the Bertb pre-training result R = {h1,h2,…,h N After Bi-LSTM, the hidden layer representation for emotion is obtained: Then the sentiment-related Softmax is used to obtain the vector representation for sentence sentiment prediction:

[0103]

[0104] in, represents the sentiment prediction hidden layer representation of the i-th sentence, is the sentiment auxiliary prediction result of the i-th sentence;

[0105] Step 3: By using the Bertb pre-training result R = {h1,h2,…,h N} Obtain the hidden layer representation for the cause through Bi-LSTM respectively Obtain vector representation for sentence reason prediction through reason-related Softmax

[0106]

[0107] in, Represents the hidden layer representation of the reason prediction of the i-th sentence, Assist in predicting the cause of the i-th sentence;

[0108] Step 4: Concatenate the sentence vector with the sentiment prediction vector representation and the cause prediction vector representation to obtain the enhanced sentence vector representation β = {β1,β2,…,β N}:

[0109]

[0110] Among them, β i represents the final representation of the i-th sentence, is the sentiment auxiliary prediction result of the i-th sentence, The reason auxiliary prediction result for the i-th sentence, Represents vector splicing, i.e. β i The final representation is the sentence vector representation h of sentence i i and and This method makes up for the problem that the sentence representation obtained by the BERT pre-training module is insensitive to sentiment and cause features, and provides semantic enhancement for the subsequent matching of sentiment and cause pairs and multi-feature fusion.

[0111] Stage 2: Emotion-Cause Pair Matching Module

[0112] Step 5: Based on the prediction results of the two sentence pairs, different sentences are introduced to perform the next step of sentiment reason detection, and a new sentiment reason pair matching strategy based on directed graph is proposed. Among them, the sentiment reason matching model framework is mainly divided into the following three containers: Figure 2 (b) The lower layer shows the order of sentences in each container, strictly following the order of the text. Container α primarily stores sentences that have already been predicted; container γ aims to predict the sentiment and reason sentences accordingly; and container β primarily stores sentences that have not yet been predicted. Containers α and β each contain at least one sentence, with container α storing at least the first sentence of the text and container β storing at least the last sentence of the text. Each unpredicted sentence is taken from container β and placed in container γ for sentence pair prediction.

[0113] Step 6: Generally, the prediction types of two sentences (γ1 and γ2) can be divided into five types, as shown in Table 1. When the initial state is S, the container γ is empty. It is necessary to take out two unprocessed sentences γ1 and γ2 from the container β and store them in the container γ for sentence pair prediction. Among them:

[0114] Rt is represented in container γ, where γ1 is the emotion and γ2 is the corresponding reason. The sentence completion features are taken from container β and added to container γ for prediction.

[0115] Rn means that in container γ, γ1 is the emotion, and γ2 is not its corresponding reason. After taking out γ2, sentences are taken out from container β from left to right in turn, and the emotion-reason pair detection is performed with γ1 until the corresponding reason clause is found.

[0116] Lt means that in container γ, γ1 is the cause and γ2 is the emotion it triggers. When γ2 is taken out, considering that γ1 may be the cause of other sentences, it is retained. Then the sentence completion container γ is taken out from container β, and the emotion cause pair detection is performed with γ1, and subsequent operations are performed.

[0117] Ln means that in container γ, γ2 is an emotion, and γ1 is not the cause of the emotion. After taking out γ1, sentences are taken out from container β from left to right in turn, and the emotion-cause pair detection is performed with γ2 until the corresponding cause clause is found, and then subsequent operations are performed.

[0118] Table 1 Different operations for different prediction results of sentences in container 2γ

[0119]

[0120] Step 7: For the case where the emotion and the cause of the emotion exist in the same sentence, the present invention allows two identical clauses to exist in the container γ. At the same time, the sentence vector of the semantic enhancement layer is subjected to double-layer linear compression. Then, the difference between the features of the sentence and those of other sentences is determined. After updating the parameters, accurate prediction of this special sentence pattern is achieved.

[0121] Stage 3: Multi-feature fusion and prediction module

[0122] Step 8: This invention adopts a multi-feature fusion approach to capture the subtle differences between emotional features and cause features from multiple aspects. Figure 2 (b) As shown in the upper layer, it is mainly composed of 6 features, among which γ2 is the cause clause representation, γ1 is the emotion clause representation, H f is the above-mentioned related conditional factor characteristics, H o is the characteristic of the relevant conditional factors below, H A Represents all the predicted result features before, H pIt is a relative position feature.

[0123] Step 9: Introduce contextual factors. Since conditional factors usually exist in the context of a sentence, and there is a close relationship between the sentiment clause and the cause clause. Therefore, the present invention adopts an attention mechanism to capture conditional factors. In particular, since conditional factors vary in context, this model uses the sentiment cause vector representation to pay attention to the preceding and following contexts, thereby obtaining the conditional factors in the preceding and following contexts and applying them to the final feature prediction. The input of this module consists of four parts, namely, the container γ, the first clause representation The second clause of container γ indicates The clause in the container α above represents The clauses in the container β below represent The specific calculation process is as follows: 1) After concatenating the vectors in the container γ, BI-LSTM processing is performed on the previous and next contexts respectively; 2) the conditional factor vector representation of the previous and next contexts is obtained through the attention mechanism, where:

[0124]

[0125]

[0126]

[0127]

[0128]

[0129]

[0130]

[0131] Among them, H γ Represents the vector representation of the concatenation of container two γ, and α t and β t They are the BI-LSTM hidden layer outputs of the above and below texts respectively, and H γ The attention weight after paying attention to the context, and They are the above conditional features and the below conditional features respectively.

[0132] Step 10: Introduce the prediction result features of the previous sentence. Considering the prediction result A before the present invention t-1 and the current text state S t In fact, the prediction result A of the sentence pair in the container γ will be tTherefore, the present invention introduces all the prediction results mentioned above, and taking into account the sequential and irreversible characteristics of the prediction results, the present invention adopts a unidirectional LSTM to capture all the previous prediction features, and uses the previous prediction results and the current text state to predict the container γ sentence pair.

[0133]

[0134] W t-1 =LSTM(A 1 ,…,A t-1 ) (13)

[0135] Among them, A t is the state prediction result in the current environment, S t is the current environment state, W t-1 is the unidirectional LSTM state of the previous prediction result.

[0136] Step 11: Introducing relative position features. The relative distance between the sentence pairs γ1 and γ2 in the container γ is also a very important feature. Therefore, this paper introduces relative distance features by using the absolute value of the distance difference between γ1 and γ2 and performing vector embedding to capture the corresponding relative position features.

[0137]

[0138] Step 12: Introducing reverse prediction. After fusing many features by means of feature splicing, they are input into the lower network. Considering that in the container γ, if the sentence pair γ1 and γ2 are an emotional reason pair and are predicted to be Rt, then the prediction result after reversal should be Lt. Similarly, if the prediction result of the sentence pair is Rn, then the prediction result after reversal should be Ln. In response to this phenomenon, the present invention proposes a reverse prediction module for emotional reason pairs, that is, when multiple features are fused, the present invention reverses the order of γ1 and γ2 in the container γ, while other features are not affected by the reversal and therefore do not change. By adopting this reverse prediction method, on the one hand, the accuracy of the current prediction can be improved, and on the other hand, the results of the current prediction can also be verified.

[0139]

[0140]

[0141] Step 13: The main goal of the sentiment prediction layer is to predict γ1 and γ2 in both the forward and reverse directions, thereby obtaining the correlation between γ1 and γ2 and verifying it using the reverse prediction. Because the length of the vector representation is too long after the multi-feature splicing and fusion, the present invention uses an MLP to compress the vector. The MLP consists of two linear layers. Through the compression of the two linear layers and the Softmax layer, the length of the vector is ultimately controlled to 6 to cope with 6 different prediction results.

[0142]

[0143]

[0144] in, is the positive prediction for the sentiment-reason sentence pair, and Backward prediction for sentiment-reason sentence pairs.

[0145] Stage 4: Loss function calculation

[0146] Step 14: The loss function of the model of the present invention consists of the following four parts: emotion-assisted prediction task, cause-assisted prediction task, emotion-cause forward prediction, and emotion-cause reverse prediction. The emotion-assisted prediction task and cause-assisted prediction task help the model better capture the specific representations of emotion and cause.

[0147]

[0148] in, and They are the emotion labeling results and prediction results respectively. and These are the labeling results and prediction results of the cause, respectively. The losses of the emotion-assisted prediction task and the cause-assisted prediction task are obtained through cross entropy.

[0149] Step 15: For the positive prediction of emotional reasons, the reverse prediction of emotional reasons, and the special form of emotional reasons in the same sentence, realize the combined prediction result representation:

[0150]

[0151] in, and They are the annotation results and prediction results of the positive prediction of emotional reasons, and They are the annotation results and prediction results of the emotional reasons for the reverse prediction, and It means that the emotional reasons are the annotation results and prediction results in the same sentence.

[0152] Step 16: The final loss function formula:

[0153] J(θ)=αL aux +βL ecpe +γ||θ|| 2 (twenty one)

[0154] Among them, α, β and γ are weights, and θ represents all parameters in the model.

[0155] The sentiment reason pair extraction system based on sentence vector and multi-feature fusion includes:

[0156] A text processing module, which is used to process input text and obtain sentence vector representations of the text;

[0157] An enhancement module is used to enhance the sentence vector representation and obtain the deep semantic information of the sentence corresponding to each sentence vector representation;

[0158] a first prediction module, configured to sequentially select a sentence pair from the text, predict the sentence pair, and obtain a prediction result for the sentence pair;

[0159] A second prediction module, which is used to introduce different sentences to form new sentence pairs based on the prediction results of the sentence pairs, and iteratively predict the emotion-cause pairs;

[0160] The multi-feature fusion algorithm module is used to obtain the correlation between the sentiment feature and the cause feature sentence pair through the multi-feature fusion algorithm.

[0161] A schematic diagram of a terminal device provided in one embodiment of the present invention. The terminal device in this embodiment includes: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the steps of each of the aforementioned method embodiments are implemented. Alternatively, when the processor executes the computer program, the functions of each module / unit in each of the aforementioned device embodiments are implemented.

[0162] The computer program may be divided into one or more modules / units, which are stored in the memory and executed by the processor to accomplish the present invention.

[0163] The terminal device may be a computing device such as a desktop computer, a notebook computer, a PDA, a cloud server, etc. The terminal device may include, but is not limited to, a processor and a memory.

[0164] The processor can be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc.

[0165] The memory may be used to store the computer programs and / or modules, and the processor implements various functions of the terminal device by running or executing the computer programs and / or modules stored in the memory and calling the data stored in the memory.

[0166] If the module / unit integrated in the terminal device 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 each of the above-mentioned 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. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM), electric carrier signal, telecommunication signal and software distribution medium. It should be noted that the content contained in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction. For example, in some jurisdictions, according to legislation and patent practice, computer-readable media do not include electric carrier signals and telecommunication signals.

[0167] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention. Those skilled in the art will readily appreciate that various modifications and variations of the present invention are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present invention shall be included within the scope of protection of the present invention.

Claims

1. The sentiment reason pair extraction method based on sentence vector and multi-feature fusion is characterized by: include: Process the input text to obtain the sentence vector representation of the text; Enhance the sentence vector representation to obtain the deep semantic information of each sentence vector representation; Select a sentence pair in the text in turn, predict the sentence pair, and obtain the prediction result of the sentence pair; Based on the prediction results of sentence pairs, different sentences are introduced to form new sentence pairs, and the sentiment-cause pair prediction is performed iteratively; Through the multi-feature fusion algorithm, the correlation between the sentiment feature and the cause feature sentence pair is obtained, as follows: The prediction of emotional features and cause features is composed of 6 features, among which, and Represent two sentences respectively. are the characteristics of the above-mentioned relevant conditions and factors, The following are the relevant conditional factors: Represents all the predicted result features of the previous predictions, is the relative position feature; Introducing contextual factors; Since the conditional factors exist in the context of the sentence, and there is a correlation between the sentiment clause and the reason clause; Therefore, the attention mechanism is used to capture the conditional factors. Since the conditional factors are different in the context, the sentiment reason vector is used to represent the attention of the previous and next contexts, thereby obtaining the conditional factors in the previous and next contexts and applying them to the final feature prediction; The input of this module consists of four parts, namely, container The first clause indicates ,container The second clause indicates , the above container The clause in , the following container The clause in ; The specific calculation process is as follows: 1) The container After concatenating the vectors in , BI-LSTM is performed on the previous and next contexts respectively. 2) The conditional factor vector representation of the previous and next contexts is obtained through the attention mechanism, where: in, Represents container 2 The concatenated vector representation is and They are the BI-LSTM hidden layer outputs of the above and below texts respectively, and They are The attention weight after paying attention to the context, and are the above conditional features and the below conditional features respectively; Introduce the prediction result features of the previous sentence; use unidirectional LSTM to capture all previous prediction features, and use the previous prediction results and the current text state to compare the container Make predictions based on sentence pairs; in, is the state prediction result in the current environment, For the previous prediction results, is the current environment status, is the unidirectional LSTM state of the previous prediction result; Relative position feature introduction; using sentence pairs and The absolute value of the distance difference is used to embed the vector to capture the corresponding relative position features; Reversal prediction introduced; in, Representative For emotion, For the corresponding reasons; The goal of the emotional reason prediction layer is to and Forward and reverse prediction of and The correlation between them is verified by reverse prediction. Since the length of the vector representation is too long after the multi-feature splicing and fusion, MLP is used to compress the vector. MLP consists of two linear layers. Through the compression of the two linear layers and the Softmax layer, the length of the vector is finally controlled to 6 to cope with 6 different prediction results. in, is the positive prediction for the sentiment-reason sentence pair, and Backward prediction for sentiment-reason sentence pairs.

2. The method for extracting sentiment cause pairs based on sentence vectors and multi-feature fusion according to claim 1 is characterized in that: The processing of the input text to obtain a sentence vector representation of the text includes: performing initial processing on the input text, and then obtaining a sentence vector based on a dynamic word embedding model Bert.

3. The method for extracting sentiment cause pairs based on sentence vectors and multi-feature fusion according to claim 1 is characterized in that: The initial processing of the input text includes: Given contains Sentences of text , each text include Sentences , every sentence Also includes words ; in, Representative sentences The words, represents the final prediction result of the sentence pair, and , where for sentence pairs and , represent For emotion, For the corresponding reasons; represent For emotion, Indicates the reason for non-correspondence; represent For the reason, the emotions it evokes; represent For emotion, Non-corresponding reasons; Represents the initial state; It represents the emotion clause and the reason clause in the same sentence.

4. The method for extracting sentiment cause pairs based on sentence vectors and multi-feature fusion according to claim 1 is characterized in that: The sentence vector representation is enhanced to obtain the deep semantic information of each sentence corresponding to the sentence vector representation, including: obtaining the sentence vector based on the dynamic word embedding model BERT, and using the multi-layer Transformer module in BERT to capture the contextual information of each word and the sentence vector representation containing rich sentence semantic information; in, Indicates the first Sentence vector representation of a sentence; Represents a dynamic word embedding model, Indicates the first The first sentence Word input; By Pre-training results After passing through Bi-LSTM, the hidden layer representation for emotion is obtained: , through emotionally related Obtaining vector representations for sentence sentiment prediction : in, Representative The hidden layer representation of sentiment prediction of a sentence, For the Sentiment-assisted prediction results of sentences; By Pre-training results Obtain the hidden layer representation for the cause through Bi-LSTM respectively , through cause-related Obtaining vector representation for sentence reason prediction : in, Representative The hidden layer representation of the reason prediction of a sentence, For the The reasons of each sentence assist in predicting the results; The sentence vector is concatenated with the sentiment prediction vector representation and the cause prediction vector representation to obtain the enhanced sentence vector representation. : in, Representative The final representation of the sentence is For the The sentiment-assisted prediction results of the sentences are: For the The reasons for the sentences assist in predicting the results. represents vector concatenation, i.e. The final representation is given by the sentence Sentence vector representation of and and Spliced ​​together.

5. The method for extracting sentiment cause pairs based on sentence vectors and multi-feature fusion according to claim 1 is characterized in that: The selecting a sentence pair from the text specifically involves taking out two sentences from the text to form a sentence pair.

6. The method for extracting sentiment cause pairs based on sentence vectors and multi-feature fusion according to claim 1 is characterized in that: The method introduces different sentences to form new sentence pairs and iteratively predicts sentiment-cause pairs, including: proposing a sentiment-cause pair matching strategy based on a directed graph, wherein the sentiment-cause matching model framework is divided into three containers, and the order of sentences in each container is strictly arranged in the order of the text; Store sentences that have been predicted; container The goal is to make corresponding predictions for the two sentences: emotion and reason; Store sentences that have not yet been predicted; Among them, the container and container There is at least one sentence in the container Store at least the first sentence of the text, the container Store at least the last sentence of the text, starting from the container Take out a sentence that has not been predicted and put it into the container To make sentence pair prediction; Select two sentences and , the prediction types of the two sentences are divided into 5 types. When the initial state is S, the container Empty, need to be removed from the container Take out two unprocessed sentences and Store in container To predict sentence pairs: Indicates that the container middle, For emotion, For the corresponding reason; from the container Extract the sentence completion features and add them to the container and make predictions; Indicates that the container middle, For emotion, If it is not the corresponding reason, After taking out, take out sentences from container β from left to right, and Perform emotion-reason pair detection until the corresponding reason clause is found; Indicates that the container middle, For the reason, The emotions it evokes will When removing, take into account It may be the reason for other sentences, so keep it and then remove it from the container Take out the sentence completion container ,and Conduct emotional reason detection and follow-up operations; Indicates that the container middle, For emotion, The reason for the emotion is not After taking out, Take the sentences from left to right, and Perform emotion-reason pair detection until the corresponding reason clause is found; For situations where the emotion and the reason that triggered the emotion exist in the same sentence, it is allowed to There are two identical clauses in the sentence. At the same time, the sentence vector of the semantic enhancement layer is subjected to double-layer linear compression. Then, the difference between the features of the sentence and those of other sentences is judged, and the parameters are updated to achieve the prediction of this special sentence.

7. A sentiment reason pair extraction system based on sentence vectors and multi-feature fusion for implementing the method of claim 1, characterized in that: include: A text processing module, which is used to process input text and obtain sentence vector representations of the text; An enhancement module is used to enhance the sentence vector representation and obtain the deep semantic information of the sentence corresponding to each sentence vector representation; a first prediction module, configured to sequentially select a sentence pair from the text, predict the sentence pair, and obtain a prediction result for the sentence pair; A second prediction module, which is used to introduce different sentences to form new sentence pairs based on the prediction results of the sentence pairs, and iteratively predict the emotion-cause pairs; The multi-feature fusion algorithm module is used to obtain the correlation between the sentiment feature and the cause feature sentence pair through the multi-feature fusion algorithm.

8. A terminal device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Text emotion reason identification method based on D-LSTM

    CN110162636A

  • Crowd-based scores for experiences from measurements of affective response

    US20160170996A1