Disclosure of Invention
1. Technical problem to be solved
The invention aims to provide an emotion-reason pair extraction system based on knowledge assistance, which aims to solve the problems in the background technology:
after word-level encoding of a text, the machine may not be able to identify the problem of the emotion words in the clause more accurately.
2. Technical scheme
The system introduces a manually constructed language and psychological characteristic knowledge base and the like for auxiliary coding, strengthens the identification of emotional words and psychological characteristics, and improves the extraction effect of emotional clauses. Meanwhile, part-of-speech labels including entity identification are added, information such as characters and events in the text is captured, and richer features are provided for extracting emotion and emotion reasons. Third, emotion and emotional cause are often co-occurring, meaning that if a clause is identified as an emotional clause with a greater probability, there is also at least one reason clause in its context with a greater probability. Therefore, the external knowledge auxiliary system learning is added, and the emotion-reason pair extraction is facilitated to a certain extent.
A system for emotion-cause pair extraction based on knowledge assistance, comprising the steps of:
s1, extracting emotion clauses;
s2, extracting reason clauses;
s3, emotion-reason pairing;
S1-S3 are all represented by knowledge-aided word encoding.
Preferably, the knowledge-assisted word encoding representation consists of 3 parts: BERT-based semantic encoding, LIWC linguistic psychology knowledge base-based part-of-speech encoding, and NLPIR-based part-of-speech encoding, wherein,
based on the semantic coding of BERT, each word w in the clause is coded by a BERT BASE model
jEncoding to obtain 768-dimensional word vector representation
Based on word class coding of a language psychological characteristic knowledge base of LIWC, an SC-LIWC dictionary (comprising 71 categories of human sensory words, emotional history words, cognitive history words, social history words and the like) constructed by the golden orchid and the like is adopted to carry out word w in clauses according to one-hot
jEncoding is performed to obtain a 71-dimensional vector representation
Based on the part-of-speech coding of NLPIR, keeping { personal name nr, place name ns, other nouns n, adjective a, adverb d, verb v, pronoun rr, adverb,Other pronouns r and other parts of speech other } are 9 parts of speech, and the word w in the clause is treated according to one-hot
jIs encoded to obtain a 9-dimensional vector representation
Preferably, the knowledge-assisted word encoding means that the semantic encoding of the BERT of the current word, the part-of-speech encoding of the LIWC linguistic-psychological characteristic knowledge base, and the part-of-speech encoding of the NLPIR are concatenated, and the calculation formula is as follows:
wherein xjA vector representation representing a word.
Preferably, the S1 uses a Bi-LSTM model with two layers of word layer and clause layer to encode and represent the clause, and performs binary bounding prediction, that is, if the model already identifies the emotion clause in the text d, there is an emotion clause
The clauses of (2) are set with the recognition results corresponding to the clauses
1, and the recognition results of the other clauses are 0; if the recognition results of all clauses in the text d are 0, namely
Then will be
Maximum first two clause recognition results
Set to 1 and the recognition results of the remaining clauses to 0.
Preferably, the calculation formula of S1 is as follows:
wherein the content of the first and second substances,
is a clause c
iIs used to indicate that the emotion is encoded,
is a clause c
iIs indicative of the context of the user,
is the predicted probability of an emotional clause.
Preferably, the S2 uses a Bi-LSTM model with two layers of a word layer and a clause layer to encode and represent the clause, and concatenates the clause with the emotion clause encoded representation, and then performs binary bounding prediction, that is, if the model identifies a reason clause in the text d, there is a reason clause
The clauses of (2) are set with the recognition results corresponding to the clauses
1, and the recognition results of the other clauses are 0; if the recognition results of all clauses in the text d are 0, namely
Then will be
Maximum first two clause recognition results
Set to 1 and the recognition results of the remaining clauses to 0.
Preferably, the calculation formula of S2 is as follows:
wherein the content of the first and second substances,
is a clause c
iIs used to indicate that the emotion is encoded,
is a clause c
iIs indicative of the context of the user,
the predicted probability of the reason clause.
Preferably, in S3, the clause is encoded and represented by a Bi-LSTM model with two layers, i.e., a term layer and a clause layer, and prediction probabilities and distance information of emotion clauses and reason clauses are added and then sent to a logistic regression model for prediction.
Preferably, the calculation formula of S3 is as follows:
preferably, the distance information is calculated as follows: setting emotion clauses
And reason clause
Is d relative to
i,jJ-i, and the maximum number of clauses in all texts does not exceed M sentences. Initializing a 2M x 50 dimensional array with each row conforming to a normal distribution function, then v
dRepresents the (d) th in the array
i,j+ M) rows, which are applied to the test dataset by continuous training of the dataset to obtain a final representation of each relative position.
3. Advantageous effects
Compared with the prior art, the invention has the advantages that:
(1) emotion-cause pair extraction (ECPE) with greater accuracy
The evaluation results of ECPE-KA on the emotion-cause pair extraction task EPCE are shown in Table 1. As can be seen from Table 1, the ECPE-KA is significantly higher than the ECPE-2Steps and the RANKCP model in the accuracy P and F1 values, and is respectively higher than the F1 values by 18.84% and 4.59%; although ECPE-KA is slightly lower than the TDGC model in the accuracy rate P, the recall rate R is obviously improved, so that the F1 value of ECPE-KA is better than that of the TDGC model, and the improvement of the recall rate also indicates that the model obtains more correct clause pairs.
Compared with the most advanced model ECPE-2D at present, the ECPE-KA (F1-0.6914) achieves better effect than the ECPE-2D model (F1-0.6889) on the ECPE task, the accuracy P is improved by 0.85%, and the recall rate only has the defect of 0.19%.
TABLE 1 results of the experimental evaluation
(2) Reduced number of pairs of candidate affective reasons
The binarization process adopted by ECPE-KA ensures that each text has at least one candidate emotion-reason pair to be sent into calculation, and the number of the candidate emotion-reason pairs in the three submodels of ECPE-2step is less than 1, which means that the model has serious defects in emotion clause extraction or reason clause extraction, so that the pairing number is sharply reduced, but a plurality of possible correct candidate emotion-reason pairs are inevitably lost.
Therefore, the ECPE-KA model not only ensures that the emotion clauses and reason clauses which are as accurate as possible are extracted, but also reduces the number of investigation candidate emotion-reason pairs and improves the identification efficiency.
(3) ECPE-KA is more accurate in emotion reason extraction (ECE)
In a classical ECE task, emotion clauses are manually marked, and an ECPE-KA model does not require manual marking of the emotion clauses in a test set.
Table 2 shows that the ECPE-KA model is only lower in accuracy than CANN and PAE-DGL, superior in recall to all reference models, and finally differs from the best result (CANN) by only 2% at 1 without sentiment clauses annotated to the test data set. This shows that the method proposed herein can overcome the application limitation problem of manual emotion clause annotation on ECE mission, and certainly there is room for improvement.
This document compares the CANN-E model, which is a label that removes the emotion clauses in the data set from the CANN model that performs better under test. As is clear from Table 2, the performance of the CANN-E model after the emotion labels are removed is reduced linearly, and compared with the CANN model, the performance is reduced by 47.74% in the value of 1. And the ECPE-KA also achieves 0.7083 in the case of no emotional clause label, and the value of 1 is improved by 86.54 percent compared with the CANN-E.
TABLE 2 evaluation of emotional cause extraction tasks
Detailed Description
An emotion-reason pair extraction system (ECPE-KA) based on knowledge assistance is provided by combining an external artificial knowledge LIWC (language-mental feature) knowledge base and an NLPIR (nlPIR) part-of-speech analysis platform. The ECPE-KA system structure is shown in FIG. 2.
Example 1: knowledge-assisted clause representation
The knowledge-aided clause representation structure is shown in fig. 3. Given a text d ═ c containing | d | clauses
1,c
2,…,c
|d|}, each clause
Respectively contain | c
i| words. Each word w
jIs represented by the code x
jThe method comprises three parts, namely semantic coding based on BERT, part of speech coding based on an LIWC language psychological characteristic knowledge base and part of speech coding based on NLPIR.
(1) The ECPE-KA model first adopts the BERT BASE model to carry out the operation on each word w in the clause
jEncoding to obtain 768-dimensional word vector representation
(2) Since the text is directed to a chinese dataset, the SC-LIWC dictionary constructed by golden blue et al is employed. The SC-LIWC dictionary includes 71 categories such as human sensory part of speech, emotional history part of speech, cognitive history part of speech, and social history part of speech. One-hot pair of words w in clauses is adopted in the text
jEncoding is performed to obtain a 71-dimensional vector representation
(3) Because only entities such as names, pronouns of names and the like need to be identified in a focused mode to assist extraction of emotion clauses, and in order to avoid dimension sparseness caused by excessive part-of-speech types, the ECPE-KA model only adopts one type and part of two types of parts-of-speech, three types of parts-of-speech which are described in detail are removed, 8 types of parts-of-speech including the names nr, the names ns of places, other nouns n, adjective a, adverb, verb v, pronouns rr and other pronouns r are reserved finally after screening, and the rest one type of parts-speech is combined into other parts-of-speech other uniformly. One-hot is adopted in the text to the word w in the clause
jIs encoded to obtain a 9-dimensional vector representation
In the ECPE-KA model, a word w in a candidate clause
jIs encoded by
And
expressed as:
example 2: sentiment clause extraction
The extraction of emotion clauses adopts a two-layer Bi-LSTM model of a word layer and a clause layer:
(1) word layer Bi-LSTM
One will contain | c
iClause of | words
Coded representation of
As input, send into Bi-LSTM model to get clause c
iMiddle j (th) wordHidden layer representation of language
Obtaining a clause c by adopting a self-attention mechanism for each word
iCoded representation of
Where F represents a Bi-LSTM network using the self-attention mechanism.
(2) Clause layer Bi-LSTM
The purpose of the clause layer Bi-LSTM is to capture semantic dependencies between clauses. For text containing | d | clauses, d ═ c
1,c
2,…,c
2,…,c
|d|Coding each clause
Sending the hidden state into a Bi-LSTM model to obtain the hidden state of the Bi-LSTM, namely a clause c
iIs represented by the context of
Finally will be
Enter softmax function to get clause c
iProbability of being an emotional clause
Considering that at least one emotion clause exists in the text and most of the text contains at most two emotion clauses, in the binary bounding phase, the ECPE-KA model considers two cases: if the model has recognized an emotion clause in the text d, then
The clauses of (2) are set with the recognition results corresponding to the clauses
1, and the recognition results of the other clauses are 0; if the recognition results of all clauses in the text d are 0, namely
Then will be
Maximum first two clause recognition results
Set to 1 and the recognition results of the remaining clauses to 0.
Thus, a candidate emotion clause set in d is obtained
Example 3: reason clause extraction
The extraction of the reason clauses also adopts a Bi-LSTM with a word layer and a clause layer, wherein the coding structure of the clauses (the coding of the Bi-LSTM with the word layer) is the same as the clause coding structure in the emotion clause extraction stage.
Clause c
iCoded representation of
And the emotion prediction probability value obtained in the first stage
Make a spliceTo obtain a clause c
iCoded representation of
To capture context information, a vector representation of | d | clauses in text d is presented herein
As an input to the Bi-LSTM model, the hidden state of Bi-LSTM, i.e., clause c, is obtained
iIs represented by the context of
Finally will be
Sending into softmax function to obtain clause c
iIs predicted to have a probability value
Similar to binarization adopted by emotion clause extraction, considering that most texts contain at most two reason clauses, binarization of the reason clause extraction result is also divided into two cases: if the model has identified a reason clause in the text d, then there is
The clauses of (2) are set with the recognition results corresponding to the clauses
1, and the recognition results of the other clauses are 0; if all clauses in the text d are recognizedAre all 0, i.e.
Then will be
Maximum first two clause recognition results
Set to 1 and the recognition results of the remaining clauses to 0.
Thus, a candidate reason clause set in d is obtained
Example 4: emotion-reason pairing
For the set of emotion clauses in document d
And reason clause set
Performing a cartesian product to obtain all possible pairing results:
obtaining candidate emotion clauses by adopting text representation method in section 1
Coded representation of
And candidate reason clause
Coded representation of
Distance v for joining two clauses simultaneously
dPrediction probability of candidate emotion clause
And predicted probability of candidate reason clause
As a feature, the five codes are spliced to obtain an input vector of the emotion-reason pair filtering model
Comprises the following steps:
distance feature v
dThe calculation method of (c) is as follows: setting emotion clauses
And reason clause
Is d relative to
i,jJ-i, and the maximum number of clauses in all texts does not exceed M sentences. Initializing a 2M x 50 dimensional array with each row conforming to a normal distribution function, then v
dRepresents the (d) th in the array
i,j+ M) rows, which are applied to the test dataset by continuous training of the dataset to obtain a final representation of each relative position.
Then inputting the vector
Sending the sentence into a Logistic regression (Logistic) model to detect whether the two clauses have a causal relationship, and filtering to obtain an emotion-reason pair set:
retention
As a final emotion-cause pair extraction result.
The foregoing shows and describes the general principles, essential features, and advantages of the invention. It will be understood by those skilled in the art that the present invention is not limited to the embodiments described above, and the preferred embodiments of the present invention are described in the above embodiments and the description, and are not intended to limit the present invention. The scope of the invention is defined by the appended claims and equivalents thereof.