A method for extracting emotional reasons based on machine question answering and joint coding
By using a machine question-answering and joint encoding approach, and leveraging BERT and relational graph convolutional neural networks to enhance the representation of sentiment and cause clauses, this approach addresses the issues of low accuracy and insufficient sensitivity to long texts in existing technologies, achieving more efficient sentiment and cause pair extraction.
Patent Information
- Application Number
- CN202410661776.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-27
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-05-27
AI Technical Summary
Existing methods for extracting sentiment and causal relationships fail to fully leverage the facilitating effect of multi-task learning, neglecting the relationship between sentiment and causal clauses. This can lead to the omission of causal relationships between sentiment and causal relationships in long texts. Furthermore, the lack of consistency in multi-task objectives results in low extraction accuracy.
We employ a machine question answering and joint encoding approach, using BERT encoding to obtain clause representations, constructing a relational graph convolutional neural network, enhancing clause representations with keywords, and constructing an undirected heterogeneous graph for sentiment cause pair extraction, thereby enhancing information flow and task collaboration between clauses.
It improves the accuracy and recall of emotional causes extraction, solves the problem of missing causal relationships in long texts, enhances the expressive power of clauses and the introduction of external knowledge, and achieves the unification of multi-task objectives.
Smart Images

Figure CN118446225B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of natural language processing, and in particular to a method for extracting sentiment cause pairs based on machine question answering and joint encoding. BACKGROUND
[0002] "Sentiment" has always been the focus of the field of natural language processing. With the informatization of various industries, people's interaction with machines has gradually increased, and the demand for human-computer dialogue in the medical, e-commerce and other fields has also gradually increased. People may need to interact with machines on the network when handling various businesses, and people also increasingly frequently communicate with others or machines on the network to relieve stress and relax themselves. Whether it is human-computer dialogue or sentiment analysis of e-commerce comments, the reasons for the sentiment sentence need to be analyzed, and with the in-depth research, the potential causes behind the sentiment have attracted widespread attention from scholars.
[0003] The task of extracting emotion cause pairs (ECPE) is a fine-grained task in the field of sentiment analysis that has become very popular in recent years. It only extracts all the potential emotion cause pairs in the document, and each emotion cause pair is composed of an emotion clause and a corresponding reason clause.
[0004] For the ECPE task, the existing method is a two-step method. The first step is to convert the emotion cause pair extraction task into two separate sub-tasks (emotion extraction and reason extraction) by using two multi-task learning networks, and extract a set of emotion clauses and a set of reason clauses. The second step performs emotion cause pairing and filtering, that is, combining all elements of the two sets into pairs, and finally training a filter to eliminate pairs that do not contain causal relationships. Among them, the first step is independent multi-task learning. The method is to input the sentence into the input layer after encoding, and then input the vector output by the input layer into the lower emotion sentence extraction and reason clause C extraction two sub-tasks, respectively, to extract emotion clauses E and reason clauses C. After the first step of extracting emotion clauses E and reason clauses C, the second step task of emotion cause pairing and filtering is performed, which specifically includes combining and pairing emotion clauses E and reason clauses C through Cartesian product, and using three kinds of features to represent each pair combination: the representation of emotion clauses se and the representation of reason clauses sc and the distance v between the two clauses; then use a logistic regression model to detect whether there is a causal relationship between each pair of clauses, if there is, save it, if not, delete it.
[0005] However, the method uses independent multi-task learning to extract sentiment clauses and reason clauses respectively, ignores the relationship between the sentiment clauses and the reason clauses, and some texts do not have corresponding reason clauses as the context of the sentiment, so some sentiment clauses may not be detected, in addition, the sub-tasks of the sentiment clauses and the reason clauses are independent of the task in the second step, and the two sub-tasks cannot fully promote the extraction task of the sentiment and reason pair, lack of interaction between tasks, resulting in low accuracy of the extraction task of the sentiment and reason pair. SUMMARY
[0006] The present application aims to overcome the shortcomings and deficiencies of the prior art, and provides a sentiment and reason pair extraction method based on machine question answering and joint encoding, which can efficiently and accurately extract the sentiment and reason pair in the text.
[0007] The present application is implemented by the following technical solutions:
[0008] A sentiment and reason pair extraction method based on machine question answering and joint encoding, comprising the following steps:
[0009] Step S10: obtaining the clauses and keywords of the target text, performing BERT encoding on the clauses to obtain the implicit representation of each clause in the text, and updating the implicit representation of the clauses using the information of the keywords to obtain the keyword semantic enhanced clause representation;
[0010] Step S20: extracting all sentiment clause representations and reason clause representations according to a preset probability threshold and keyword semantic enhanced clause representation, pairing the sentiment clause representations and the reason clause representations, and obtaining the representation of the sentiment and reason clause pair;
[0011] Step S30: constructing a relation graph convolutional neural network using the clause representation and the clause pair representation, and obtaining the sentiment and reason pair extraction result based on the relation graph convolutional neural network;
[0012] The step S10 further comprises: taking the union of the keywords and the external knowledge base to form a keyword set, updating the implicit representation of the clauses based on the keyword set, and obtaining the keyword semantic enhanced clause representation:
[0013]
[0014] In the formula, v i is a clause node v’ i characteristic, represents the representation of the keyword node k j , is the weighted addition of the keyword representation, which is used to generate a smaller granularity keyword semantic enhanced clause representation, wherein, are trainable parameters, |D| is the number of clauses in the target text, b is a bias term, attention weight a ij is the edge weight between the clause node v' i and the keyword node k j , the clause node v' i is the implicit representation of the clause c i .
[0015] Compared with the prior art, the present application uses keywords to enhance the information of the clause representation encoded by BERT, then models the mutual relationship between the sentence pair and the clause, and constructs an undirected heterogeneous graph, so that the information flow between the sentiment clauses, the reason clauses and the two kinds of clauses and the sentence pair is more efficient, fully plays the promoting role of the sentiment clauses and the reason clauses on the extraction of the sentiment reason pair, solves the problem that the prior art is not sensitive to long text, and the problem that the task targets of the multi-task model are unified and the errors are transmitted between different sub-tasks.
[0016] Further, the step S10 comprises: obtaining the intermediate implicit representation of all clauses in the document D using the BERT model, and establishing the interaction between the clauses using the graph attention network based on the intermediate implicit representation of the clauses to obtain the implicit representation of each clause.
[0017] Further, the representation of the sentiment reason clause pair in the step S20 is:
[0018] p ij =W p [ E i ;C j ] +r i-j + b p
[0019] wherein, W p and b p are trainable parameters, b p is a bias value, r i-j is a relative position, E i and C j respectively represent the sentiment clause and the reason clause.
[0020] Further, the step S30 comprises full connection between the sentiment clause nodes, full connection between the reason clause nodes, and connecting the sentiment-reason pair nodes with the corresponding sentiment clause nodes and reason clause nodes respectively to construct an undirected heterogeneous graph; and using a relational graph convolutional neural network to encode and aggregate the relationship between the nodes in the undirected heterogeneous graph to obtain the final representation of the sentiment-reason pair.
[0021] Further, the method further comprises a step S40 of obtaining the final representation of the sentiment clause and the reason clause, comparing the prediction results of the sentiment clause, the reason clause and the sentiment-reason pair with the real labels, and adjusting the probability threshold according to the comparison result.
[0022] The final representation of the sentiment clause or the reason clause is used as a query statement, and the adjusted probability threshold is used to repeat the steps S20-S40.
[0023] Further, the trainable parameters in the sentiment-reason pair extraction method are trained through the following steps:
[0024] The loss between the sentiment clause prediction result and the sentiment clause real label is calculated to obtain a sentiment clause loss.
[0025] The loss between the reason clause prediction result and the reason clause real label is calculated to obtain a reason clause loss.
[0026] The loss between the sentiment-reason pair prediction result and the sentiment-reason pair real label is calculated to obtain a sentiment-reason pair loss.
[0027] The sentiment-reason pair loss, the sentiment clause loss and the reason clause loss are multiplied by different loss coefficients and then added to obtain a total loss.
[0028] The trainable parameters in the sentiment-reason pair extraction method are adjusted through the total loss until the total loss converges.
[0029] The application also provides a sentiment-reason pair extraction device, comprising:
[0030] A pre-training unit obtains clauses and keywords of a target text, encodes the clauses by using BERT to obtain the implicit representation of each clause in the text, and updates the implicit representation of the clauses using the information of the keywords, which comprises: taking the union of the keywords and an external knowledge base to form a keyword set, updating the implicit representation of the clauses based on the keyword set to obtain a clause representation enhanced by keyword semantics.
[0031]
[0032] In the formula, v i for the clause nodev’ i characterized in that, represents a keyword node k j representation, is a weighted addition of keyword representations for generating a smaller granularity keyword semantic enhanced clause representation, wherein, is a trainable parameter, |D| is the number of clauses in the target text, b is a bias term, and the attention weight a ij is an edge weight between a clause node v' i and a keyword node k j is an implicit representation of a clause v' i . c i .
[0033] The sentiment reason extraction unit extracts all sentiment clause representations and reason clause representations according to a preset probability threshold and the keyword semantic enhanced clause representation, and pairs the sentiment clause representations and the reason clause representations to obtain a representation of a sentiment reason clause pair.
[0034] The result obtaining unit constructs a relation graph convolutional neural network using the clause representation and the clause pair representation, and obtains a sentiment reason pair extraction result based on the relation graph convolutional neural network.
[0035] The application further provides a computer device, which comprises a processor and a memory.
[0036] The memory is used for storing a computer program and transmitting the computer program to the processor.
[0037] The processor is used for executing the sentiment reason pair extraction method based on machine question answering and joint coding according to instructions in the computer program.
[0038] The application further provides a computer readable storage medium, which is used for storing a computer program, and the computer program causes a processor to execute the sentiment reason pair extraction method based on machine question answering and joint coding when the processor executes the computer program.
[0039] In order to better understand and implement, the application will be described in detail below with reference to the drawings. BRIEF DESCRIPTION OF DRAWINGS
[0040] Figure 1 is a schematic diagram of the sentiment reason pair extraction model based on machine question answering and joint coding of the application.
[0041] Figure 2This is a flowchart illustrating the sentiment reason pair extraction method based on machine question answering and joint coding, according to an embodiment of the present invention.
[0042] Figure 3 This is a schematic diagram of the structure of the emotional reason extraction device according to an embodiment of the present invention.
[0043] Figure 4 This is a flowchart illustrating the training method for the sentiment reasoning extraction method based on machine question answering and joint encoding.
[0044] Figure 5 This is a schematic diagram of the training device for the emotion reasoning extraction device based on machine question answering and joint coding.
[0045] Figure 6 for Figure 4 The flowchart of step S50 in the training method shown is illustrated.
[0046] Figure 7 for Figure 5 A schematic diagram of the structure of the second training unit 50 of the training device shown. Detailed Implementation
[0047] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings.
[0048] This invention addresses the issue of insufficient accuracy in existing sentiment cause pair extraction methods within the field of natural language processing. It argues that current methods fail to fully leverage the facilitating effects of the two subtasks and sentiment cause pairings on the extraction task, lacking interaction and collaboration between tasks. On one hand, some texts lack corresponding causal clauses as context for the sentiment, potentially failing to detect certain sentiment clauses. On the other hand, limited interaction between the sentiment cause pair extraction task and its subtasks may prevent the task from fully learning the causal relationship between sentiment and causal clauses, thus deleting some sentiment cause pairs with unclear causal relationships. Furthermore, existing methods restrict the distance between clauses when pairing sentiment and causal clauses, focusing primarily on clauses close to the target text while neglecting relationships between distant clauses. Therefore, in some application scenarios, these sentiment cause pairs may be missed, such as in long texts where the sentiment and cause are far apart, containing a large amount of irrelevant information. In addition, existing methods suffer from poor clause expressiveness and a lack of external knowledge incorporation, leading to inaccurate identification of sentiment and causal clauses during extraction.
[0049] Further, the existing emotion cause pair extraction method has the problem of inconsistent task objectives among multiple subtasks, that is, each subtask is optimized separately without combining information of other subtasks in the process of model training and optimization.
[0050] Based on the above-mentioned problems found in the research, the present application provides an emotion cause pair extraction method capable of improving interaction and cooperation among tasks and enhancing semantic features of clauses, thereby improving the precision and recall rate of emotion cause pair extraction, as shown in Figure 1 . The emotion cause pair extraction method comprises:
[0051] Step S10: obtaining clauses and keywords of a target text, performing BERT encoding on the clauses to obtain implicit representations of the clauses in the text, and updating the implicit representations of the clauses using information of the keywords to obtain clause representations enhanced in keyword semantics;
[0052] Step S20: extracting all emotion clause representations and cause clause representations according to a preset probability threshold and the clause representations enhanced in keyword semantics, pairing the emotion clause representations and the cause clause representations, and obtaining representations of emotion cause clause pairs;
[0053] Step S30: constructing a relation graph convolutional neural network using the clause representations and the representations of clause pairs, and obtaining emotion cause pair extraction results based on the relation graph convolutional neural network.
[0054] Meanwhile, based on the above-mentioned emotion cause pair extraction method, the present application further provides an optimization training method for trainable parameters involved in the emotion cause pair extraction step.
[0055] In addition, in order to more clearly understand the technical solutions provided by the embodiments of the present application, some key terms involved in the embodiments of the present application are introduced first:
[0056] Emotion Cause Pair Extraction (ECPE): aims to extract all possible emotion cause sentence pairs composed of emotions and their corresponding reasons. Emotion cause sentence pair extraction can be described as: given a text containing n clauses (C1,…,C n ) where C i represents the i-th clause. Emotion cause pair extraction aims to identify each emotion cause pair (C emo ,C cau ), where the cause clause C cau is the corresponding reason for the emotion clause C emo .
[0057] Attention Mechanism is a method that simulates human visual and cognitive systems, allowing neural networks to focus on relevant parts when processing input data. By introducing attention mechanisms, neural networks can automatically learn and selectively focus on important information in the input, improving model performance and generalization ability.
[0058] Graph Attention Networks (GAT): Graph Attention Networks introduce attention mechanisms into spatial domain-based graph neural networks.
[0059] Relational Graph Convolutional Network (RGCN): Used to process graph data with multiple relationship (edge) types to better simulate entities and their complex relationships in the real world. RGCN can be applied to various tasks such as knowledge graph reasoning, social network analysis, drug discovery, etc. RGCN performs aggregation operations on nodes of different relationship types separately, divides the graph structure into different subgraphs according to different attributes on the edge, aggregates the domain nodes on the subgraphs obtained by division, and then adds the results of different subgraph aggregations to the next layer of network.
[0060] BERT (Bidirectional Encoder Representation from Transformers): BERT is a pre-trained language representation model. It uses a new Masked Language Model (MLM) for pre-training to generate deep bidirectional language representations.
[0061] Token: For models, token is a digital representation. Each token is associated with a unique numerical ID, and the model distinguishes different tokens through these IDs. During training, the model learns the method of mapping text to these numerical IDs, so as to be able to encode and decode new text.
[0062] Cross Entropy Loss: is a commonly used loss function in deep learning and machine learning, especially in handling classification problems. It measures the difference between the model's predicted probability distribution and the true probability distribution.
[0063] Bipartite Graph or two-part graph is a special graph. Bipartite graph can be defined as: if the vertex set V of a graph G=(V,E) can be divided into two disjoint sets A and B (i.e. A∩B=∅), and each edge (i,j) in the graph connects two vertices i and j belonging to the two different vertex sets A and B (i.e. i∈A,j∈B or i∈B,j∈A), then the graph G is called a bipartite graph.
[0064] The MRC (Machine Reading Comprehension) framework can specifically refer to: given a question (or can be called query), finding the answer to the given question in the document by understanding the content of the document. For example, when extracting sentiment sentences from a document, a sentiment query sentence "find sentiment sentences" can be given, and all document sentences in the document are classified based on the sentiment query sentence. The document sentences with the sentiment label (for example, "1") in the classification result are sentiment sentences, i.e. the document sentences with the sentiment label in the classification result are the answers to the sentiment query sentence. The document sentences with the non-sentiment label (for example, "0") in the classification result are non-sentiment sentences, i.e. the document sentences with the non-sentiment label in the classification result are not the answers to the sentiment query sentence.
[0065] Based on the above introduction of the related key terms, the sentiment reason pair extraction method of the embodiment of the application is specifically explained by the following two parts.
[0066] (I) sentiment reason pair extraction part
[0067] The embodiment provides a sentiment reason pair extraction method based on machine question answering and joint encoding. Referring to Figure 2 and Figure 3 , Figure 2 is a flowchart of the sentiment reason pair extraction step of the embodiment, Figure 3 is a structural schematic diagram of the sentiment reason pair extraction device of the embodiment. The sentiment reason pair extraction device of the embodiment includes a pre-training unit 10, a sentiment reason pair extraction unit 20, and a result acquisition unit 30.
[0068] The pre-training unit 10 of the sentiment reason pair extraction device is used to perform step S10: obtaining the clauses and keywords of the target text, performing BERT encoding on the clauses to obtain the implicit representation of each clause in the text; updating the implicit representation of the clause using the information of the keyword to obtain the keyword semantic enhanced clause representation. Specifically, the pre-training unit 10 includes a data acquisition module 11a, a keyword acquisition module 11b, a first graph attention module 12, and a second graph attention module 13.
[0069] The data acquisition module 11a is used to perform step S11a: using the BERT model to obtain the intermediate implicit representations of all clauses in document D.
[0070] For a given document D=(c1,c2,…,c...) consisting of n clauses n ), where each clause c i =(w i1 ,w i2 ,…,w iM The input sequence consists of M words. Insert [CLS] at the beginning of each clause and [SEP] between every two clauses to construct the corresponding input sequence:
[0071]
[0072] in, wqi For query statement cq The i-th word, query statement cq This includes whether it is a sentiment statement or a causal statement.
[0073] Then the BERT model is used to process the input sequence. DI Encode the clause to obtain its intermediate implicit representation. HI :
[0074]
[0075] in, d is the dimension of the hidden state. c' i for clause c i The implicit representation of .
[0076] Specifically, the BERT model is first used to obtain the implicit representations of all tokens in the clauses of document D. Then, the implicit representations of the tokens in each clause, excluding the tags [CLS] and [SEP], are averaged to obtain the intermediate implicit representations of the clauses.
[0077] The keyword acquisition module 11b is used to perform step S11b: acquire the keyword set of the target text.
[0078] The TextRank algorithm is used to extract the document D=(c1,c2,…,c n The key phrases in the text are used, and the externally introduced commonsense knowledge base Concept Net is used as the sentiment dictionary. The union of the key phrases and the sentiment dictionary is used as the keyword set to help the implicit representation of the clause highlight the potential causal features, thereby obtaining a more granular clause representation.
[0079] The first graph attention module 12 is used to perform step S12: based on the intermediate implicit representation of the clauses, a graph attention network is used to establish the interaction between clauses to obtain the implicit representation H of each clause.
[0080] H = GAT ( H I ) = { v' 1, v' 2,…, v' n}
[0081] in, v’ i Is a clause c i The implicit representation of .
[0082] Specifically, based on a given document D The intermediate hidden representation obtained after BERT encoding H I ,Will H I Implicit representation of each clause in the middle c' i As nodes, construct clause graphs ,in, v’ c For a set of nodes, ξ c For the set of edges, use clauses c i The implied meaning in the middle c' i Initialize the clause nodes to obtain the clauses in the clause graph. c i The corresponding clause node is v 0 i In a clause graph, each node has a directly adjacent edge to every other node, and each node has a self-loop edge.
[0083] Then, a graph attention network is used to propagate clause information, enabling each clause to learn contextual semantic information: for each clause node, an attention mechanism is used to assign an attention coefficient to each neighboring node of the clause node to reflect the importance of the neighboring nodes to the current clause node. Then, the information of each neighboring node of the clause node is weighted and aggregated to the clause node through the attention coefficient. The representation of the current clause node is updated through multiple superimposed graph attention layers, and finally the implicit representation H of the clause is obtained.
[0084] Specifically, in each layer of the graph attention network, the attention coefficients between clause nodes and their neighboring nodes are calculated:
[0085]
[0086] in, a ij Let represent the attention coefficient between clause node i and its neighboring node j, where N is the set of all neighboring nodes of node i. v t-1 This represents the clause node of the (t-1)th level. LeakyReLU This represents the activation function.
[0087] Based on the attention coefficient, the information of each neighboring node connected to the clause node is aggregated into the clause node in a weighted manner to update the clause node. The clause node in layer t is represented as follows:
[0088]
[0089] Where N is the set of all neighboring nodes of node i, and the current layer is layer t. This represents the output of the previous level of the adjacent node j. For trainable parameters, b This is the bias value. Let be the attention coefficients between clause node i and its neighboring node j at layer t. ReLU The function is the activation function.
[0090] clause c i The representation of the last-level node serves as the implicit representation of the final clause. v’ i .
[0091] The second graph attention module 13 is used to perform step S13: based on the keyword set, update the implicit representation of the clause to obtain a keyword semantically enhanced clause representation.
[0092] Among them, based on a given document D The implicit representation of H = GAT ( H I ), to represent the implicit representation of each clause in H. v' i As a clause node, each keyword in the keyword set k j As keyword nodes, construct the clause keyword bipartite graph G of document D. b =(V;E b ), where V=V c ∪V kV represents a node set consisting of clause nodes and keyword nodes. k ={k1;k2;…;k m} indicates that document D contains m keywords, V c ={ v' 1; v' 2;…; v' |D|} indicates that document D has a |D| clause, E b ∈R |D|×m This represents the adjacency matrix of co-occurrence of clause keywords, i.e., establishing edges between each clause node and each keyword node. Since clauses are short, many keywords appear only once in a single clause, therefore E b Most of the elements e ij The value is 1, indicating that the adjacency matrix based on the co-occurrence of clause keywords is relatively sparse.
[0093] Based on a clause keyword bipartite graph, a graph attention mechanism is used to measure the document-level keyword preference of each clause to reflect the importance of the current keyword to the clause. Using the clause node as the central node, the information of the keyword nodes connected to the central node is weighted and aggregated based on the attention weights between them, thus updating the clause node and obtaining a more granular keyword semantically enhanced clause representation. The keyword semantically enhanced clause representation is shown below:
[0094]
[0095] in, Represents the key node k j The expression, It is a weighted sum of keyword representations, used to generate more granular keyword semantically enhanced clause representations. These are trainable parameters, b is the bias term, and the attention weights are... a ij For clause nodes in the document v' i and keyword nodes k j The edge weights between them are shown below:
[0096]
[0097] in v i and k j These are clause nodes. v' i Feature and Keyword Nodes k j The characteristics of [·] are that [·] is a concatenation operation. and are trainable parameters.
[0098] Further, the emotion-cause pair extraction unit 20 is configured to perform step S20: extracting all emotion clause representations and cause clause representations according to the preset probability threshold and the keyword semantic enhanced clause representation, and pairing the emotion clause representations and the cause clause representations to obtain the representation of the emotion-cause clause pair. The emotion-cause pair extraction unit 20 includes a clause extraction module 21 and a clause pairing module 22.
[0099] The clause extraction module 21 is configured to perform step S21: judging the keyword semantic enhanced clause representation according to the query statement by calling the preset corresponding probability threshold, and outputting emotion clause representations E 1, E 2, …, E n}= H E and cause clause representations C 1, C 2, …, C n}= H C , respectively, are the emotion representation of the i-th clause and the cause representation of the j-th clause. E i , C j .
[0100] Specifically, the keyword semantic enhanced clause representation is judged by calling the first preset probability threshold τ E and the second preset probability threshold τ C , respectively. If the probability that the clause is an emotion clause is greater than the first preset probability threshold τ E , the clause is output as an emotion clause E i . If the probability that the clause is a cause clause is greater than the second preset probability threshold τ C , the clause is output as a cause clause C i . Since the emotion information and the cause information of a clause are contained in different words, the clause is divided into emotion clauses and cause clauses according to different words. An emotion clause may contain emotion information and cause information at the same time, so a clause can be an emotion clause, a cause clause of another emotion clause, or even a cause clause of itself, that is, a clause can be both an emotion clause and a cause clause. Therefore, if the probability that the clause is an emotion clause is greater than the first preset probability threshold τ E , and the probability that the clause is a cause clause is greater than the second preset probability threshold τ C .If the clause satisfies the above conditions, the clause is output as both an emotion clause and a reason clause; otherwise, the clause is removed.
[0101] The clause pairing module 22 is configured to perform step S22: using a pair generator to concatenate the emotion clause and the reason clause to obtain a representation of a candidate emotion-reason clause pair H p ={ p 11 , p 12 ,…, p nn} where the candidate emotion-reason clause pair p ij is expressed as:
[0102] p ij =W p [ E i ;C j ] +r i-j + b p
[0103] wherein W p and b p are trainable parameters, b p is a bias value, r i-j is a relative position, E i and C j represent the emotion clause and the reason clause, respectively.
[0104] Further, the result obtaining unit 30 of the emotion-reason pair extraction device is configured to perform step S30: constructing a relation graph convolution network using the clause representation and the clause pair representation, and obtaining an emotion-reason pair extraction result based on the relation graph convolution network. Specifically, the result obtaining unit 30 includes a relation graph convolution module 31 and a prediction module 32.
[0105] The relation graph convolution module 31 is configured to perform step S31: encoding and aggregating the relationships between different clauses and between clauses and sentence pairs through the relation graph convolution neural network to obtain a final representation of the emotion-reason pair.
[0106] wherein the representation of the sentiment clause is taken as the initial state of the sentiment clause node, the representation of the cause clause is taken as the initial state of the cause clause node, and the representation of the sentiment-cause pair is taken as the initial state of the pair node, a directed heterogeneous graph, i.e., a relational graph convolutional neural network, is constructed. Specifically, the sentiment clause node is initialized, the cause clause node is initialized, and the pair node is initialized, respectively, as = H E , = H C = H p In addition, the document node is initialized using the average pooling of the semantic enhancement of the keywords of all clauses of the document D: Full connection is performed between the sentiment clause nodes and the cause clause nodes, and the pair nodes are connected with the corresponding sentiment clause nodes and cause clause nodes, respectively, to construct the directed heterogeneous graph.
[0107] Therefore, the directed heterogeneous graph includes the edges of the sentiment clause-sentiment clause connection, the edges of the cause clause-cause clause connection, the edges of the sentiment clause-pair connection, and the edges of the cause clause-pair connection, and each pair node has two edges. Among them, the edges of the clause-clause connection are used to learn the context information between other sentiment clauses or cause clauses, and the edges of the clause-pair connection are used to form the interaction of the pair and the clause, so that the sentiment clause node and the cause clause node pass the causal relationship to the pair node, and the pair node serves as a bridge connecting the two clause nodes of the pair node, so that the corresponding sentiment clause node and cause clause node interact through the two edges of the pair node.
[0108] Further, the relational graph convolutional neural network is used to encode and aggregate the relationship between the nodes in the directed heterogeneous graph to obtain the final representation of the sentiment-cause pair.
[0109] Specifically, according to the directed heterogeneous graph, for each node, the information of its adjacent nodes is aggregated by the following formula to update the node representation:
[0110]
[0111]
[0112]
[0113] wherein, represents the hidden state of the node u in the first l+ 1 layer, R is the edge of different types, is a trainable parameter, and N r (u) represents the neighbor node of the node u connected with the edge of type r. ReLU is ReLU an activation function.
[0114] After the convolution operation of the θ-layer RGCN, the hidden state of the node in the last layer of the RGCN is selected as the final representation of the clause pair. Among them, the i-th node in the undirected heterogeneous graph can be represented as , that is, after the training of the θ-layer RGCN, the final representation of the clause pair p ij is , the final representation of the clause C i or E i is .
[0115] Therefore, After the operation of the relational graph convolutional neural network, the final representations of the sentiment clause, the reason clause and the sentiment-reason pair are obtained as follows: E = , C = , P = = , , } and the final representation of the sentiment-reason pair is taken as the candidate sentiment-reason pair.
[0116] The prediction module 32 is used to perform step S32: generating a sentiment-reason pair extraction result by a classifier (classifier) through the final representation of the sentiment-reason pair.
[0117] Specifically, the final representation P of the sentiment-reason pair, the final representation E of the sentiment clause and the final representation C of the reason clause are multiplied by a matrix, and then the matrix multiplication result is input into a softmax activation function to obtain a sentiment-reason pair prediction result, and all sentiment-reason pairs of the text are screened out according to the prediction result, wherein the expression of the sentiment-reason pair prediction result is as follows:
[0118] = softmax(PEC)
[0119] wherein, is a sentiment-reason pair prediction label, indicating the prediction probability that the sentiment clause i and the reason clause j are a sentiment-reason pair, and softmax is an activation function that maps a set of real values to a probability distribution. A threshold of 0.5 is used to determine whether the clause pair is a sentiment-reason pair.
[0120] The sentiment-reason pairs with >0.5 are retained as the final sentiment-reason pair extraction result and output.
[0121] The embodiment also provides a computer readable storage medium, which stores a computer program, and the program is executed by a processor to implement the steps of the emotion cause pair extraction method based on machine question answering and joint coding.
[0122] The embodiment provides a computer device, which comprises a memory, a processor and a computer program stored in the memory and executable on the processor, and the processor implements the steps of the emotion cause pair extraction method based on machine question answering and joint coding when executing the program.
[0123] Compared with the prior art, the emotion cause pair extraction method constructs a coarse-grained semantic perception graph, that is, a fully connected clause graph is established based on a graph attention mechanism for all clauses, each node is a clause, and the node can learn all context text information without being affected by the text distance by being connected with other nodes, thereby avoiding the problem that the prior method is not sensitive to long text. In addition, the emotion and the cause can appear in the same clause, therefore, a self-loop edge is added to each node in the clause graph, so that each node learns the information of the node itself. Then, a multi-layer stacked attention layer is used to strengthen the learning of the context text information by the clause.
[0124] The emotion cause pair extraction method also constructs a fine-grained semantic perception graph, that is, the keywords in the document are extracted using external knowledge, and then a bipartite graph of clause keywords is constructed, the clause implicit representation obtained by the clause graph is subjected to keyword semantic enhancement through the clause keyword bipartite graph, and the semantics of the clause is further enhanced, thereby enhancing the sensitivity of the clause to long text.
[0125] Further, the emotion cause pair extraction method pairs the keyword semantic enhanced emotion clause and the cause clause, establishes a relationship graph convolutional neural network of the emotion clause, the cause clause and the emotion cause pair, and based on the relationship graph convolutional neural network, the emotion clause, the cause clause and the emotion cause pair are jointly learned, thereby further solving the problem that the prior emotion cause pair extraction method ignores the relationship between distant clauses and is not sensitive to long text.
[0126] Further, the emotional reason pair extraction method of the present application jointly encodes the extraction method using a graph neural network, takes the emotional clause, the reason clause, the sentence pair and the document as nodes, and connects them through corresponding edges to construct an undirected heterogeneous graph, i.e., a relationship graph convolutional neural network, so that the sentence pair can learn the information of the corresponding clause node through the edge, the document node can enhance the global information, in addition, the emotional clause node can learn the information of all emotional clause nodes, the reason clause node can learn the information of all reason clause nodes, and the emotional clause node and the reason clause node can also interact through the corresponding sentence pair, thereby enhancing the learning of the causal relationship between the clauses, thereby solving the problem that the existing emotional reason pair extraction method has inconsistent goals between multiple subtasks and error transmission between different subtasks.
[0127] (II) Training part
[0128] The emotional reason pair extraction method based on machine question answering and joint encoding described in the present embodiment also includes a training method, which is described in detail below. Figure 4 Figure 4 The training method based on the above emotional reason pair extraction is shown in the flowchart, and the training method mainly includes the following steps:
[0129] Step S40: Compare the final representation of the emotional clause, the reason clause and the emotional reason pair with the real label, and adjust the probability threshold.
[0130] Step S50: Calculate the loss corresponding to the emotional clause prediction result, the reason clause prediction result and the emotional reason pair prediction result, and update the emotional reason pair extraction model using the loss.
[0131] The present embodiment also provides a training device for the emotional reason pair extraction. Refer to Figure 5 Figure 5 The structure of the training device based on the above emotional reason pair extraction is shown in the schematic diagram. The training device includes a first training unit 40 and a second training unit 50, the first training unit 40 is used to adjust the probability threshold of the clause extraction module 21 in the emotional reason pair extraction device, and the second training unit 50 is used to optimize and train the trainable parameters in the first graph attention module 12, the second graph attention module 13, the clause pairing module 22 and the relationship graph convolution module 31 in the emotional reason pair extraction device.
[0132] The first training unit 40 is used to perform step S40: compare the prediction results of the emotional clause, the reason clause and the emotional reason pair with the real label, and adjust the probability threshold according to the comparison result;
[0133] Specifically, the final representation of each emotional clause is used to generate an emotional clause prediction result through an emotional classifier:
[0134] =softmax(E)
[0135] The final representation of each cause clause is passed through a cause classifier to produce a cause clause prediction result:
[0136] =softmax(C)
[0137] The prediction results of the sentiment clause and the cause clause are then compared with the true labels of the sentiment clause and the cause clause respectively. If there are more misjudgments of the sentiment sentence or the cause sentence in the comparison results, the first preset probability threshold or the second preset probability threshold is adjusted upward, otherwise the opposite; meanwhile, the prediction results of the sentiment-cause pair are compared with the true labels of the sentiment clause and the cause clause. If there are sentence pairs in which a sentiment clause is recognized but a cause clause is not recognized, or a cause clause is recognized but a sentiment clause is not recognized, the mapping parameters are adjusted.
[0138] Further, the sentiment clause prediction result or the cause clause prediction result is taken as a query sentence, and the adjusted probability threshold is used to re-judge the cause clause or the sentiment clause in steps S20-S40 and adjust the probability threshold.
[0139] Specifically, the cause clause or the sentiment clause is taken as a query sentence for the second round of query, and steps S20-S40 are repeated to re-identify the clauses of the text using the adjusted probability threshold and the mapping parameters, to obtain new sentiment clauses and cause clauses in parallel, to obtain new sentiment-cause pairs through the new relationship graph convolutional neural network, to use the true labels to evaluate the effectiveness of the new clauses and the sentence pairs, and to adjust the probability threshold and the mapping parameters again according to the new evaluation results.
[0140] In the second round of query, the cause clause is used as a query to verify the effectiveness of the candidate pair with a rethinking mechanism in the embodiment, which specifically includes: C j generating a cause clause C j corresponding to the sentiment query sentence, such as "finding the cause clause C j corresponding to the sentiment clause", based on the sentiment query sentence, performing sentiment clause prediction on each clause in the document to obtain a sentiment clause prediction probability of each clause, extracting an updated sentiment clause E i according to the updated first preset probability threshold E i in parallel with the given cause clause C j to generate a new sentiment-cause pairP ij , the updated sentiment clause E i , the given cause clause C j , the new sentiment-cause pair P ij After convolution processing, the obtained clause and sentence pair results are compared with the true labels, and the size of the probability threshold is adjusted according to the comparison result.
[0141] Further, referring to Figure 6 and Figure 7 , the second training unit 50 is configured to perform step S50: calculating the loss corresponding to the sentiment clause prediction result, the cause clause prediction result and the sentiment-cause pair prediction result, and updating the sentiment-cause pair extraction model using the loss. Specifically, the second training unit 50 includes a sentiment-cause pair loss calculation module 51, a sentiment clause loss calculation module 52, a cause clause loss calculation module 53, a loss summary module 54 and a parameter adjustment module 55.
[0142] The sentiment-cause pair loss calculation module 51 is configured to perform step S51: calculating the loss between the sentiment-cause pair prediction result and the sentiment-cause pair true label, obtaining the sentiment-cause pair loss L P .
[0143] Wherein, the cross-entropy loss function is selected to calculate the loss between the sentiment-cause pair prediction result and the sentiment-cause pair true label, and the expression of the sentiment-cause pair loss L P
[0144]
[0145] Wherein, is the sentiment-cause pair prediction label, is the sentiment-cause true label.
[0146] The sentiment clause loss calculation module 52 is configured to perform step S52: calculating the loss between the sentiment clause prediction result and the sentiment clause true label, obtaining the sentiment clause loss L P .
[0147] Wherein, the cross-entropy loss function is selected to calculate the loss between the sentiment clause prediction result and the sentiment clause true label, obtaining the sentiment clause loss L E
[0148]
[0149] Wherein, is the sentiment clause prediction label, is the sentiment clause true label.
[0150] The cause clause loss calculation module 53 is used to perform step S53: calculate the loss between the cause clause prediction result and the cause clause true label, and obtain the cause clause loss L. C .
[0151] Specifically, the cross-entropy loss function is used to calculate the loss between the predicted result of the cause clause and the true label of the cause clause, resulting in the cause clause loss L. C :
[0152]
[0153] in, Predict labels for cause clauses. The true label for the causal clause.
[0154] The loss aggregation module 54 is used to execute step S54: summarizing the emotional causes of the loss L. P Emotional clause loss L E and cause clause loss L C The total loss L is obtained by summing the results.
[0155] Among them, by applying emotional reasons to the loss L P Emotional clause loss L E and the loss of the cause clause L C The sum of the products multiplied by different loss coefficients is used to assess the impact of emotional factors on the loss L. P Emotional clause loss L E and cause clause loss L C In summary, the expression for the total loss L is:
[0156] .
[0157] Where α represents the effect of emotional factors on the loss L P The loss coefficient; β is the sentiment clause loss L. E The loss coefficient; γ is the cause clause L C The loss coefficient of the loss.
[0158] The parameter adjustment module 55 is used to perform step S55: adjust the trainable parameters of the first graph attention module 12, the second graph attention module 13, the clause pairing module 22 and the relationship graph convolution module 31 in the sentiment reason extraction model through the total loss L until the total loss converges.
[0159] If the total loss L fails to converge, the trainable parameters in the emotion cause pair extraction device are adjusted, and the process returns to steps S10-S30; if the total loss L converges, the training ends.
[0160] Compared with the prior art, the training method of the present application uses an MRC framework containing a rethink mechanism, after modeling the relationship between sentiment clauses and reason clauses and the relationship between sentence pairs through an undirected heterogeneous graph, the preset probability threshold is adjusted according to the comparison result of the prediction result and the true label, then the reason clause or the sentiment clause is used as a query with a rethink mechanism, and is brought into the sentiment reason pair extraction model, the effectiveness of the candidate pair after the probability threshold adjustment is verified, and the preset probability threshold can be further adjusted according to the result, so as to improve the accuracy of the extraction of the sentiment clause and the reason clause, and the MRC framework can enable the sentiment reason pair to better learn the causal relationship between the sentiment clause and the reason clause.
[0161] In addition, compared with the existing two-step method of extracting sentiment reason pairs, the training method of the present application takes the overall task as the target, trains all trainable parameters in the model according to the loss of different subtasks, can better improve the accuracy of the sentiment reason pair extraction model, avoids the error in the first step of the two-step method from being transmitted to the second step, and thus affects the result of the second step.
[0162] Based on the same inventive concept, the present application also provides an electronic device, which can be a server, a desktop computing device or a mobile computing device (for example, a laptop computing device, a handheld computing device, a tablet computer, a netbook, etc.) and the like terminal device. The device includes one or more processors and a memory, wherein the processor is used to execute a program to implement the sentiment reason pair extraction method of the method embodiment; the memory is used to store a computer program executable by the processor.
[0163] Based on the same inventive concept, the present application also provides a computer readable storage medium, corresponding to the above-mentioned image processing method embodiment, the computer readable storage medium has a computer program stored thereon, and the program is executed by a processor to implement the steps of the sentiment reason pair extraction method described in any of the above embodiments.
[0164] The application can take the form of a computer program product implemented on one or more storage media (including but not limited to magnetic storage media, CD-ROMs, optical storage media, etc.) including a program code embodied therein. The computer usable storage media includes permanent and non-permanent, removable and non-removable media, which can be implemented by any method or technology to store information. The information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to: phase change memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read only memory (ROM), electrically erasable programmable read only memory (EEPROM), flash memory or other memory technology, compact disc read only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassette, magnetic tape, magnetic disk storage or other magnetic storage device, or any other non-transmission medium that can be used to store information accessible by a computing device.
[0165] Effect embodiment
[0166] This embodiment uses the Chinese benchmark dataset published by Xia and Ding, which contains 1945 documents containing 2167 sentiment-reason pairs. Each document contains an average of 87.18 sub-sentences. Each sentiment / reason contains an average of 6.08 sub-sentences. Among them, 76 pairs of sentiment-reason pairs overlap with two reasons and the same emotion, and 3 pairs overlap with three reasons and the same emotion. 62.1% of the sentiment-reason pairs are separated by one sentence, 23.6% are adjacent, 10.4% are separated by two sub-sentences, and the remaining 3.9% are separated by more than two sub-sentences.
[0167] In order to verify the effectiveness of the sentiment-reason pair extraction model of the present application, the following baseline models are used in this embodiment for multiple comparison experiments:
[0168] ECPE-2D: A two-dimensional matrix is used to represent the sentiment-reason pair and capture the interaction between different pairs.
[0169] RANKCP: A ranking strategy-based model that extracts sentiment-reason pairs by utilizing the relative distance embedding of sub-sentences.
[0170] UTOS: A sequence labeling tag set based on sentiment-reason index is designed, and a sentiment-reason pair is extracted by a sequence labeling method.
[0171] ISML: This study proposes an end-to-end model based on sliding window multi-label learning to extract pairs.
[0172] EPO-ECPE: A framework is proposed to predict sentiment-cause pairs by extracting sentiment clauses. The framework first predicts sentiment clauses, then obtains true and false sentiment-cause pairs according to the relative distance between sentiment clauses and other clauses, and uses them to improve the training process of sentiment prediction.
[0173] PTN: A label scheme is designed to annotate all sentence pairs, and different labels are used to decode sentiment clauses, cause clauses and sentiment-cause pairs in the document.
[0174] PBJE: A method is designed to extract sentiment-cause pairs using joint encoding, build a heterogeneous graph and learn encoding for clauses and sentence pairs, and finally extract sentiment-cause pairs by jointly learning clauses and sentence pairs.
[0175] Based on the ECPE corpus, the sentiment-cause pair extraction model of the present application is used to extract sentiment-cause pairs, sentiment clauses and cause clauses in each experiment, 90% of the data is randomly selected for training, and the remaining data is used for testing, 10-fold cross-validation is used as the data segmentation strategy, precision P, recall R and F score F1 are used as evaluation indicators for sentiment-cause pair extraction, sentiment clause extraction and cause clause extraction three tasks, run 10 times and report the average results.
[0176] Table 1: Extraction results of different baseline models on ECPE corpus for sentiment-cause pairs, sentiment clauses and cause clauses
[0177]
[0178] Referring to Table 1, Table 1 shows the results of the emotion cause pair extraction task and its two subtasks: emotion clause extraction (Emotion Clause Extraction) and cause clause extraction (Cause Clause Extraction). Compared with other emotion cause pair extraction models, the emotion cause pair extraction model of the present application has obvious advantages, and the advantages of the model of the present application are more prominent in the main task emotion cause pair extraction ECPE and the auxiliary task cause extraction CE. In the auxiliary task cause extraction task CE, compared with the baseline model PBJE, the F1 value and the precision of the model of the present application are improved by 3.21% and 3.55% respectively, and compared with the baseline model ISML, the recall of the model of the present application is improved by 0.35%. In the emotion extraction task EE, although the precision and F1 value of the model of the present application are slightly lower than those of the baseline model EPO-ECPE, the recall is improved, and compared with other baseline models except EPO-ECPE, the precision, recall and F1 value of the model of the present application are significantly improved. In the main task, the model of the present application achieves good improvement, and compared with the best PBJE in the baseline model, the F1 value and the precision of the model of the present application are improved by 3.03% and 2.33% respectively.
[0179] Therefore, the emotion cause pair extraction model of the present application can improve the emotion cause pair extraction task compared with the baseline model, mainly because of the performance enhancement in the cause extraction task, and the reason is that the emotion cause pair extraction model of the present application uses the MRC framework in the present embodiment, and introduces the reconsideration mechanism, and after the joint encoding of the sentence pair and the sub-sentence, the cause sub-sentence is used as a query with a reconsideration mechanism to verify the effectiveness of the candidate pair in the second round of query.
[0180] Further, the present embodiment also verifies the effectiveness of the MRC framework and the relationship graph convolutional neural network through the ablation experiment.
[0181] Table 2 Results of ablation study on benchmark corpus and two subtasks of emotion-cause pair extraction.
[0182]
[0183] Referring to Table 2, W / o MRC represents that the experiment is performed by using a model without the MRC framework, compared with the emotion cause pair extraction model of the present application, the experimental results of W / o MRC show that the overall performance of the model is decreased, which indicates that setting no probability threshold for verification has a certain influence on the accuracy of emotion clauses and cause clauses. W / o RGCN represents that the relationship graph convolutional neural network is removed, and the probability threshold is set for judgment and verification after obtaining the emotion clause representation and the cause clause representation. Compared with W / o MRC (remove the MRC framework), the F1 value of EE and CE of W / o RGCN decreases to a smaller extent, but the F1 value of ECPE also decreases to a certain extent, which indicates that using the relationship graph convolutional neural network to model the sentence pair and the emotion / cause clause can better learn the causal relationship therein.
[0184] In summary, compared with the prior art, the emotion cause pair extraction model of the present application has the advantages that the emotion extraction task performance is excellent, and the reason extraction task and emotion cause pair extraction task performance are significantly improved. On the ECPE benchmark corpus, the emotion cause pair extraction model of the present application achieves better results than the baseline model.
[0185] The above-described embodiments are only preferred embodiments of the present application, and the protection scope of the present application is not limited thereto. Any equivalent replacement or transformation made by those skilled in the art on the basis of the present application is within the protection scope of the present application. The protection scope of the present application is subject to the claims.
Claims
1. A method for extracting emotional reasons based on machine question answering and joint coding, characterized in that, The method comprises the following steps: Step S10: obtaining clauses and keywords of a target text, performing BERT encoding on the clauses to obtain implicit representations of the clauses, and updating the implicit representations of the clauses using information of the keywords to obtain keyword-semantics-enhanced clause representations; Step S20: extracting all sentiment clause representations and cause clause representations according to a preset probability threshold and the keyword-semantics-enhanced clause representations, pairing the sentiment clause representations and the cause clause representations, and obtaining representations of sentiment-cause clause pairs; Step S30: constructing a relational graph convolutional neural network using the clause representations and the representations of the clause pairs, and obtaining a sentiment-cause pair extraction result based on the relational graph convolutional neural network; The step S10 further comprises: taking a union of the keywords and an external knowledge base to form a keyword set, and updating the implicit representations of the clauses based on the keyword set to obtain the keyword-semantics-enhanced clause representations. wherein, v i is a clause node v’ i characterized by, represents a keyword node k j representation, is a weighted sum of keyword representations for generating a smaller granularity keyword semantic enhanced clause representation, wherein, is a trainable parameter, |D| is the number of clauses in the target text, b is a bias term, and the attention weight a ij is an edge weight between a clause node v' i and a keyword node k j in a document, and v' i is an implicit representation of a clause c i .
2. The method of claim 1, wherein, The step S10 comprises: obtaining intermediate implicit representations of all clauses in a document D using a BERT model, establishing interactions between the clauses using a graph attention network based on the intermediate implicit representations of the clauses, and obtaining implicit representations of the clauses.
3. The method of claim 1, wherein, The representations of the sentiment-cause clause pairs in the step S20 are: p ij =W p [ E i ;C j ] +r i-j + b p wherein, W p and b p are trainable parameters, b p is a bias value, r i-j is a relative position, E i and C j respectively represent an emotional clause and a reason clause.
4. The method of claim 1, wherein, The step S30 comprises: performing full connection between sentiment clause nodes, performing full connection between cause clause nodes, connecting sentiment-cause pair nodes with corresponding sentiment clause nodes and cause clause nodes respectively, and constructing an undirected heterogeneous graph; and encoding and aggregating relationships between nodes in the undirected heterogeneous graph using a relational graph convolutional neural network to obtain the sentiment-cause pair extraction result.
5. The method according to any one of claims 1 to 4, characterized in that, The method further comprises step S40: obtaining prediction results of sentiment clauses, cause clauses and sentiment-cause pairs, comparing the prediction results with real labels, and adjusting the probability threshold according to a comparison result. The final representations of the sentiment clauses or the cause clauses are used as query statements, and the step S20 to S40 is repeated using the adjusted probability threshold.
6. The method of any one of claims 1-4, wherein, The trainable parameters in the sentiment-cause pair extraction method are trained through the following steps: calculating a loss between sentiment clause prediction results and sentiment clause real labels to obtain a sentiment clause loss; calculating a loss between cause clause prediction results and cause clause real labels to obtain a cause clause loss; calculating a loss between sentiment-cause pair prediction results and sentiment-cause pair real labels to obtain a sentiment-cause pair loss; multiplying the sentiment-cause pair loss, the sentiment clause loss and the cause clause loss by different loss coefficients and then adding them to obtain a total loss; adjusting the trainable parameters in the sentiment-cause pair extraction method through the total loss until the total loss converges.
7. An emotional cause extraction apparatus characterized by comprising: The device comprises: a pre-training unit configured to obtain clauses and keywords of a target text, perform BERT encoding on the clauses to obtain implicit representations of the clauses, take a union of the keywords and an external knowledge base to form a keyword set, update the implicit representations of the clauses based on the keyword set, and obtain keyword-semantics-enhanced clause representations; wherein, v i is a clause node v’ i characterized by, represents a keyword node k j representation, is a weighted sum of keyword representations for generating a smaller granularity keyword semantic enhanced clause representation, wherein, is a trainable parameter, |D| is the number of clauses in the target text, b is a bias term, and the attention weight a ij is an edge weight between a clause node v' i and a keyword node k j in a document; and v' i is an implicit representation of a clause c i ; The emotion reason extraction unit extracts all emotion clause representations and reason clause representations according to a preset probability threshold and a keyword semantic enhanced clause representation, and pairs the emotion clause representations and the reason clause representations to obtain a representation of an emotion reason clause pair; The result obtaining unit constructs a relation graph convolutional neural network by using the clause representation and the clause pair representation, and obtains an emotion reason pair extraction result based on the relation graph convolutional neural network.
8. A computer device, comprising: The computer device comprises a processor and a memory: The memory is configured to store a computer program and transmit the computer program to the processor; The processor is configured to execute the method according to the instructions in the computer program.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium is configured to store a computer program, and the computer program, when executed by a processor, causes the processor to execute the method according to any one of claims 1-6. The computer readable storage medium is configured to store a computer program, and the computer program, when executed by a processor, causes the processor to execute the method according to any one of claims 1-6.
Citation Information
Patent Citations
Text sentiment analysis method based on hybrid supervision model
CN110321563A
Emotion cause clause pair extraction method based on semantic decision graph neural network
CN113505583A