CN114357164A - Emotion-reason pair extraction method, device and equipment and readable storage medium - Google Patents
Emotion-reason pair extraction method, device and equipment and readable storage medium Download PDFInfo
- Publication number
- CN114357164A CN114357164A CN202111639867.8A CN202111639867A CN114357164A CN 114357164 A CN114357164 A CN 114357164A CN 202111639867 A CN202111639867 A CN 202111639867A CN 114357164 A CN114357164 A CN 114357164A
- Authority
- CN
- China
- Prior art keywords
- clause
- emotion
- reason
- representation
- pair
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Abstract
The invention provides an emotion-reason pair extraction method, device and equipment and a readable storage medium, wherein the emotion-reason pair extraction method comprises the following steps: after a document to be predicted of a natural language text is obtained, semantic representation of clauses in the document is obtained by utilizing a pre-trained language model, and emotion-reason pair extraction models which are trained are used for extracting and obtaining emotion-reason pairs in the document. Wherein, the emotion-reason pair extraction model comprises a plurality of layers of attention modules fused with Gaussian priors. And in the emotion-reason pair extraction model training process, calculating to obtain a joint loss value when performing clause type prediction and emotion-reason pair prediction, updating parameters of the emotion-reason pair extraction model by using the joint loss value gradient until the joint loss value converges, finishing training, and obtaining the trained emotion-reason pair extraction model. The method fully captures the relative position information among clauses in the document, and can automatically extract and obtain potential emotion-reason pairs in the document.
Description
Technical Field
The invention relates to the field of natural language processing, in particular to an emotion-reason pair extraction method, device and equipment and a readable storage medium.
Background
Emotion-reason pair extraction is a task in the field of natural language processing, and aims to automatically extract emotion clauses and corresponding reason clauses from documents at the chapter level. Where a document is made up of several clauses, a clause is defined as a short sentence separated by a symbol such as a comma, as opposed to a whole sentence separated by a period. The emotion-reason pair extraction application scenarios are wide and comprise social media mining, product comment analysis and the like. In view of their importance, more and more researchers are beginning to focus on emotion-cause pair extraction.
In one document, the emotion clauses and the reason clauses corresponding to the emotion clauses contain a large amount of voice information, and the method has high research value. At present, the emotion-reason pair extraction algorithm does not fully consider the importance of the relative position between the emotion clause and the reason clause, or only uses simple position embedding to capture position information.
Disclosure of Invention
The invention mainly aims to provide an emotion-reason pair extraction method, device and equipment and a readable storage medium, and aims to solve the technical problems that in the prior art, a large number of text features need to be artificially constructed in a chapter-level emotion-reason pair extraction method, and the emotion-reason pair capturing capability is poor due to insufficient utilization of relative position information among clauses.
In a first aspect, the present invention provides an emotion-cause pair extraction method, including the steps of:
inputting a document to be predicted into a language model to obtain vectorization representation of each clause in the document to be predicted;
inputting the vectorization representation of each clause into a trained emotion-reason pair extraction model, and obtaining emotion-reason pairs in the document to be predicted based on the trained emotion-reason pair extraction model;
the step of obtaining the emotion-reason pair in the document to be predicted based on the trained emotion-reason pair extraction model comprises the following steps:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
a cross attention module based on fusion Gaussian prior obtains a second directional quantitative representation of each clause in the emotion clause set and the reason clause set;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
and predicting the emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the document to be predicted based on the predicted values of the emotion-reason pairs.
Optionally, the step of obtaining the first vector quantization representation of each clause based on the first fusion gaussian prior self-attention module includes:
inputting the vectorization representation of each clause into a first Gaussian prior fusion self-attention module to obtain a first vectorization representation of each clause, wherein the formula of the first Gaussian prior fusion self-attention module is as follows:
wherein s isiIs a first vector quantized representation of clause i, ciFor vectorized representation of clause i, cjFor vectorized representation of any clause other than clause i in the document to be predicted, di,jIs ciAnd cjThe distance of (a) to (b),is Gaussian priors and varies1And b1Are training parameters.
Optionally, the step of predicting the type of each clause based on the first vector quantization representation of each clause includes:
inputting the first vector quantized representation of each clause into a first prediction formula, the first prediction formula being:
wherein the content of the first and second substances,type prediction value, s, for clause iiIs a first vector quantized representation of clause i, WsAnd bsAre training parameters.
Optionally, the step of obtaining a second quantitative representation of each clause in the emotion clause set and the reason clause set by the cross attention module based on the fusion gaussian prior includes:
inputting the first vector quantitative representation of each clause in the emotion clause set and the reason clause set into a Gaussian prior fused cross attention module to obtain a second vector quantitative representation of each clause in the emotion clause set and the reason clause set, wherein the formula of the Gaussian prior fused cross attention module is as follows:
wherein the content of the first and second substances,for the second quantized representation of clause i in the set of emotion clauses,for the first vector representation of clause i in the set of emotion clauses,for the second quantized representation of clause j in the reason clause set,first vector quantized representation of clause j in the set of reason clauses, di,j、dj,iIs composed ofAndthe distance of (a) to (b),is Gaussian priors and varies2And b2、∝3And b3Are training parameters.
Optionally, the step of obtaining a new vectorized representation of each candidate clause pair by the self-attention module based on the second fusion gaussian prior includes:
inputting the vectorization representation of each candidate clause pair into a second Gaussian-prior-fused self-attention module to obtain a new vectorization representation of each candidate clause pair, wherein the formula of the second Gaussian-prior-fused self-attention module is expressed as:
wherein the content of the first and second substances,for a new vectorized representation of candidate clause pairs, hi,jVectorized representation of candidate clause pairs made up of sentiment clause i and reason clause jN is the number of clauses in the document to be predicted, hi,mVectorized representation of candidate clause pairs consisting of an emotion clause i and any clause in the set of reason clauses, dj,mFor the distance between the reason clause j and any clause in the set of reason clauses,is Gaussian priors and varies4And b4Are training parameters.
Optionally, the step of predicting an emotion-cause pair according to the new vectorized representation of each candidate clause pair includes:
inputting the new vectorized representation of the candidate clause pair into a second prediction formula, the second prediction formula being:
wherein the content of the first and second substances,the predictor of the new vectorized representation for the candidate clause pair consisting of clause i and clause j,for a new vectorized representation of candidate clause pairs, WhAnd bhAre training parameters.
Optionally, the emotion-reason pair extraction method further includes:
inputting a training document into a language model to obtain vectorization representation of each clause in the training document;
inputting the vectorization representation of each clause into an emotion-reason pair extraction model, and obtaining joint loss based on the emotion-reason pair extraction model;
updating training parameters of the emotion-cause pair extraction model according to the combined loss gradient;
detecting whether the joint loss converges;
if the joint loss is not converged, taking a new training document as the training document, and returning to execute the step of inputting the training document into a language model to obtain vectorization representation of each clause in the training document;
if the joint loss is converged, taking the latest emotion-reason pair extraction model as the emotion-reason pair extraction model after training;
the step of deriving a joint loss based on the emotion-cause pair extraction model comprises:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
inputting the type predicted value and the type label value of each clause into a first loss function formula to obtain a first loss, wherein the first loss function formula is as follows:
wherein L isclauseFor the first loss, n is the number of clauses in the training document,for the emotion clause type tag value of clause i,for the emotion clause type predictor for clause i,for the reason clause type tag value of clause i,a reason clause type prediction value of the clause i;
obtaining a second-direction quantitative representation of each clause in the updated emotion clause set and reason clause set based on a cross attention module fused with Gaussian priors;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
predicting emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the training document based on the predicted values of the emotion-reason pairs;
inputting the predicted value of the emotion-reason pair and the tag value of the emotion-reason pair of each candidate clause pair into a second loss function formula to obtain a second loss, wherein the second loss function formula is as follows:
wherein L ispairFor the second loss, n is the number of clauses in the training document,tag value, u, of emotion-reason pair for candidate clause pairi,jA predictor of emotion-cause pairs for candidate clause pairs;
combining the first loss and the second loss results in a combined loss.
In a second aspect, the present invention also provides an emotion-reason pair extraction device, including:
the clause vectorization representation module is used for inputting the document to be predicted into the language model to obtain vectorization representation of each clause in the document to be predicted;
the emotion-reason pair prediction module is used for inputting the vectorized representation of each clause into a trained emotion-reason pair extraction model and obtaining emotion-reason pairs in the document to be predicted based on the trained emotion-reason pair extraction model;
the step of obtaining the emotion-reason pair in the document to be predicted based on the trained emotion-reason pair extraction model comprises the following steps:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
a cross attention module based on fusion Gaussian prior obtains a second directional quantitative representation of each clause in the emotion clause set and the reason clause set;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
and predicting the emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the document to be predicted based on the predicted values of the emotion-reason pairs.
Optionally, the emotion-cause pair prediction module is specifically configured to:
inputting the vectorization representation of each clause into a first Gaussian prior fusion self-attention module to obtain a first vectorization representation of each clause, wherein the formula of the first Gaussian prior fusion self-attention module is as follows:
wherein s isiIs a first vector quantized representation of clause i, ciFor vectorized representation of clause i, cjFor vectorized representation of any clause other than clause i in the document to be predicted, di,jIs ciAnd cjThe distance of (a) to (b),is Gaussian priors and varies1And b1Are training parameters.
Optionally, the emotion-cause pair prediction module is specifically configured to:
inputting the first vector quantized representation of each clause into a first prediction formula, the first prediction formula being:
wherein the content of the first and second substances,type prediction value, s, for clause iiIs a first vector quantized representation of clause i, WsAnd bsAre training parameters.
Optionally, the emotion-cause pair prediction module is specifically configured to:
inputting the first vector quantitative representation of each clause in the emotion clause set and the reason clause set into a Gaussian prior fused cross attention module to obtain a second vector quantitative representation of each clause in the emotion clause set and the reason clause set, wherein the formula of the Gaussian prior fused cross attention module is as follows:
wherein the content of the first and second substances,for the second quantized representation of clause i in the set of emotion clauses,for the first vector representation of clause i in the set of emotion clauses,for the second quantized representation of clause j in the reason clause set,first vector quantized representation of clause j in the set of reason clauses, di,j、dj,iIs composed ofAndthe distance of (a) to (b),is Gaussian priors and varies2And b2、∝3And b3Are training parameters.
Optionally, the emotion-cause pair prediction module is specifically configured to:
inputting the vectorization representation of each candidate clause pair into a second Gaussian-prior-fused self-attention module to obtain a new vectorization representation of each candidate clause pair, wherein the formula of the second Gaussian-prior-fused self-attention module is expressed as:
wherein the content of the first and second substances,for a new vectorized representation of candidate clause pairs, hi,jIs vectorized representation of candidate clause pairs formed by emotion clause i and reason clause j, n is the number of clauses in the document to be predicted, hi,mVectorized representation of candidate clause pairs consisting of an emotion clause i and any clause in the set of reason clauses, dj,mFor the distance between the reason clause j and any clause in the set of reason clauses,is Gaussian priors and varies4And b4Are training parameters.
Optionally, the emotion-cause pair prediction module is specifically configured to:
inputting the new vectorized representation of the candidate clause pair into a second prediction formula, the second prediction formula being:
wherein the content of the first and second substances,the predictor of the new vectorized representation for the candidate clause pair consisting of clause i and clause j,for a new vectorized representation of candidate clause pairs, WhAnd bhAre training parameters.
Optionally, the emotion-cause pair extraction apparatus further includes a training module, specifically configured to:
inputting a training document into a language model to obtain vectorization representation of each clause in the training document;
inputting the vectorization representation of each clause into an emotion-reason pair extraction model, and obtaining joint loss based on the emotion-reason pair extraction model;
updating training parameters of the emotion-cause pair extraction model according to the combined loss gradient;
detecting whether the joint loss converges;
if the joint loss is not converged, taking a new training document as the training document, and returning to execute the step of inputting the training document into a language model to obtain vectorization representation of each clause in the training document;
if the joint loss is converged, taking the latest emotion-reason pair extraction model as the emotion-reason pair extraction model after training;
the step of deriving a joint loss based on the emotion-cause pair extraction model comprises:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
inputting the type predicted value and the type label value of each clause into a first loss function formula to obtain a first loss, wherein the first loss function formula is as follows:
wherein L isclauseFor the first loss, n is the number of clauses in the training document,for the emotion clause type tag value of clause i,for the emotion clause type predictor for clause i,for the reason clause type tag value of clause i,a reason clause type prediction value of the clause i;
obtaining a second-direction quantitative representation of each clause in the updated emotion clause set and reason clause set based on a cross attention module fused with Gaussian priors;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
predicting emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the training document based on the predicted values of the emotion-reason pairs;
inputting the predicted value of the emotion-reason pair and the tag value of the emotion-reason pair of each candidate clause pair into a second loss function formula to obtain a second loss, wherein the second loss function formula is as follows:
wherein L ispairFor the second loss, n is the number of clauses in the training document,tag value, u, of emotion-reason pair for candidate clause pairi,jA predictor of emotion-cause pairs for candidate clause pairs;
combining the first loss and the second loss results in a combined loss.
In a third aspect, the present invention further provides an emotion-reason pair extraction device, which includes a processor, a memory, and an emotion-reason pair extraction program stored on the memory and executable by the processor, wherein when the emotion-reason pair extraction program is executed by the processor, the steps of the emotion-reason pair extraction method as described above are implemented.
In a fourth aspect, the present invention further provides a readable storage medium, in which an emotion-reason pair extraction program is stored, where the emotion-reason pair extraction program, when executed by a processor, implements the steps of the emotion-reason pair extraction method as described above.
In the invention, after a document to be predicted of a natural language text is acquired, semantic representation of clauses in the document is acquired by utilizing a pre-trained language model, and emotion-reason pair extraction models which are trained are used for extracting and obtaining emotion-reason pairs in the document. Wherein, the emotion-reason pair extraction model comprises a plurality of layers of attention modules fused with Gaussian priors. And in the emotion-reason pair extraction model training process, calculating to obtain a joint loss value when performing clause type prediction and emotion-reason pair prediction, updating parameters of the emotion-reason pair extraction model by using the joint loss value gradient until the joint loss value converges, and finishing training to obtain the trained emotion-reason pair extraction model. The method fully captures the relative position information among clauses in the document, and can automatically extract and obtain potential emotion-reason pairs in the document.
Drawings
FIG. 1 is a diagram of a hardware structure of an emotion-reason pair extraction device according to an embodiment of the present invention;
FIG. 2 is a flow chart illustrating an embodiment of a sentiment-reason pair extraction method according to the present invention;
FIG. 3 is a flow chart illustrating a method for emotion-reason pair extraction according to another embodiment of the present invention;
FIG. 4 is a flow chart illustrating a method for emotion-reason pair extraction according to yet another embodiment of the present invention;
FIG. 5 is a functional block diagram of an embodiment of an emotion-reason pair extraction apparatus according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
In a first aspect, an embodiment of the present invention provides an emotion-reason pair extraction device.
Referring to fig. 1, fig. 1 is a schematic diagram of a hardware structure of an emotion-reason pair extraction device according to an embodiment of the present invention. In an embodiment of the present invention, the emotion-reason pair extraction device may include a processor 1001 (e.g., a Central Processing Unit, CPU), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used for realizing connection communication among the components; the user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard); the network interface 1004 may optionally include a standard wired interface, a WIreless interface (e.g., a WI-FI interface, WI-FI interface); the memory 1005 may be a Random Access Memory (RAM) or a non-volatile memory (non-volatile memory), such as a magnetic disk memory, and the memory 1005 may optionally be a storage device independent of the processor 1001. Those skilled in the art will appreciate that the hardware configuration depicted in FIG. 1 is not intended to be limiting of the present invention, and may include more or less components than those shown, or some components in combination, or a different arrangement of components.
With continued reference to FIG. 1, the memory 1005 of FIG. 1, which is one type of computer storage medium, may include an operating system, a network communication module, a user interface module, and an emotion-cause pair extraction program. The processor 1001 may call an emotion-reason pair extraction program stored in the memory 1005, and execute an emotion-reason pair extraction method provided by an embodiment of the present invention.
In a second aspect, embodiments of the present invention provide an emotion-reason pair extraction method.
Referring to fig. 2, fig. 2 is a flowchart illustrating an embodiment of an emotion-reason pair extraction method according to the present invention.
In an embodiment of the emotion-reason pair extraction method of the present invention, the emotion-reason pair extraction method includes:
step S10, inputting the document to be predicted into a language model to obtain vectorization representation of each clause in the document to be predicted;
in this embodiment, the public data set contributed by the ECPE task presenter is selected, the chapter document and each clause are parsed from the text format file, and the text format file in the public data set is divided into a training set, a verification set and a test set by taking a chapter as a unit. Before inputting into the corresponding language model, the natural language text in the documents of the training set, the verification set and the test set is constructed into the input format required by the language model, the [ CLS ] mark is added to the sub-sentence head in the text, and the [ SEP ] mark is added to the sub-sentence tail in the text. Instantiating a BERT language model, and loading model parameters pre-trained in advance by using a large scale to obtain the BERT language model finished by pre-training. And segmenting the clauses by using a word splitter of the pre-trained BERT language model to obtain vectorization of each word of the clauses in the document to be predicted, and inputting the vectorization of each word of the clauses in the document to be predicted, which is verified to be centralized, into the pre-trained BERT language model to obtain vectorization representation of each clause in the document to be predicted.
Step S20, inputting the vectorization representation of each clause into a trained emotion-reason pair extraction model, and obtaining emotion-reason pairs in the document to be predicted based on the trained emotion-reason pair extraction model;
specifically, the obtaining of the emotion-reason pair in the document to be predicted based on the trained emotion-reason pair extraction model is realized by the following steps:
step S201, obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
in this embodiment, referring to fig. 3, fig. 3 is a flowchart illustrating an emotion-reason pair extraction method according to another embodiment of the present invention. And inputting the vectorized representation of each clause in the to-be-predicted document obtained in the step S10 into the emotion-reason pair extraction model after training, wherein the self-attention module fusing gaussian priors with the first in the emotion-reason pair extraction model enables each clause to fuse information of other clauses in the document, and performs self-attention calculation inside the clause to obtain a first updated vectorized representation of the clause, namely a first vectorized representation of each clause.
Further, in an embodiment, the step S201 includes:
inputting the vectorization representation of each clause into a first Gaussian prior fusion self-attention module to obtain a first vectorization representation of each clause, wherein the formula of the first Gaussian prior fusion self-attention module is as follows:
wherein s isiIs a first vector quantized representation of clause i, ciFor vectorized representation of clause i, cjFor vectorized representation of any clause other than clause i in the document to be predicted, di,jIs ciAnd cjThe distance of (a) to (b),is Gaussian priors and varies1And b1Are training parameters.
In this embodiment, the vectorized representation of each clause is input into a first gaussian prior-fused self-attention module to obtain a first vectorized representation of each clause, where a formula of the first gaussian prior-fused self-attention module is expressed as:wherein s isiIs a first vector quantized representation of clause i, ciFor vectorized representation of clause i, cjFor vectorized representation of any clause other than clause i in the document to be predicted, di,jIs ciAnd cjThe distance of (a) to (b),is Gaussian priors and varies1And b1Are training parameters.
Step S202, predicting the type of each clause based on the first vector quantization expression of each clause, and dividing to obtain an emotion clause set and a reason clause set based on a type predicted value;
in this embodiment, the first vector quantization expression obtained in step S201 is obtained, and the type of each clause is predicted based on the obtained first vector quantization expression of each clause, where the clause type includes a reason clause and an emotion clause. And based on the obtained type prediction value, dividing clauses in the document to be predicted to obtain a plurality of emotion clauses and a plurality of reason clauses, wherein the emotion clauses form an emotion clause set, and the reason clauses form a reason clause set.
Further, in an embodiment, the step of predicting the type of each clause based on the first vector quantization representation of each clause includes:
inputting the first vector quantized representation of each clause into a first prediction formula, the first prediction formula being:
wherein the content of the first and second substances,type prediction value, s, for clause iiIs a first vector quantized representation of clause i, WsAnd bsAre training parameters.
In this embodiment, the type of each clause is predicted based on the first vector quantization representation of each clause, and the type prediction value may be calculated by inputting the first vector quantization representation of each clause into a first prediction formula, where the first prediction formula is:wherein the content of the first and second substances,type prediction value, s, for clause iiIs a first vector quantized representation of clause i, WsAnd bsAre training parameters.
Step S203, obtaining a second directional quantitative representation of each clause in the emotion clause set and the reason clause set based on a cross attention module fused with Gaussian priors;
in this embodiment, based on step S202, an emotion clause set and a reason clause set in a document to be predicted can be obtained, based on a cross attention module fused with gaussian priors, each emotion clause in the emotion clause set is obtained, distance information between the emotion clause and the reason clause is captured, the emotion clause in the emotion clause set is fused with clause information of each reason clause in the reason clause set, and a second-directional quantized representation of each clause in the emotion clause set is obtained. And acquiring each reason clause in the reason clause set by a Gaussian prior fusion-based cross attention module, capturing distance information between the reason clauses and the emotion clauses, fusing the clause information of each emotion clause in the emotion clause set by the reason clauses in the reason clause set, and obtaining second-direction quantitative representation of each clause in the reason clause set.
Further, in an embodiment, the step S203 includes:
inputting the first vector quantitative representation of each clause in the emotion clause set and the reason clause set into a Gaussian prior fused cross attention module to obtain a second vector quantitative representation of each clause in the emotion clause set and the reason clause set, wherein the formula of the Gaussian prior fused cross attention module is as follows:
wherein the content of the first and second substances,for the second quantized representation of clause i in the set of emotion clauses,for the first vector representation of clause i in the set of emotion clauses,for the second quantized representation of clause j in the reason clause set,first vector quantized representation of clause j in the set of reason clauses, di,j、dj,iIs composed ofAndthe distance of (a) to (b),is Gaussian priors and varies2And b2、∝3And b3Are training parameters.
In this embodiment, a first vector quantization representation of each clause in the emotion clause set and the reason clause set is input to the gaussian prior fused cross attention module to obtain a second vector quantization representation of each clause in the emotion clause set and the reason clause set, where a formula of the gaussian prior fused cross attention module for the emotion clauses is expressed as:the formula of the cross attention module for the fusion gaussian priors for the cause clause is expressed as: wherein the content of the first and second substances,second-direction quantized representation of clause i in set of emotion clauses,For the first vector representation of clause i in the set of emotion clauses,for the second quantized representation of clause j in the reason clause set,first vector quantized representation of clause j in the set of reason clauses, di,j、dj,iIs composed ofAndthe distance of (a) to (b),is Gaussian priors and varies2And b2、∝3And b3Are training parameters.
Step S204, applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second directional quantized representation of each clause in the emotion clause set and the second directional quantized representation of each clause in the reason clause set to obtain the vectorized representation of each candidate clause pair;
in this embodiment, the second updated vectorized representation of each clause in the emotion clause set and the reason clause set obtained in step S203 is obtained, a cartesian product is applied to the emotion clause set and the reason clause set, and the second vectorized representation of each clause in the emotion clause set and the second vectorized representation of each clause in the reason clause set are subjected to one-to-one concatenation operation, so as to obtain the vectorized representation of each candidate clause pair. Wherein, the calculation formula of the Cartesian product is as follows:wherein h isi,jTo proceed toA vectorized representation of the candidate clause pairs resulting from a one-to-one stitching operation,for a second quantized representation of each clause in the set of emotion clauses,a second quantized representation of each clause in the set of clauses for the reason.
Step S205, obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
in this embodiment, the vectorization representation of each candidate clause pair obtained in step S205 is obtained, and based on the second gaussian-prior-fused self-attention module, the information of each candidate clause pair on other candidate clause pairs in the fused document is obtained, and self-attention calculation is performed on the inside of the candidate clause pair, so as to obtain a new vectorization representation of each candidate clause pair.
Further, in an embodiment, the step S205 includes:
inputting the vectorization representation of each candidate clause pair into a second Gaussian-prior-fused self-attention module to obtain a new vectorization representation of each candidate clause pair, wherein the formula of the second Gaussian-prior-fused self-attention module is expressed as:
wherein the content of the first and second substances,for a new vectorized representation of candidate clause pairs, hi,jIs vectorized representation of candidate clause pairs formed by emotion clause i and reason clause j, n is the number of clauses in the document to be predicted, hi,mVectorized representation of candidate clause pairs consisting of an emotion clause i and any clause in the set of reason clauses, dj,mDistance between reason clause j and any clause in reason clause set,Is Gaussian priors and varies4And b4Are training parameters.
In this embodiment, the vectorization representation of each candidate clause pair is input to the second gaussian prior fused self-attention module to obtain a new vectorization representation of each candidate clause pair, where the formula of the second gaussian prior fused self-attention module is expressed as: wherein the content of the first and second substances,for a new vectorized representation of candidate clause pairs, hi,jIs vectorized representation of candidate clause pairs formed by emotion clause i and reason clause j, n is the number of clauses in the document to be predicted, hi,mVectorized representation of candidate clause pairs consisting of an emotion clause i and any clause in the set of reason clauses, dj,mFor the distance between the reason clause j and any clause in the set of reason clauses,is Gaussian priors and varies4And b4Are training parameters.
And step S206, predicting the emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the document to be predicted based on the predicted values of the emotion-reason pairs.
In this embodiment, the new vectorized representation of the candidate clause pair obtained in step S205 is obtained, and the emotion-cause pair prediction is performed according to the new vectorized representation of each candidate clause pair, where the types of the candidate clause pairs include emotion-cause pairs and non-emotion-cause pairs. And extracting and obtaining the emotion-reason pairs in the document to be predicted based on the predicted values of the emotion-reason pairs.
Further, in an embodiment, the step of predicting emotion-cause pairs according to the new vectorized representation of each candidate clause pair includes:
inputting the new vectorized representation of the candidate clause pair into a second prediction formula, the second prediction formula being:
wherein the content of the first and second substances,the predictor of the new vectorized representation for the candidate clause pair consisting of clause i and clause j,for a new vectorized representation of candidate clause pairs, WhAnd bhAre training parameters.
In this embodiment, the new vectorized representation of the candidate clause pair is input to a second prediction formula, which is:wherein the content of the first and second substances,the predictor of the new vectorized representation for the candidate clause pair consisting of clause i and clause j,for a new vectorized representation of candidate clause pairs, WhAnd bhAre training parameters.
Further, in an embodiment, the emotion-reason pair extraction method further includes:
step S1, inputting a training document into a language model to obtain vectorization representation of each clause in the training document;
step S2, inputting the vectorization representation of each clause into an emotion-reason pair extraction model, and obtaining combined loss based on the emotion-reason pair extraction model;
step S3, updating the training parameters of the emotion-reason pair extraction model according to the combined loss gradient;
step S4, detecting whether the joint loss is converged;
if the joint loss does not converge, using the new training document as the training document, and returning to execute the step S1;
step S5, if the combined loss is converged, taking the latest emotion-reason pair extraction model as the emotion-reason pair extraction model after training;
specifically, the obtaining of the joint loss based on the emotion-cause pair extraction model is realized by the following steps:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
inputting the type predicted value and the type label value of each clause into a first loss function formula to obtain a first loss, wherein the first loss function formula is as follows:
wherein L isclauseFor the first loss, n is the number of clauses in the training document,for the emotion clause type tag value of clause i,for the emotion clause type predictor for clause i,for the reason clause type tag value of clause i,a reason clause type prediction value of the clause i;
obtaining a second-direction quantitative representation of each clause in the updated emotion clause set and reason clause set based on a cross attention module fused with Gaussian priors;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
predicting emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the training document based on the predicted values of the emotion-reason pairs;
inputting the predicted value of the emotion-reason pair and the tag value of the emotion-reason pair of each candidate clause pair into a second loss function formula to obtain a second loss, wherein the second loss function formula is as follows:
wherein L ispairFor the second loss, n is the number of clauses in the training document,tag value, u, of emotion-reason pair for candidate clause pairi,jA predictor of emotion-cause pairs for candidate clause pairs;
combining the first loss and the second loss results in a combined loss.
In this embodiment, referring to fig. 4, fig. 4 is a flowchart illustrating an emotion-reason pair extraction method according to still another embodiment of the present invention. And inputting the training document into a language model to obtain vectorization representation of each clause in the training document. And inputting the vectorization representation of each clause into an emotion-reason pair extraction model, and obtaining the joint loss based on the emotion-reason pair extraction model. Specifically, the obtaining of the joint loss based on the emotion-cause pair extraction model is realized by the following steps:
a first vector quantization representation of each clause is obtained based on a first fused gaussian prior self-attention module. And predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set. Inputting the type predicted value and the type label value of each clause into a first loss function formula to obtain a first loss, wherein the first loss function formula is as follows:wherein L isclauseFor the first loss, n is the number of clauses in the training document,for the emotion clause type tag value of clause i,for the emotion clause type predictor for clause i,for the reason clause type tag value of clause i,a reason clause type predictor for clause i.
And obtaining a second-direction quantitative representation of each clause in the updated emotion clause set and reason clause set based on a cross attention module fused with Gaussian priors. Applying Cartesian product to the set of emotion clauses and the set of reason clauses to represent the second vector of each clause in the set of emotion clauses and the sum of the vectorsAnd performing one-to-one splicing operation on the second vectorization representation of each clause in the reason clause set to obtain the vectorization representation of each candidate clause pair. A new vectorized representation of each candidate clause pair is obtained based on a second fused gaussian prior self-attention module. And predicting the emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the training document based on the predicted values of the emotion-reason pairs. Inputting the predicted value of the emotion-reason pair and the tag value of the emotion-reason pair of each candidate clause pair into a second loss function formula to obtain a second loss, wherein the second loss function formula is as follows: wherein L ispairFor the second loss, n is the number of clauses in the training document,tag value, u, of emotion-reason pair for candidate clause pairi,jIs the predicted value of the emotion-reason pair of the candidate clause pair. Combining the first loss and the second loss results in a combined loss.
And updating the training parameters of the emotion-reason pair extraction model according to the combined loss gradient. Wherein the training parameters include training parameters of a first self-attention module with Gaussian prior fused: is a direct change1And b1And fusing the training parameters of the cross attention module with Gaussian prior: is a direct change2And b2、∝3And b3The second Gaussian mixture prior varies from the attention module4And b4And training parameters for clause type prediction are as follows: wsAnd bsPerforming emotion-cause pair predicted training parameters: whAnd bh. And detecting whether the joint loss converges. If the joint loss is not converged, taking a new training document as the training document, and returning to execute the step of inputting the training document into the language model to obtain the trainingVectorizing representation of each clause in the document; and if the joint loss converges, taking the latest emotion-reason pair extraction model as the emotion-reason pair extraction model after training.
In this embodiment, after a to-be-predicted document of a natural language text is acquired, a pre-trained language model is used to acquire semantic representations of clauses in the document, and an emotion-reason pair extraction model after training is used to extract and obtain emotion-reason pairs in the document. Wherein, the emotion-reason pair extraction model comprises a plurality of layers of attention modules fused with Gaussian priors. And in the emotion-reason pair extraction model training process, calculating to obtain a joint loss value when performing clause type prediction and emotion-reason pair prediction, updating parameters of the emotion-reason pair extraction model by using the joint loss value gradient until the joint loss value converges, and finishing training to obtain the trained emotion-reason pair extraction model. The method fully captures the relative position information among clauses in the document, and can automatically extract and obtain potential emotion-reason pairs in the document. Compared with the prior art, the method is an end-to-end model instead of a step-by-step model, so that the problems of error propagation and the like are avoided, and emotion-reason pairs hidden in text documents at chapter level can be extracted, so that the method is closer to actual application scenes and has higher practical value.
In a third aspect, an embodiment of the present invention further provides an emotion-reason pair extraction device.
Referring to fig. 5, a functional block diagram of an embodiment of an emotion-reason pair extraction apparatus is shown.
In this embodiment, the emotion-cause pair extraction device includes:
a clause vectorization representation module 10, configured to input a to-be-predicted document into a language model, so as to obtain vectorization representation of each clause in the to-be-predicted document;
the emotion-reason pair prediction module 20 is configured to input the vectorized representation of each clause into a trained emotion-reason pair extraction model, and obtain an emotion-reason pair in the document to be predicted based on the trained emotion-reason pair extraction model;
the step of obtaining the emotion-reason pair in the document to be predicted based on the trained emotion-reason pair extraction model comprises the following steps:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
a cross attention module based on fusion Gaussian prior obtains a second directional quantitative representation of each clause in the emotion clause set and the reason clause set;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
and predicting the emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the document to be predicted based on the predicted values of the emotion-reason pairs.
Further, in an embodiment, the emotion-cause pair prediction module 20 is specifically configured to:
inputting the vectorization representation of each clause into a first Gaussian prior fusion self-attention module to obtain a first vectorization representation of each clause, wherein the formula of the first Gaussian prior fusion self-attention module is as follows:
wherein s isiIs a first vector quantized representation of clause i, ciFor vectorized representation of clause i, cjFor vectorized representation of any clause other than clause i in the document to be predicted, di,jIs ciAnd cjThe distance of (a) to (b),is Gaussian priors and varies1And b1Are training parameters.
Further, in an embodiment, the emotion-cause pair prediction module 20 is specifically configured to:
inputting the first vector quantized representation of each clause into a first prediction formula, the first prediction formula being:
wherein the content of the first and second substances,type prediction value, s, for clause iiIs a first vector quantized representation of clause i, WsAnd bsAre training parameters.
Further, in an embodiment, the emotion-cause pair prediction module 20 is specifically configured to:
inputting the first vector quantitative representation of each clause in the emotion clause set and the reason clause set into a Gaussian prior fused cross attention module to obtain a second vector quantitative representation of each clause in the emotion clause set and the reason clause set, wherein the formula of the Gaussian prior fused cross attention module is as follows:
wherein the content of the first and second substances,for the second quantized representation of clause i in the set of emotion clauses,for the first vector representation of clause i in the set of emotion clauses,for the second quantized representation of clause j in the reason clause set,first vector quantized representation of clause j in the set of reason clauses, di,j、dj,iIs composed ofAndthe distance of (a) to (b),is Gaussian priors and varies2And b2、∝3And b3Are training parameters.
Further, in an embodiment, the emotion-cause pair prediction module 20 is specifically configured to:
inputting the vectorization representation of each candidate clause pair into a second Gaussian-prior-fused self-attention module to obtain a new vectorization representation of each candidate clause pair, wherein the formula of the second Gaussian-prior-fused self-attention module is expressed as:
wherein the content of the first and second substances,for a new vectorized representation of candidate clause pairs, hi,jIs vectorized representation of candidate clause pairs formed by emotion clause i and reason clause j, n is the number of clauses in the document to be predicted, hi,mFor emotional clause i and reasonVectorized representation of candidate clause pairs consisting of any clause in the set of clauses, dj,mFor the distance between the reason clause j and any clause in the set of reason clauses,is Gaussian priors and varies4And b4Are training parameters.
Further, in an embodiment, the emotion-cause pair prediction module 20 is specifically configured to:
inputting the new vectorized representation of the candidate clause pair into a second prediction formula, the second prediction formula being:
wherein the content of the first and second substances,the predictor of the new vectorized representation for the candidate clause pair consisting of clause i and clause j,for a new vectorized representation of candidate clause pairs, WhAnd bhAre training parameters.
Further, in an embodiment, the emotion-cause pair extraction apparatus further includes a training module, specifically configured to:
inputting a training document into a language model to obtain vectorization representation of each clause in the training document;
inputting the vectorization representation of each clause into an emotion-reason pair extraction model, and obtaining joint loss based on the emotion-reason pair extraction model;
updating training parameters of the emotion-cause pair extraction model according to the combined loss gradient;
detecting whether the joint loss converges;
if the joint loss is not converged, taking a new training document as the training document, and returning to execute the step of inputting the training document into a language model to obtain vectorization representation of each clause in the training document;
if the joint loss is converged, taking the latest emotion-reason pair extraction model as the emotion-reason pair extraction model after training;
the step of deriving a joint loss based on the emotion-cause pair extraction model comprises:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
inputting the type predicted value and the type label value of each clause into a first loss function formula to obtain a first loss, wherein the first loss function formula is as follows:
wherein L isclauseFor the first loss, n is the number of clauses in the training document,for the emotion clause type tag value of clause i,for the emotion clause type predictor for clause i,for the reason clause type tag value of clause i,a reason clause type prediction value of the clause i;
obtaining a second-direction quantitative representation of each clause in the updated emotion clause set and reason clause set based on a cross attention module fused with Gaussian priors;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
predicting emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the training document based on the predicted values of the emotion-reason pairs;
inputting the predicted value of the emotion-reason pair and the tag value of the emotion-reason pair of each candidate clause pair into a second loss function formula to obtain a second loss, wherein the second loss function formula is as follows:
wherein L ispairFor the second loss, n is the number of clauses in the training document,tag value, u, of emotion-reason pair for candidate clause pairi,jA predictor of emotion-cause pairs for candidate clause pairs;
combining the first loss and the second loss results in a combined loss.
The function implementation of each module in the emotion-reason pair extraction device corresponds to each step in the embodiment of the emotion-reason pair extraction method, and the function and implementation process are not described in detail here.
In a fourth aspect, the embodiment of the present invention further provides a readable storage medium.
The readable storage medium of the invention stores the emotion-reason pair extraction program, wherein the emotion-reason pair extraction program realizes the steps of the emotion-reason pair extraction method when being executed by a processor.
The method implemented when the emotion-reason pair extraction program is executed may refer to various embodiments of the emotion-reason pair extraction method of the present invention, and details thereof are not repeated herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for causing a terminal device to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (10)
1. An emotion-cause pair extraction method, characterized in that the emotion-cause pair extraction method comprises:
inputting a document to be predicted into a language model to obtain vectorization representation of each clause in the document to be predicted;
inputting the vectorization representation of each clause into a trained emotion-reason pair extraction model, and obtaining emotion-reason pairs in the document to be predicted based on the trained emotion-reason pair extraction model;
the step of obtaining the emotion-reason pair in the document to be predicted based on the trained emotion-reason pair extraction model comprises the following steps:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
a cross attention module based on fusion Gaussian prior obtains a second directional quantitative representation of each clause in the emotion clause set and the reason clause set;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
and predicting the emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the document to be predicted based on the predicted values of the emotion-reason pairs.
2. An emotion-cause pair extraction method as recited in claim 1, wherein the step of obtaining the first vector quantized representation of each clause based on the first fused Gaussian prior self-attention module comprises:
inputting the vectorization representation of each clause into a first Gaussian prior fusion self-attention module to obtain a first vectorization representation of each clause, wherein the formula of the first Gaussian prior fusion self-attention module is as follows:
wherein s isiIs a first vector quantized representation of clause i, ciFor vectorized representation of clause i, cjFor vectorized representation of any clause other than clause i in the document to be predicted, di,jIs ciAnd cjThe distance of (a) to (b),is Gaussian priors and varies1And b1Are training parameters.
3. An emotion-cause pair extraction method as recited in claim 1, wherein said step of predicting the type of each clause based on said first vector quantized representation of each clause comprises:
inputting the first vector quantized representation of each clause into a first prediction formula, the first prediction formula being:
4. The emotion-cause pair extraction method of claim 1, wherein the step of obtaining a second quantized representation of each clause in the set of emotion clauses and the set of reason clauses based on a cross attention module fused with gaussian priors comprises:
inputting the first vector quantitative representation of each clause in the emotion clause set and the reason clause set into a Gaussian prior fused cross attention module to obtain a second vector quantitative representation of each clause in the emotion clause set and the reason clause set, wherein the formula of the Gaussian prior fused cross attention module is as follows:
wherein the content of the first and second substances,for the second quantized representation of clause i in the set of emotion clauses,for the first vector representation of clause i in the set of emotion clauses,for the second quantized representation of clause j in the reason clause set,first vector quantized representation of clause j in the set of reason clauses, di,j、dj,iIs composed ofAndthe distance of (a) to (b),is Gaussian priors and varies2And b2、∝3And b3Are training parameters.
5. An emotion-cause pair extraction method as recited in claim 1, wherein said step of deriving a new vectorized representation of each candidate clause pair based on a second fused Gaussian prior self-attention model comprises:
inputting the vectorization representation of each candidate clause pair into a second Gaussian-prior-fused self-attention module to obtain a new vectorization representation of each candidate clause pair, wherein the formula of the second Gaussian-prior-fused self-attention module is expressed as:
wherein the content of the first and second substances,for a new vectorized representation of candidate clause pairs, hi,jIs vectorized representation of candidate clause pairs formed by emotion clause i and reason clause j, n is the number of clauses in the document to be predicted, hi,mVectorized representation of candidate clause pairs consisting of an emotion clause i and any clause in the set of reason clauses, dj,mFor the distance between the reason clause j and any clause in the set of reason clauses,is Gaussian priors and varies4And b4Are training parameters.
6. The emotion-cause pair extraction method of claim 1, wherein the step of performing emotion-cause pair prediction from the new vectorized representation of each candidate clause pair comprises:
inputting the new vectorized representation of the candidate clause pair into a second prediction formula, the second prediction formula being:
7. The emotion-cause pair extraction method as recited in claim 1, wherein the emotion-cause pair extraction method further comprises:
inputting a training document into a language model to obtain vectorization representation of each clause in the training document;
inputting the vectorization representation of each clause into an emotion-reason pair extraction model, and obtaining joint loss based on the emotion-reason pair extraction model;
updating training parameters of the emotion-cause pair extraction model according to the combined loss gradient;
detecting whether the joint loss converges;
if the joint loss is not converged, taking a new training document as the training document, and returning to execute the step of inputting the training document into a language model to obtain vectorization representation of each clause in the training document;
if the joint loss is converged, taking the latest emotion-reason pair extraction model as the emotion-reason pair extraction model after training;
the step of deriving a joint loss based on the emotion-cause pair extraction model comprises:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
inputting the type predicted value and the type label value of each clause into a first loss function formula to obtain a first loss, wherein the first loss function formula is as follows:
wherein L isclauseFor the first loss, n is the number of clauses in the training document,for the emotion clause type tag value of clause i,for the emotion clause type predictor for clause i,for the reason clause type tag value of clause i,a reason clause type prediction value of the clause i;
obtaining a second-direction quantitative representation of each clause in the updated emotion clause set and reason clause set based on a cross attention module fused with Gaussian priors;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
predicting emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the training document based on the predicted values of the emotion-reason pairs;
inputting the predicted value of the emotion-reason pair and the tag value of the emotion-reason pair of each candidate clause pair into a second loss function formula to obtain a second loss, wherein the second loss function formula is as follows:
wherein L ispairFor the second loss, n is the number of clauses in the training document,tag value, u, of emotion-reason pair for candidate clause pairi,jA predictor of emotion-cause pairs for candidate clause pairs;
combining the first loss and the second loss results in a combined loss.
8. An emotion-cause pair extraction apparatus, characterized in that the emotion-cause pair extraction apparatus comprises:
the clause vectorization representation module is used for inputting the document to be predicted into the language model to obtain vectorization representation of each clause in the document to be predicted;
the emotion-reason pair prediction module is used for inputting the vectorized representation of each clause into a trained emotion-reason pair extraction model and obtaining emotion-reason pairs in the document to be predicted based on the trained emotion-reason pair extraction model;
the step of obtaining the emotion-reason pair in the document to be predicted based on the trained emotion-reason pair extraction model comprises the following steps:
obtaining a first vector quantization representation of each clause based on a first fusion Gaussian prior self-attention module;
predicting the type of each clause based on the first vector quantization expression of each clause, and dividing based on a type predicted value to obtain an emotion clause set and a reason clause set;
a cross attention module based on fusion Gaussian prior obtains a second directional quantitative representation of each clause in the emotion clause set and the reason clause set;
applying Cartesian product to the emotion clause set and the reason clause set, and performing one-to-one splicing operation on the second vector quantitative representation of each clause in the emotion clause set and the second vector quantitative representation of each clause in the reason clause set to obtain the vector representation of each candidate clause pair;
obtaining a new vectorization representation of each candidate clause pair based on a second fusion Gaussian prior self-attention module;
and predicting the emotion-reason pairs according to the new vectorization representation of each candidate clause pair, and extracting and obtaining the emotion-reason pairs in the document to be predicted based on the predicted values of the emotion-reason pairs.
9. An emotion-cause pair extraction apparatus comprising a processor, a memory, and an emotion-cause pair extraction program stored on the memory and executable by the processor, wherein the emotion-cause pair extraction program when executed by the processor implements the steps of the emotion-cause pair extraction method according to any one of claims 1 to 7.
10. A readable storage medium, characterized in that the readable storage medium has stored thereon an emotion-reason pair extraction program, wherein the emotion-reason pair extraction program, when executed by a processor, implements the steps of the emotion-reason pair extraction method according to any one of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111639867.8A CN114357164A (en) | 2021-12-29 | 2021-12-29 | Emotion-reason pair extraction method, device and equipment and readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111639867.8A CN114357164A (en) | 2021-12-29 | 2021-12-29 | Emotion-reason pair extraction method, device and equipment and readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114357164A true CN114357164A (en) | 2022-04-15 |
Family
ID=81103624
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111639867.8A Pending CN114357164A (en) | 2021-12-29 | 2021-12-29 | Emotion-reason pair extraction method, device and equipment and readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114357164A (en) |
-
2021
- 2021-12-29 CN CN202111639867.8A patent/CN114357164A/en active Pending
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN112685565B (en) | Text classification method based on multi-mode information fusion and related equipment thereof | |
US10657969B2 (en) | Identity verification method and apparatus based on voiceprint | |
CN113011186B (en) | Named entity recognition method, named entity recognition device, named entity recognition equipment and computer readable storage medium | |
EP3872652B1 (en) | Method and apparatus for processing video, electronic device, medium and product | |
CN111223476B (en) | Method and device for extracting voice feature vector, computer equipment and storage medium | |
CN111581966A (en) | Context feature fusion aspect level emotion classification method and device | |
CN114330966A (en) | Risk prediction method, device, equipment and readable storage medium | |
CN111159358A (en) | Multi-intention recognition training and using method and device | |
CN113836303A (en) | Text type identification method and device, computer equipment and medium | |
CN114004231A (en) | Chinese special word extraction method, system, electronic equipment and storage medium | |
CN115438149A (en) | End-to-end model training method and device, computer equipment and storage medium | |
CN113723077A (en) | Sentence vector generation method and device based on bidirectional characterization model and computer equipment | |
CN111368066A (en) | Method, device and computer readable storage medium for acquiring dialogue abstract | |
CN113722436A (en) | Text information extraction method and device, computer equipment and storage medium | |
US11036996B2 (en) | Method and apparatus for determining (raw) video materials for news | |
CN112380861A (en) | Model training method and device and intention identification method and device | |
CN111241843B (en) | Semantic relation inference system and method based on composite neural network | |
CN114528851B (en) | Reply sentence determination method, reply sentence determination device, electronic equipment and storage medium | |
CN113408287B (en) | Entity identification method and device, electronic equipment and storage medium | |
CN116127060A (en) | Text classification method and system based on prompt words | |
CN114357164A (en) | Emotion-reason pair extraction method, device and equipment and readable storage medium | |
CN113268588A (en) | Text abstract extraction method, device, equipment, storage medium and program product | |
CN112199954A (en) | Disease entity matching method and device based on voice semantics and computer equipment | |
CN116522905B (en) | Text error correction method, apparatus, device, readable storage medium, and program product | |
CN116975298B (en) | NLP-based modernized society governance scheduling system and method |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |