Aspect emotion triple extraction method and device, equipment and storage medium
By constructing a combination method of hypergraph relationship matrix and coding representation, the interactive information between aspect words and perspective words is captured, and the problems of inaccurate and inefficient extraction results in the prior art are solved, and more efficient and accurate aspect emotion triple extraction is achieved.
Patent Information
- Application Number
- CN202411643298.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-04-25
- Estimated Expiration
- 2044-11-18
AI Technical Summary
The existing aspect emotion triple extraction method based on generative model failed to effectively model the connection between aspect words and opinion words, resulting in inaccurate and inefficient extraction results.
By constructing a hypergraph relationship matrix of the sentence to be tested, hypergraph information is extracted in combination with the coding representation of the sentence, the interactive information between aspect words and opinion words is captured, and boundary-sensitive relationship perception prompt representation is obtained through word relationship classification and relationship perception, which is used to improve the decoding process.
The extraction accuracy and efficiency of aspect emotion triplets are improved, and the accuracy of fine-grained sentiment analysis tasks is enhanced.
Smart Images

Figure CN119886136A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of natural language processing technology and sentiment analysis, and in particular to a sentiment triple extraction method, device, equipment and storage medium. Background Art
[0002] Aspect-level sentiment triple extraction (ASTE) aims to extract all sentiment triplets in a sentence, which are aspect words, opinion words and the corresponding sentiment polarity.
[0003] Recently, it has become an emerging trend to use generative models such as T5 to complete the ASTE task. This method aims to better utilize the semantic information of the label and effectively solve the problem of error propagation. The current ASTE method based on generative models adopts the Encoder-Decoder structure and follows the following paradigm: predefine a template, then convert the triples into the target sequence according to the fixed template, and finally obtain the sentiment triples from the sequence generated by the model. GAS transforms the sentiment analysis task into a text generation problem and uses a prediction normalization strategy to modify incorrect prediction results; MvP uses a prompt learning method of element order to improve sentiment tuple prediction by aggregating multi-view results; SLGM builds a bidirectional template and introduces a tag-oriented sequence annotation module to enhance the generative model; CONTRASTE uses aspect-based prompts and contrastive learning to improve the performance of the generative model on the ASTE task.
[0004] However, none of these methods effectively models the relationship between aspect words and opinion words. On the one hand, after encoding the input sentence to obtain context information, no further relationship modeling is done for the specific task of ASTE, making it difficult to establish the subtle relationship between aspect words and opinion words. On the other hand, using a simple structured template to pair aspect words and opinion words in the decoding stage cannot fully provide effective relationship information for the decoding process, resulting in inaccurate and inefficient extraction of aspect-sentiment triples. Summary of the invention
[0005] Based on this, the purpose of the present invention is to provide a method, device, equipment and storage medium for extracting aspect emotion triples, by constructing a hypergraph relationship matrix of the sentence to be tested, combining the encoded sentence encoding representation of the sentence to perform hypergraph information extraction, so as to capture the interaction information between aspect words and opinion words and other context words in the sentence to be tested, obtain the sentence hypergraph information representation, perform word pair relationship classification and relationship perception on the sentence hypergraph information representation, further obtain boundary-sensitive relationship perception prompt representation for decoding, and provide relationship perception prompt information for the decoding process, thereby improving the accuracy and efficiency of the extraction of aspect emotion triples, and improving the accuracy of fine-grained sentiment analysis tasks.
[0006] In a first aspect, an embodiment of the present application provides a method for extracting emotion triples, comprising the following steps:
[0007] Obtaining a sentence to be tested and a preset triple extraction model, wherein the sentence to be tested includes a plurality of words, and the triple extraction model includes a sentence encoding module, a hypergraph information extraction module, a relationship perception prompt module, and a triple extraction module;
[0008] Inputting the sentence to be tested into the sentence encoding module for encoding processing to obtain a sentence encoding representation of the sentence to be tested;
[0009] Constructing a hypergraph relationship matrix of the sentence to be tested, wherein the hypergraph association matrix includes relationship vectors between a plurality of nodes and a plurality of hyperedges;
[0010] Inputting the sentence encoding representation and the hypergraph relationship matrix into the hypergraph information extraction module to extract hypergraph information, and obtaining the sentence hypergraph information representation of the sentence to be tested;
[0011] Inputting the sentence hypergraph information representation into the relationship perception prompt module to perform word pair relationship classification and relationship perception, and obtaining the relationship perception prompt representation of the sentence to be tested;
[0012] The sentence encoding representation and the relationship perception prompt representation are input into the triple extraction module to perform triple extraction, and the aspect emotion triple extraction result of the sentence to be tested is obtained.
[0013] In a second aspect, an embodiment of the present application provides a device for extracting emotion triples, including:
[0014] A data acquisition unit, used to obtain a sentence to be tested and a preset triple extraction model, wherein the sentence to be tested includes a plurality of words, and the triple extraction model includes a sentence encoding module, a hypergraph information extraction module, a relationship perception prompt module and a triple extraction module;
[0015] A sentence encoding unit, used for inputting the sentence to be tested into the sentence encoding module for encoding processing to obtain a sentence encoding representation of the sentence to be tested;
[0016] A matrix construction unit, used to construct a hypergraph relationship matrix of the sentence to be tested, wherein the hypergraph association matrix includes relationship vectors between a plurality of nodes and a plurality of hyperedges;
[0017] A feature extraction unit, used for inputting the sentence encoding representation and the hypergraph relationship matrix into the hypergraph information extraction module to extract the hypergraph information and obtain the sentence hypergraph information representation of the sentence to be tested;
[0018] A relationship perception unit, used for inputting the sentence hypergraph information representation into the relationship perception prompt module to perform word pair relationship classification and relationship perception, and obtain the relationship perception prompt representation of the sentence to be tested;
[0019] The triple extraction unit is used to input the sentence encoding representation and the relationship perception prompt representation into the triple extraction module to perform triple extraction and obtain the aspect emotion triple extraction result of the sentence to be tested.
[0020] In a third aspect, an embodiment of the present application provides a computer device comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method for extracting aspect emotion triples as described in the first aspect are implemented.
[0021] In a fourth aspect, an embodiment of the present application provides a storage medium storing a computer program, which, when executed by a processor, implements the steps of the method for extracting aspect emotion triples as described in the first aspect.
[0022] In an embodiment of the present application, a method, apparatus, device and storage medium for extracting aspect-emotion triples are provided. A hypergraph relationship matrix of a sentence to be tested is constructed, and hypergraph information is extracted in combination with the encoded sentence encoding representation of the sentence to capture the interaction information between aspect words, opinion words and other context words in the sentence to be tested, and a sentence hypergraph information representation is obtained. Word pair relationship classification and relationship perception are performed on the sentence hypergraph information representation, and a boundary-sensitive relationship-aware prompt representation is further obtained for decoding, providing relationship-aware prompt information for the decoding process, thereby improving the accuracy and efficiency of the extraction of aspect-emotion triples and improving the accuracy of fine-grained sentiment analysis tasks.
[0023] For better understanding and implementation, the present invention is described in detail below with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 A schematic diagram of a process for extracting aspect emotion triples provided in one embodiment of the present application;
[0025] Figure 2 A schematic diagram of the process of S3 in the aspect emotion triple extraction method provided by one embodiment of the present application;
[0026] Figure 3 A schematic diagram of the process of S4 in the aspect emotion triple extraction method provided by one embodiment of the present application;
[0027] Figure 4A schematic diagram of the process of S41 in the aspect emotion triple extraction method provided in one embodiment of the present application;
[0028] Figure 5 A schematic diagram of the process of S5 in the aspect emotion triple extraction method provided by one embodiment of the present application;
[0029] Figure 6 A schematic diagram of the process of S6 in the aspect emotion triple extraction method provided by one embodiment of the present application;
[0030] Figure 7 A schematic diagram of the flow of S7 in the aspect emotion triple extraction method provided by another embodiment of the present application;
[0031] Figure 8 A schematic diagram of the structure of an aspect emotion triple extraction device provided in one embodiment of the present application;
[0032] Fig. 9 A schematic diagram of the structure of a computer device provided for one embodiment of the present application. DETAILED DESCRIPTION
[0033] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0034] The terms used in this application are for the purpose of describing specific embodiments only and are not intended to limit this application. The singular forms of "a", "said" and "the" used in this application and the appended claims are also intended to include plural forms unless the context clearly indicates other meanings. It should also be understood that the term "and / or" used herein refers to and includes any or all possible combinations of one or more associated listed items.
[0035] It should be understood that, although the terms first, second, third, etc. may be used in the present application to describe various information, these information should not be limited to these terms. These terms are only used to distinguish the same type of information from each other. For example, without departing from the scope of the present application, the first information may also be referred to as the second information, and similarly, the second information may also be referred to as the first information. Depending on the context, the words "if" / "if" as used herein may be interpreted as "at the time of" or "when" or "in response to determination".
[0036] See also Figure 1 , Figure 1A schematic diagram of a flow chart of a method for extracting aspect emotion triples provided in an embodiment of the present application, the method comprising the following steps:
[0037] S1: Obtain the sentence to be tested and the preset triple extraction model.
[0038] The executor of the aspect emotion triple extraction method is an extraction device of the aspect emotion triple extraction method (hereinafter referred to as the extraction device). In an optional embodiment, the extraction device can be a computer device, a server, or a server cluster composed of multiple computer devices.
[0039] In this embodiment, the extraction device obtains a sentence to be tested and a preset triple extraction model, wherein the sentence to be tested includes several words, and the triple extraction model includes a sentence encoding module, a hypergraph information extraction module, a relationship perception prompt module and a triple extraction module.
[0040] Specifically, the extraction device may obtain the sentence to be tested input by the user, or may obtain the corresponding sentence to be tested from a preset database, wherein the sentence to be tested includes a number of words, and the sentence expression of the sentence to be tested is:
[0041] x={w1,w2,…,w i ,…,…,w n}
[0042] Where x is the sentence expression of the sentence to be tested, i is the position index of the word, n is the number of words in the sentence to be tested, and w i is the vector representation of the i-th word of the sentence to be tested.
[0043] S2: Input the sentence to be tested into the sentence encoding module for encoding processing to obtain a sentence encoding representation of the sentence to be tested.
[0044] The sentence encoding module can adopt a BERT (Bidirectional Encoder Representation from Transformers) word embedding model or a T5 (Text-to-Text Transfer Transformer) word embedding model to convert a word vector into a corresponding word embedding vector.
[0045] In this embodiment, the extraction device inputs the sentence to be tested into the sentence encoding module for encoding processing to obtain the sentence encoding representation of the sentence to be tested. Specifically, the extraction device inputs the sentence to be tested into the sentence encoding module respectively, maps each word in the sentence to be tested into a low-dimensional vector space, obtains the word embedding vectors of several words of the sentence to be tested as the state vector by querying the pre-trained matrix, combines the state vectors of several words of the sentence to be tested, and constructs the sentence encoding representation of the sentence to be tested.
[0046] S3: Construct a hypergraph relationship matrix of the sentence to be tested.
[0047] In order to fully model the relationship between aspect words and opinion words in the sentence to be tested, in this embodiment, the extraction device constructs a hypergraph relationship matrix of the sentence to be tested for triple extraction to improve the accuracy and efficiency of triple extraction, wherein the hypergraph association matrix includes relationship vectors between a number of nodes and a number of hyperedges.
[0048] See also Figure 2 , Figure 2 The flowchart of S3 in the aspect emotion triple extraction method provided in one embodiment of the present application includes steps S31 to S33, which are specifically as follows:
[0049] S31: Obtain a syntactic dependency graph and dependency label data of the sentence to be tested, and determine dependency edges connecting corresponding words in the syntactic dependency graph according to dependency labels between words in the dependency label data.
[0050] In this embodiment, the extraction device obtains the syntactic dependency graph of the sentence to be tested. Specifically, the extraction device uses the Stanford parser to analyze the sentence to be tested and construct a comprehensive syntactic dependency graph to explore the subtle relationship between the components in the sentence to be tested.
[0051] The extraction device obtains dependency label data, and determines the dependency edges connecting the corresponding words in the syntactic dependency graph according to the dependency labels between the words in the dependency label data. Specifically, the syntactic dependency graph includes a plurality of nodes, and the dependency labels are used to indicate the dependency relationship between the words in the sentence to be tested. The extraction device determines the dependency edges connecting the corresponding words in the syntactic dependency graph according to the dependency label data of the sentence to be tested. i With the word w j There is a dependency relationship, indicating that word w i With the word w j Determine the dependency edges connecting the corresponding words in the syntactic dependency graph.
[0052] S32: Perform grammatical induction processing on the sentence to be tested to obtain the grammatical structure diagram of the sentence to be tested and a plurality of grammatical edges in the grammatical structure diagram; respectively use the words that are connected to the dependency edges and grammatical edges as nodes of the relational hypergraph, and use the dependency edges and grammatical edges as hyperedges of the relational hypergraph to construct the relational hypergraph of the sentence to be tested, transform the relational hypergraph, and obtain the hypergraph relation matrix.
[0053] In this embodiment, the extraction device performs grammatical induction processing on the sentence to be tested to obtain the grammatical structure diagram of the sentence to be tested and a number of grammatical edges in the grammatical structure diagram. Specifically, the extraction device uses the grammatical induction algorithm of the slot constraint method proposed by Dunn to learn the structural pattern to perform grammatical induction processing on the sentence to be tested, so as to extract the grammatical structure of the sentence to be tested, obtain the grammatical structure diagram of the sentence to be tested and a number of grammatical edges in the grammatical structure diagram.
[0054] Each structure is regarded as a hyperedge, and the words contained in the structure are regarded as member nodes of the hyperedge, and each hyperedge can connect multiple nodes according to a certain relationship. The extraction device uses the words that have a connection relationship with the dependency edge and the grammatical edge as nodes of the relationship hypergraph, and the dependency edge and the grammatical edge as hyperedges of the relationship hypergraph, constructs the relationship hypergraph of the sentence to be tested, transforms the relationship hypergraph, and obtains the hypergraph relationship matrix, wherein the hypergraph relationship matrix includes the relationship vectors between a plurality of nodes and a plurality of hyperedges, and the relationship vectors are:
[0055]
[0056] In the formula, Z ij is the relationship vector between the ith node and the jth hyperedge, v i is the i-th node, e j is the jth hyperedge.
[0057] S4: Inputting the sentence encoding representation and the hypergraph relationship matrix into the hypergraph information extraction module to extract hypergraph information, and obtaining the sentence hypergraph information representation of the sentence to be tested.
[0058] In order to further model the context information of the sentence to be tested, in this embodiment, the extraction device inputs the sentence encoding representation and the hypergraph relationship matrix into the hypergraph information extraction module to extract hypergraph information and obtain the sentence hypergraph information representation of the sentence to be tested.
[0059] See also Figure 3 , Figure 3The flowchart of S4 in the aspect emotion triple extraction method provided in one embodiment of the present application includes steps S41 to S42, which are as follows:
[0060] S41: Input the sentence encoding representation and the hypergraph relationship matrix into the hypergraph attention network to extract the attention hypergraph information and obtain the node attention information representation.
[0061] In this embodiment, the extraction device inputs the sentence encoding representation and the hypergraph relationship matrix into the hypergraph attention network to extract attention hypergraph information to capture the high-order interaction information between aspect words and opinion words and other context words in the sentence to be tested, and obtain the node attention information representation.
[0062] The hypergraph attention network includes several graph attention layers; see Figure 4 , Figure 4 The flowchart of S41 in the aspect emotion triple extraction method provided in one embodiment of the present application includes steps S411 to S412, which are specifically as follows:
[0063] S411: Use the sentence encoding representation as the node input representation and node output representation of the first graph attention layer of the hypergraph attention network, and obtain the first attention score data according to the hypergraph relationship matrix, the node output representation and the preset first attention score calculation algorithm.
[0064] In this embodiment, the extraction device uses the sentence encoding representation as the node input representation and the node output representation of the first-layer graph attention layer of the hypergraph attention network, and obtains the first attention score data according to the hypergraph relationship matrix, the node output representation and the preset first attention score calculation algorithm, wherein the first attention score data includes the attention scores between the multiple nodes connected to the multiple hyperedges and the multiple hyperedges; the first attention score calculation algorithm is:
[0065]
[0066] In the formula, α jk is the attention score between the kth node connected to the jth hyperedge and the jth hyperedge, is the output vector of the kth node in the node output representation of the l-1th graph attention layer, MLP(·) is the multi-layer perceptron function, e j is the jth hyperedge, v p is the pth node connected to the jth hyperedge, is the output vector of the pth node in the node output representation of the l-1th graph attention layer; the node input representation of the l-1th graph attention layer of the hypergraph attention network is the node output representation of the l-1th graph attention layer of the hypergraph attention network.
[0067] Specifically, the extraction device determines, according to the hypergraph relationship matrix, several nodes and several nodes in several hyperedges in a set of hyperedges that have a connection relationship, and according to the node input representation of the current graph attention layer of the hypergraph attention network, the node input representation of the current graph attention layer of the hypergraph attention network is used as the node output representation of the previous graph attention layer of the hypergraph attention network, calculates the attention scores between the nodes and the hyperedges, and obtains first attention score data.
[0068] S412: Obtain a hyperedge attention aggregation representation of a plurality of hyperedges according to the hypergraph relationship matrix, the first attention score data, the node input representation, and a preset hyperedge attention aggregation algorithm.
[0069] In this embodiment, the extraction device generates a hyperedge representation by aggregating node information according to the hypergraph relationship matrix, the first attention score data, the node input representation, and a preset hyperedge attention aggregation algorithm, thereby obtaining a hyperedge attention aggregation representation of a plurality of hyperedges, wherein the hyperedge attention aggregation algorithm is:
[0070]
[0071] In the formula, is the hyperedge attention aggregation representation of the jth hyperedge in the lth graph attention layer, σ(·) is the activation function, and v k is the kth node connected to the jth hyperedge, W n is the first weight parameter.
[0072] S413: Obtain second attention score data according to the hypergraph relationship matrix, node output representation, hyperedge attention aggregation representation of a plurality of hyperedges, and a preset second attention score calculation algorithm.
[0073] In this embodiment, the extraction device obtains the second attention score data according to the hypergraph relationship matrix, the node output representation, the hyperedge attention aggregation representation of the plurality of hyperedges, and the preset second attention score calculation algorithm, wherein the second attention score data includes the attention scores between the plurality of hyperedges in the hyperedge set having a connection relationship between the plurality of nodes and the plurality of nodes. The second attention score calculation algorithm is:
[0074]
[0075] In the formula, β ijis the attention score between the jth hyperedge in the hyperedge set that connects the i-th node and the i-th node, ε i is the set of hyperedges connected to the ith node, e p is the jth hyperedge in the hyperedge set that has a connection relationship with the pth node, is the hyperedge attention aggregation representation of the jth hyperedge of the lth graph attention layer, is the output vector of the pth node in the node output representation of the l-1th graph attention layer; the node input representation of the l-1th graph attention layer of the hypergraph attention network is the node output representation of the l-1th graph attention layer of the hypergraph attention network.
[0076] Specifically, the extraction device determines several nodes with connection relationships on several hyperedges according to the hypergraph relationship matrix, and calculates the attention scores between nodes and hyperedges with several hyperedges according to the node input representation of the current graph attention layer of the hypergraph attention network, and the node input representation of the current graph attention layer of the hypergraph attention network is the node output representation of the previous graph attention layer of the hypergraph attention network, and obtains the attention score β ij .
[0077] S414: According to the hypergraph relationship matrix, the second attention score data, the node input representation and the preset node attention aggregation algorithm, the node attention aggregation representation is obtained as the node output representation of the first graph attention layer of the hypergraph attention network and the node input representation of the next graph attention layer, and the calculation is repeated to obtain the node output representation of the last graph attention layer of the hypergraph attention network as the node attention information representation.
[0078] In this embodiment, the extraction device aggregates the information back to the nodes in the hyperedge by aggregating the hyperedge according to the hypergraph relationship matrix, the second attention score data, the node input representation, and the preset node attention aggregation algorithm, to obtain the node attention aggregation representation, wherein the node attention aggregation algorithm is:
[0079]
[0080] In the formula, is the output vector of the i-th node in the node output representation of the l-th graph attention layer, e j is the jth hyperedge in the hyperedge set that has a connection relationship with the i-th node, β ij is the attention score between the jth hyperedge in the hyperedge set that connects the i-th node and the i-th node, W e is the second weight parameter.
[0081] The extraction device uses the node attention aggregation representation as the node output representation of the first graph attention layer of the supergraph attention network and the node input representation of the next graph attention layer, and repeats the calculation to obtain the node output representation of the last graph attention layer of the supergraph attention network as the node attention information representation.
[0082] S42: Input the node attention information representation into the feedforward neural network for information fitting to obtain a node information fitting representation, use the information fitting vectors of several nodes in the node information representation after information fitting as the information vectors of the corresponding words in the sentence to be tested, and obtain the sentence hypergraph information representation.
[0083] In this embodiment, the extraction device inputs the node attention information representation into the feedforward neural network, performs information fitting through several layers of fully connected layers and residual connection layers connected in sequence in the feedforward neural network, obtains the node information fitting representation, and uses the information fitting vectors of several nodes in the node information representation after the information fitting as the information vectors of the corresponding words in the sentence to be tested, to obtain the sentence hypergraph information representation.
[0084] S5: Inputting the sentence hypergraph information representation into the relationship perception prompt module to perform word pair relationship classification and relationship perception, and obtaining the relationship perception prompt representation of the sentence to be tested.
[0085] In order to further obtain boundary-sensitive relationship representation, in this embodiment, the extraction device inputs the sentence hypergraph information representation into the relationship perception prompt module to perform word pair relationship classification and relationship perception, and obtains the relationship perception prompt representation of the sentence to be tested.
[0086] The relationship perception prompt module includes a first multi-layer perceptron network and a second multi-layer perceptron network; see Figure 5 , Figure 5 The flowchart of S5 in the aspect emotion triple extraction method provided in one embodiment of the present application includes steps S51 to S52, which are specifically as follows:
[0087] S51: Adopting the dual affine attention method, according to the sentence hypergraph information representation and the preset relationship probability distribution calculation algorithm, obtain the word pair relationship representation.
[0088] The word pair relationship representation includes relationship probability distribution prediction data of several word pairs, and the relationship probability distribution prediction data includes several types of relationship probability distribution predictions, the type C∈{N,BA,IA,BO,IO,A,O,POS,NEU,NEG}, for {BA,IA,BO,IO}, B and I respectively represent the beginning and the inside of the term, while the sub-labels -A and -O are intended to determine whether the term is an aspect word or an opinion word, and {A,O} are respectively used to indicate whether two different words belong to the same aspect word or opinion word, {POS,NEU,NEG} not only detects whether the word pair matches, but also is used to judge the sentiment polarity of the aspect-opinion pair, POS represents positive, NEU represents neutral, and NEG represents negative. This relationship labeling scheme is proven to be boundary-sensitive, which helps the model to further learn boundary-sensitive word pair relationships.
[0089] In this embodiment, the extraction device adopts a dual affine attention method to obtain a word pair relationship representation according to the sentence hypergraph information representation and a preset relationship probability distribution calculation algorithm, wherein the relationship probability distribution calculation algorithm is:
[0090] R=Biaffine(MLP a (H F ),MLP o (H F ))
[0091] In the formula, R is the word pair relationship representation, Biaffine(·) is the biaffine attention function, and MLP a (·) is the processing function of the first multi-layer perceptron network, MLP o (·) is the processing function of the second multi-layer perceptron network, H F is the hypergraph information representation of the sentence.
[0092] S52: Performing maximum pooling processing on the word pair relationship representation to obtain the word pair relationship representation after maximum pooling processing, and using a gating mechanism to perform information fusion based on the sentence hypergraph information representation and the word pair relationship representation after maximum pooling processing to obtain a relationship-aware prompt representation.
[0093] In this embodiment, the extraction device performs maximum pooling processing on the word pair relationship representation, aggregates the relationship information of each word from the relationship representation related to it, obtains the word pair relationship representation after maximum pooling processing, and uses a gating mechanism to perform information fusion based on the sentence hypergraph information representation and the word pair relationship representation after maximum pooling processing to obtain a relationship-aware prompt representation.
[0094] S6: Input the sentence encoding representation and the relationship perception prompt representation into the triple extraction module to perform triple extraction, and obtain the aspect emotion triple extraction result of the sentence to be tested.
[0095] In this embodiment, the extraction device inputs the sentence encoding representation and the relationship perception prompt representation into the triple extraction module to perform triple extraction, and obtains the aspect emotion triple extraction result of the sentence to be tested.
[0096] By constructing a hypergraph relationship matrix of the sentence to be tested, hypergraph information extraction is performed in combination with the encoded sentence encoding representation to capture the interaction information between aspect words, opinion words and other context words in the sentence to be tested, and the sentence hypergraph information representation is obtained. The sentence hypergraph information representation is subjected to word pair relationship classification and relationship perception, and further boundary-sensitive relationship-aware prompt representation is obtained for decoding, providing relationship-aware prompt information for the decoding process, thereby improving the accuracy and efficiency of the extraction of aspect-sentiment triples and improving the accuracy of fine-grained sentiment analysis tasks.
[0097] See also Figure 6 , Figure 6 The flowchart of S6 in the aspect emotion triple extraction method provided in one embodiment of the present application includes steps S61 to S62, which are specifically as follows:
[0098] S61: Input the sentence encoding representation and the relationship perception prompt representation into the decoder, obtain a sentence decoding template representation according to a preset first sentence decoding algorithm, and then decode the sentence template representation according to the sentence decoding template representation.
[0099] In order to further utilize the relationship information in the decoding stage and facilitate the model to output more accurate aspect emotion triple extraction results, in this embodiment, the extraction device inputs the sentence encoding representation and the relationship perception prompt representation into the decoder, and obtains the sentence decoding template representation according to the preset first sentence decoding algorithm. According to the sentence decoding template representation, wherein the sentence decoding template representation is composed of a number of triples arranged in a fixed type order, the first sentence decoding algorithm is:
[0100] H d =Decoder(H e ,P)
[0101] In the formula, H d is the sentence decoding template representation, Decoder(·) is the decoding function, H e is the sentence encoding representation, and P is the relation-aware cue representation.
[0102] S62: According to the sentence decoding template representation and the position indexes of the triples in the sentence decoding template representation, the types and sentiment polarities of the triples in the sentence decoding template representation are determined to obtain the aspect sentiment triple extraction result of the sentence to be tested.
[0103] In this embodiment, the extraction device determines the types and sentiment polarities of several triples in the sentence decoding template representation according to the sentence decoding template representation and the position indexes of several triples in the sentence decoding template representation, and obtains the aspect sentiment triple extraction result of the sentence to be tested.
[0104] In an optional embodiment, the step S7 is further included: training the triple extraction model, see Figure 7 , Figure 7 The flowchart of S7 in the method for extracting aspect emotion triples provided in another embodiment of the present application includes steps S71 to S75, which are specifically as follows:
[0105] S71: Obtain several sample sentences and label template representations of the sample sentences.
[0106] In this embodiment, the extraction device obtains several sample sentences and label template representations of the sample sentences, wherein the label template representation is composed of label data of several triplets in the sample sentences arranged in a fixed type order, and the label data of the triplet includes word probability distribution label data of word pairs and sentiment probability distribution label data of word pairs.
[0107] S72: Inputting a number of the sample sentences into a triple extraction model to be trained to obtain sentence encoding representations and word pair relationship representations of the sample sentences.
[0108] In this embodiment, the extraction device inputs several of the sample sentences into the triple extraction model to be trained to obtain sentence encoding representations and word pair relationship representations of the sample sentences, wherein the word pair relationship representation includes relationship probability distribution prediction data corresponding to several words, and the relationship probability distribution prediction data includes several types of relationship probability distribution prediction vectors.
[0109] S73: Obtain relationship probability distribution label data of several word pairs in several of the sample sentences, and obtain a first cross entropy loss value based on the relationship probability distribution prediction data of several word pairs in the sample sentences, the relationship probability distribution label data and a preset first cross entropy loss function.
[0110] In this embodiment, the extraction device obtains the relationship probability distribution label data of several word pairs in the sample sentences, and obtains the first cross entropy loss value according to the relationship probability distribution prediction data of several word pairs in the sample sentences, the relationship probability distribution label data and the preset first cross entropy loss function, wherein the relationship probability distribution label data includes several types of relationship probability distribution label vectors, and the first cross entropy loss function is:
[0111]
[0112] In the formula, is the first cross entropy loss value, n is the number of words in the sample sentence, y ij is the probability distribution label vector of the relationship between the word pair consisting of the i-th word and the j-th word in the sample sentence, is the number of types, c is the type, r i,j|c The predicted vector for the relationship probability distribution of type c between the word pair consisting of the i-th word and the j-th word.
[0113] S74: respectively using sentence encoding representations of several sample sentences as input representations of the decoder in the triple extraction model to be trained, and label template representations of several sample sentences as initial output representations of the decoder, performing several iterative decodings according to a preset second sentence decoding algorithm, and obtaining sentence decoding representations of several sample sentences at several moments.
[0114] In this embodiment, the extraction device uses the sentence encoding representations of several sample sentences as the input representations of the decoder in the triple extraction model to be trained, and the label template representations of several sample sentences as the initial output representations of the decoder, and performs several iterative decoding according to a preset second sentence decoding algorithm to obtain sentence decoding representations of several sample sentences at several moments, wherein the second sentence decoding algorithm is:
[0115]
[0116] In the formula, is the sentence decoding representation of the sample sentence at the tth moment, H′ e is the sentence encoding representation of the sample sentence, It is the sentence decoding representation of the sample sentence at the t-1th moment.
[0117] S75: Perform conditional probability conversion on the sentence decoding representations of the sample sentences at several moments respectively to obtain conditional probability representations of the sample sentences at several moments, obtain a second cross entropy loss value according to the conditional probability representations of the sample sentences at several moments and a preset second cross entropy loss function, and train the triple extraction model to be trained according to the first cross entropy loss value and the second cross entropy loss value.
[0118] In this embodiment, the extraction device performs conditional probability conversion on the sentence decoding representations of the sample sentences at several moments, respectively, to obtain conditional probability representations of the sample sentences at several moments, and obtains a second cross entropy loss value according to the conditional probability representations of the sample sentences at several moments and a preset second cross entropy loss function, wherein the second cross entropy loss function is:
[0119]
[0120] In the formula, is the second cross entropy loss value, T is the total time, It is the conditional probability representation of the sample sentence at the tth moment.
[0121] The extraction device accumulates the first cross entropy loss value and the second cross entropy loss value according to the first cross entropy loss value and the second cross entropy loss value to obtain a total loss value, and trains the triple extraction model to be trained according to the total loss value.
[0122] Please refer to Figure 8 , Figure 8 A schematic diagram of the structure of an aspect emotion triple extraction device provided by an embodiment of the present application. The device can implement all or part of the aspect emotion triple extraction device through software, hardware, or a combination of both. The device 8 includes:
[0123] A data acquisition unit 81 is used to obtain a sentence to be tested and a preset triple extraction model, wherein the sentence to be tested includes a plurality of words, and the triple extraction model includes a sentence encoding module, a hypergraph information extraction module, a relationship perception prompt module, and a triple extraction module;
[0124] A sentence encoding unit 82, used for inputting the sentence to be tested into the sentence encoding module for encoding processing to obtain a sentence encoding representation of the sentence to be tested;
[0125] A matrix construction unit 83, used to construct a hypergraph relationship matrix of the sentence to be tested, wherein the hypergraph association matrix includes relationship vectors between a plurality of nodes and a plurality of hyperedges;
[0126] A feature extraction unit 84 is used to input the sentence encoding representation and the hypergraph relationship matrix into the hypergraph information extraction module to extract the hypergraph information and obtain the sentence hypergraph information representation of the sentence to be tested;
[0127] A relationship perception unit 85, configured to input the sentence hypergraph information representation into the relationship perception prompt module to perform word pair relationship classification and relationship perception, and obtain a relationship perception prompt representation of the sentence to be tested;
[0128] The triple extraction unit 86 is used to input the sentence encoding representation and the relationship perception prompt representation into the triple extraction module to perform triple extraction, so as to obtain the aspect emotion triple extraction result of the sentence to be tested.
[0129] In this embodiment, the extraction device obtains the sentence to be tested and the preset triple extraction model through the data acquisition unit, wherein the sentence to be tested includes a plurality of words, and the triple extraction model includes a sentence encoding module, a hypergraph information extraction module, a relationship perception prompt module and a triple extraction module; through the sentence encoding unit, the sentence to be tested is input into the sentence encoding module for encoding processing to obtain the sentence encoding representation of the sentence to be tested; through the matrix construction unit, a hypergraph relationship matrix of the sentence to be tested is constructed, wherein the hypergraph association matrix includes a relationship matrix between a plurality of nodes and a plurality of hyperedges. quantity; through the feature extraction unit, the sentence encoding representation and the hypergraph relationship matrix are input into the hypergraph information extraction module for hypergraph information extraction to obtain the sentence hypergraph information representation of the sentence to be tested; through the relationship perception unit, the sentence hypergraph information representation is input into the relationship perception prompt module for word pair relationship classification and relationship perception to obtain the relationship perception prompt representation of the sentence to be tested; through the triple extraction unit, the sentence encoding representation and the relationship perception prompt representation are input into the triple extraction module for triple extraction to obtain the aspect emotion triple extraction result of the sentence to be tested.
[0130] A data acquisition unit obtains a sentence to be tested and a preset triple extraction model, wherein the sentence to be tested includes a plurality of words, and the triple extraction model includes a sentence encoding module, a feature extraction module, an entity detection module, and a sentiment analysis module; through the sentence encoding unit, the sentence to be tested is input into the sentence encoding module for encoding processing to obtain the sentence encoding representation of the sentence to be tested; through the feature extraction unit, a part-of-speech adjacency matrix and a syntactic adjacency matrix of the sentence to be tested are constructed, and the sentence encoding representation, the part-of-speech adjacency matrix, and the syntactic adjacency matrix are input into the feature extraction module for feature extraction to obtain the context feature representation of the sentence to be tested; through the entity detection unit, a plurality of word groups of the sentence to be tested are constructed, and according to the context feature representation, a plurality of first fragment feature representations of the word groups are constructed, and a plurality of single The first segment feature representation of the word group is input into the entity detection module to obtain entity detection results of several word groups, wherein the entity detection results include aspect words and opinion words; through the term extraction unit, according to the entity detection results of several word groups, several terms of the sentence to be tested are constructed, wherein the terms include the word groups corresponding to aspect words and the word groups corresponding to opinion words; through the aspect sentiment triple construction unit, according to the first segment feature representation of several word groups, the second segment feature representation of several terms is constructed, and the second segment feature representation of several terms is input into the sentiment analysis module to obtain sentiment analysis results of several terms, and several aspect sentiment triples of the sentence to be tested are constructed, wherein the aspect sentiment triples include terms and sentiment analysis results of the terms. By constructing a hypergraph relationship matrix of the sentence to be tested, hypergraph information extraction is performed in combination with the encoded sentence encoding representation to capture the interaction information between aspect words, opinion words and other context words in the sentence to be tested, and the sentence hypergraph information representation is obtained. The sentence hypergraph information representation is subjected to word pair relationship classification and relationship perception, and further boundary-sensitive relationship-aware prompt representation is obtained for decoding, providing relationship-aware prompt information for the decoding process, thereby improving the accuracy and efficiency of the extraction of aspect-sentiment triples and improving the accuracy of fine-grained sentiment analysis tasks.
[0131] Please refer to Fig. 9 , Fig. 9 The computer device 10 is a schematic diagram of a computer device according to an embodiment of the present application. The computer device 10 includes: a processor 91, a memory 92, and a computer program 93 stored in the memory 92 and executable on the processor 91; the computer device may store a plurality of instructions, which are suitable for being loaded and executed by the processor 91. Figures 1 to 7 The method steps of the embodiment shown in the figure can be found in the specific implementation process. Figures 1 to 7The specific description of the illustrated embodiment will not be repeated here.
[0132] Among them, the processor 91 may include one or more processing cores. The processor 91 uses various interfaces and lines to connect various parts in the server, and executes various functions and processes data of the emotion triple extraction device 8 by running or executing instructions, programs, code sets or instruction sets stored in the memory 92, and calling the data in the memory 92. Optionally, the processor 91 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programble Logic Array, PLA). The processor 91 can integrate one or more combinations of a central processing unit 91 (Central Processing Unit, CPU), an image processor 91 (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing the content to be displayed on the touch display screen; the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 91, and it can be implemented by a single chip.
[0133] Among them, the memory 92 may include a random access memory 92 (Random Access Memory, RAM), and may also include a read-only memory 92 (Read-Only Memory). Optionally, the memory 92 includes a non-transitory computer-readable storage medium. The memory 92 can be used to store instructions, programs, codes, code sets or instruction sets. The memory 92 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for at least one function (such as touch instructions, etc.), instructions for implementing the above-mentioned various method embodiments, etc.; the data storage area may store data involved in the above-mentioned various method embodiments, etc. The memory 92 may also be optionally at least one storage device located away from the aforementioned processor 91.
[0134] An embodiment of the present application also provides a storage medium, which can store multiple instructions. The instructions are suitable for being loaded by a processor and executing the method steps of the above-mentioned embodiments one to four. The specific execution process can be found in the specific descriptions of embodiments one to four, which will not be repeated here.
[0135] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.
[0136] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described or recorded in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0137] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraint algorithm of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0138] In the embodiments provided by the present invention, it should be understood that the disclosed devices / terminal equipment and methods can be implemented in other ways. For example, the device / terminal equipment embodiments described above are only schematic. For example, the division of the modules or units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0141] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present invention implements all or part of the processes 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, and when the computer program is executed by a processor, the steps of the above-mentioned method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form, etc.
[0142] The present invention is not limited to the above-mentioned embodiments. If various changes or modifications to the present invention do not depart from the spirit and scope of the present invention, and if these changes and modifications fall within the scope of the claims and equivalent technologies of the present invention, the present invention is also intended to include these changes and modifications.
Claims
1. A method for extracting aspect sentiment triples, characterized in that: The following steps are involved: Obtaining a sentence to be tested and a preset triple extraction model, wherein the sentence to be tested includes a plurality of words, and the triple extraction model includes a sentence encoding module, a hypergraph information extraction module, a relationship perception prompt module, and a triple extraction module; Inputting the sentence to be tested into the sentence encoding module for encoding processing to obtain a sentence encoding representation of the sentence to be tested; Constructing a hypergraph relationship matrix of the sentence to be tested, wherein the hypergraph association matrix includes relationship vectors between a plurality of nodes and a plurality of hyperedges; Inputting the sentence encoding representation and the hypergraph relationship matrix into the hypergraph information extraction module to extract hypergraph information, and obtaining the sentence hypergraph information representation of the sentence to be tested; Inputting the sentence hypergraph information representation into the relationship perception prompt module to perform word pair relationship classification and relationship perception, and obtaining the relationship perception prompt representation of the sentence to be tested; The sentence encoding representation and the relationship perception prompt representation are input into the triple extraction module to perform triple extraction, and the aspect emotion triple extraction result of the sentence to be tested is obtained.
2. The method for extracting aspect emotion triples according to claim 1, characterized in that: The step of constructing the hypergraph relationship matrix of the sentence to be tested comprises the following steps: Obtaining a syntactic dependency graph and dependency label data of the sentence to be tested, and determining dependency edges connecting corresponding words in the syntactic dependency graph according to dependency labels between the words in the dependency label data; Perform grammatical induction processing on the sentence to be tested to obtain a grammatical structure diagram of the sentence to be tested and a plurality of grammatical edges in the grammatical structure diagram; respectively use words that have a connection relationship with the dependency edges and grammatical edges as nodes of a relational hypergraph, and use the dependency edges and grammatical edges as hyperedges of the relational hypergraph to construct a relational hypergraph of the sentence to be tested, transform the relational hypergraph, and obtain the hypergraph relation matrix.
3. The method for extracting aspect emotion triples according to claim 2, characterized in that: The contextual hypergraph information extraction module includes a hypergraph attention network and a feedforward neural network; The step of inputting the sentence encoding representation and the hypergraph relationship matrix into the hypergraph information extraction module to extract hypergraph information and obtain the sentence hypergraph information representation of the sentence to be tested comprises the following steps: Inputting the sentence encoding representation and the hypergraph relationship matrix into the hypergraph attention network to extract attention hypergraph information and obtain node attention information representation; The node attention information representation is input into the feedforward neural network for information fitting to obtain a node information fitting representation, and the information fitting vectors of several nodes in the node information representation after information fitting are used as information vectors of the corresponding words in the sentence to be tested to obtain the sentence hypergraph information representation.
4. The method for extracting aspect emotion triples according to claim 3, characterized in that: The hypergraph attention network includes several graph attention layers; The step of inputting the sentence encoding representation and the hypergraph relationship matrix into the hypergraph attention network to extract the attention hypergraph information and obtain the node attention information representation comprises the following steps: The sentence encoding representation is used as the node input representation and the node output representation of the first-layer graph attention layer of the hypergraph attention network, and the first attention score data is obtained according to the hypergraph relationship matrix, the node output representation and the preset first attention score calculation algorithm; wherein the first attention score data includes the attention scores between several nodes connected to several hyperedges and several hyperedges; the first attention score calculation algorithm is: In the formula, α jk is the attention score between the kth node connected to the jth hyperedge and the jth hyperedge, is the output vector of the kth node in the node output representation of the l-1th graph attention layer, MLP(·) is the multi-layer perceptron function, e j is the jth hyperedge, v p is the pth node connected to the jth hyperedge, is the output vector of the pth node in the node output representation of the l-1th graph attention layer; the node input representation of the l-1th graph attention layer of the hypergraph attention network is the node output representation of the l-1th graph attention layer of the hypergraph attention network; According to the first attention score data, the node input representation and the preset hyperedge attention aggregation algorithm, a hyperedge attention aggregation representation of a plurality of hyperedges is obtained, wherein the hyperedge attention aggregation algorithm is: In the formula, is the hyperedge attention aggregation representation of the jth hyperedge in the lth graph attention layer, σ(·) is the activation function, and v k is the kth node connected to the jth hyperedge, W n is the first weight parameter; According to the hypergraph relationship matrix, the node output representation, the hyperedge attention aggregation representation of the plurality of hyperedges, and the preset second attention score calculation algorithm, the second attention score data is obtained, wherein the second attention score data includes the attention scores between the plurality of hyperedges in the hyperedge set having a connection relationship between the plurality of nodes and the plurality of nodes. The second attention score calculation algorithm is: In the formula, β ij is the attention score between the jth hyperedge in the hyperedge set that connects the i-th node and the i-th node, ε i is the set of hyperedges connected to the ith node, e p is the jth hyperedge in the hyperedge set that has a connection relationship with the pth node, is the hyperedge attention aggregation representation of the jth hyperedge of the lth graph attention layer, is the output vector of the pth node in the node output representation of the l-1th graph attention layer; the node input representation of the l-1th graph attention layer of the hypergraph attention network is the node output representation of the l-1th graph attention layer of the hypergraph attention network; According to the second attention score data, the node input representation and the preset node attention aggregation algorithm, the node attention aggregation representation is obtained as the node output representation of the first graph attention layer of the supergraph attention network and the node input representation of the next graph attention layer, and the calculation is repeated to obtain the node output representation of the last graph attention layer of the supergraph attention network as the node attention information representation, wherein the node attention aggregation algorithm is: In the formula, is the output vector of the i-th node in the node output representation of the l-th graph attention layer, e j is the jth hyperedge in the hyperedge set that has a connection relationship with the i-th node, β ij is the attention score between the jth hyperedge in the hyperedge set that connects the i-th node and the i-th node, W e is the second weight parameter.
5. The method for extracting aspect emotion triples according to claim 4, characterized in that: The relationship perception prompt module includes a first multi-layer perceptron network and a second multi-layer perceptron network; The step of inputting the sentence hypergraph information representation into the relationship perception prompt module for word pair relationship classification and relationship perception to obtain the relationship perception prompt representation of the sentence to be tested comprises the following steps: The double affine attention method is adopted to obtain the word pair relationship representation according to the sentence hypergraph information representation and the preset relationship probability distribution calculation algorithm, wherein the word pair relationship representation includes the relationship probability distribution prediction data of several word pairs, and the relationship probability distribution calculation algorithm is: R=Biaffine(MLP a (H F ),MLP o (H F )) Where R is the word pair relationship representation, Biaffine(·) is the biaffine attention function, and MLP a (·) is the processing function of the first multi-layer perceptron network, MLP o (·) is the processing function of the second multi-layer perceptron network, H F is a hypergraph information representation of the sentence; The word pair relationship representation is subjected to maximum pooling processing to obtain the word pair relationship representation after maximum pooling processing, and a gating mechanism is used to perform information fusion according to the sentence hypergraph information representation and the word pair relationship representation after maximum pooling processing to obtain a relationship perception prompt representation.
6. The method for extracting aspect emotion triples according to claim 5, characterized in that: The step of inputting the sentence encoding representation and the relationship perception prompt representation into the triple extraction module to extract triples, and obtaining the aspect emotion triple extraction result of the sentence to be tested, comprises the following steps: The sentence encoding representation and the relationship perception prompt representation are input into the decoder, and a sentence decoding template representation is obtained according to a preset first sentence decoding algorithm. According to the sentence decoding template representation, wherein the sentence decoding template representation is composed of a plurality of triplets arranged in a fixed type order, the first sentence decoding algorithm is: H d =Decoder(H e ,P) In the formula, H d is the sentence decoding template representation, Decoder(·) is the decoding function, H e is the sentence encoding representation, and P is the relation perception cue representation; According to the sentence decoding template representation and the position indexes of the triples in the sentence decoding template representation, the types and sentiment polarities of the triples in the sentence decoding template representation are determined to obtain the aspect sentiment triple extraction result of the sentence to be tested.
7. The method for extracting aspect emotion triples according to claim 6, characterized in that: It also includes the steps of: training the triple extraction model; The training of the triple extraction model comprises the steps of: Obtaining a plurality of sample sentences and label template representations of the sample sentences, wherein the label template representation is composed of label data of a plurality of triplets in the sample sentences arranged in a fixed type order, and the label data of the triplets includes word probability distribution label data of word pairs and sentiment probability distribution label data of word pairs; Inputting a number of the sample sentences into the triple extraction model to be trained, obtaining sentence encoding representations and word pair relationship representations of the sample sentences, wherein the word pair relationship representations include relationship probability distribution prediction data corresponding to a number of words, and the relationship probability distribution prediction data includes several types of relationship probability distribution prediction vectors; Obtaining relationship probability distribution label data of several word pairs in several sample sentences, and obtaining a first cross entropy loss value according to the relationship probability distribution prediction data of several word pairs in several sample sentences, the relationship probability distribution label data, and a preset first cross entropy loss function, wherein the relationship probability distribution label data includes several types of relationship probability distribution label vectors, and the first cross entropy loss function is: In the formula, is the first cross entropy loss value, n is the number of words in the sample sentence, y ij is the probability distribution label vector of the relationship between the word pair consisting of the i-th word and the j-th word in the sample sentence, is the number of types, c is the type, r i,j|c A predicted vector for the relationship probability distribution of type c between the word pair consisting of the i-th word and the j-th word; The sentence encoding representations of several sample sentences are respectively used as the input representations of the decoder in the triple extraction model to be trained, and the label template representations of several sample sentences are used as the initial output representations of the decoder. According to the preset second sentence decoding algorithm, several iterative decodings are performed to obtain the sentence decoding representations of several sample sentences at several moments, wherein the second sentence decoding algorithm is: In the formula, is the sentence decoding representation of the sample sentence at the tth moment, H′ e is the sentence encoding representation of the sample sentence, is the sentence decoding representation of the sample sentence at the t-1th moment; The sentence decoding representations of the sample sentences at several moments are respectively converted into conditional probabilities to obtain conditional probability representations of the sample sentences at several moments, and a second cross entropy loss value is obtained according to the conditional probability representations of the sample sentences at several moments and a preset second cross entropy loss function, and the triple extraction model to be trained is trained according to the first cross entropy loss value and the second cross entropy loss value, wherein the second cross entropy loss function is: In the formula, is the second cross entropy loss value, T is the total time, It is the conditional probability representation of the sample sentence at the tth moment.
8. A device for extracting aspect emotion triples, characterized in that: include: A data acquisition unit, used to obtain a sentence to be tested and a preset triple extraction model, wherein the sentence to be tested includes a plurality of words, and the triple extraction model includes a sentence encoding module, a hypergraph information extraction module, a relationship perception prompt module and a triple extraction module; A sentence encoding unit, used for inputting the sentence to be tested into the sentence encoding module for encoding processing to obtain a sentence encoding representation of the sentence to be tested; A matrix construction unit, used to construct a hypergraph relationship matrix of the sentence to be tested, wherein the hypergraph association matrix includes relationship vectors between a plurality of nodes and a plurality of hyperedges; A feature extraction unit, used for inputting the sentence encoding representation and the hypergraph relationship matrix into the hypergraph information extraction module to extract the hypergraph information and obtain the sentence hypergraph information representation of the sentence to be tested; A relationship perception unit, used for inputting the sentence hypergraph information representation into the relationship perception prompt module to perform word pair relationship classification and relationship perception, and obtain the relationship perception prompt representation of the sentence to be tested; The triple extraction unit is used to input the sentence encoding representation and the relationship perception prompt representation into the triple extraction module to perform triple extraction and obtain the aspect emotion triple extraction result of the sentence to be tested.
9. A computer device, characterized in that: The method comprises a processor, a memory 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 emotion triple extraction method according to any one of claims 1 to 7 are implemented.
10. A storage medium, characterized in that: The storage medium stores a computer program, which, when executed by a processor, implements the steps of the emotion triple extraction method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Knowledge enhancement-based aspect emotion triple extraction method and system
CN117171610A
Multi-view knowledge graph inference method and system based on hypergraph convolution and graph convolution, and storage medium
CN118396093A