Feature extraction method for implicit sentiment statements

Through the combination of RoBERTa and BiGRU, global and local features of implicit emotional sentences are extracted, solving the semantic complexity and feature extraction problems of implicit emotional sentences, and improving the accuracy and efficiency of sentiment analysis.

CN118673931APending Publication Date: 2024-09-20JILIN UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410878872.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-02
Publication Date
2024-09-20

AI Technical Summary

Technical Problem

It is difficult for existing technologies to effectively analyze and extract the semantic features of implicit emotional sentences, especially due to their complex semantics and lack of obvious emotional words, resulting in insufficient accuracy and versatility in sentiment analysis.

Method used

The RoBERTa model is used for word embedding, combined with the 12-layer Transformer bidirectional encoder and BiGRU layer, to extract the global and local features of implicit emotional sentences, and perform classification prediction through Softmax, integrating multi-head self-attention and feed-forward network mechanisms, and using factual information to perform Deep semantic interaction and attention pooling.

Benefits of technology

It improves the accuracy of sentiment analysis, simplifies the model architecture, improves training speed and efficiency, and significantly improves the feature extraction performance of implicit emotional sentences.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118673931A
    Figure CN118673931A
Patent Text Reader

Abstract

The invention is suitable for the technical field of natural language processing, and provides an implicit sentiment statement-oriented feature extraction method, which comprises the following steps of S1, layer embedding; a RoBERTa model is adopted to embed words, and S2, a semantic interaction layer is established; a 12-layer Transform bidirectional encoder is adopted to extract global features in the implicit sentiment sentences; step S3, preparing a BiGRU layer; extracting local features in the sentiment sentences by adopting a bidirectional gating loop unit; s4, an output layer; and carrying out classification prediction by adopting Softmax, and outputting an obtained label result. According to the method, RoBERTa and BiGRU are fused to capture semantic features in implicit sentiment statements, so that the classification accuracy is improved, the model architecture is simplified, the training speed is higher, the efficiency is higher, and the overall performance is effectively improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of natural language processing, and in particular relates to a feature extraction method for implicit emotional sentences. Background Art

[0002] Sentiment analysis is widely used to solve the problem of text sentiment tendency and is a hot topic in the field of natural language processing. Text sentiment sentences can be divided into explicit sentiment sentences and implicit sentiment sentences, among which implicit sentiment sentences do not contain or only contain a small number of obvious sentiment words. With the rapid development of Internet technology, the emergence of a large amount of information has made text types more diverse and the format more complex, making it difficult for the model to accurately understand, and implicit sentiment sentences play a leading role in it. Therefore, how to analyze and extract features of implicit sentiment sentences has become a difficult problem in natural language processing. The sentiment analysis task is to classify sentiment sentences into two categories (derogatory and commendatory). Since the semantics of implicit sentiment sentences are more complex, in addition to the sentences themselves, there are many factual information that have an important impact on the classification task. Therefore, while extracting the semantic features of implicit sentiment sentences, sentiment features are also extracted from the related factual information.

[0003] Early sentiment analysis methods mainly include methods based on sentiment dictionaries and machine learning. The method based on sentiment dictionaries consumes a lot of manpower and time costs. The method based on machine learning requires manual adjustment of algorithms for tasks in different fields and cannot achieve automated sentiment analysis. The current mainstream method is to use deep learning for sentiment analysis to automatically extract semantic information from text. Existing sentiment analysis methods mostly use attention mechanisms combined with convolutional networks, but it is not enough to only consider the sentence itself as the data source for sentiment analysis, because when the semantics of the text are more complex, in addition to the sentence to be analyzed, there are many related factual information, which are equally important. To address the above problems, web or fact databases can be referenced to judge and query the authenticity of the text in real time, which is used to aggregate external evidence and provide a basis for its judgment with supporting evidence. However, current sentiment analysis research mainly focuses on explicit sentiment analysis sentences, ignoring the importance of implicit sentiment analysis. However, implicit sentiment sentences are very common in daily application scenarios. At present, there are several problems with implicit sentiment analysis tasks: 1) Implicit sentiment sentences lack universality and are more closely related to the context than explicit sentiment sentences; 2) Implicit sentiment sentences do not contain or contain fewer obvious sentiment words, and the language expression is more euphemistic. Therefore, a feature extraction method for implicit sentiment sentences is proposed. Summary of the invention

[0004] The purpose of the present invention is to provide a feature extraction method for implicit emotional sentences, aiming to solve the problems raised in the above background technology.

[0005] To achieve the above object, the present invention provides the following technical solutions:

[0006] A feature extraction method for implicit emotional sentences includes the following steps:

[0007] Step S1, embedding layer: use RoBERTa model to embed words.

[0008] Step S2, semantic interaction layer: a 12-layer Transformer bidirectional encoder is used to extract global features in implicit sentiment sentences;

[0009] Step S3, BiGRU layer: using bidirectional gated recurrent unit to extract local features in sentiment sentences;

[0010] Step S4, output layer: Use Softmax to perform classification prediction and output the obtained label results.

[0011] Furthermore, in step S1, the RoBERTa model includes three types of embedding codes, namely, tag embedding, segmentation embedding and position embedding; tag embedding is a word vector obtained by pre-training the RoBERTa model based on WordPiece embedding; when processing the input text, the RoBERTa model adds a [CLS] flag at the beginning of the word and a [SEP] flag at the end, and converts each word into a corresponding tag embedding vector to segment the sentence.

[0012] Furthermore, the specific process of step S2 is as follows:

[0013] S n ={s1,s2,…,s n} is regarded as a set of n implicit sentiment sentences, L is the maximum sequence length, d is the feature size; E m,n ={e1,e2,…,e m} is considered as S n A collection of relevant factual information,

[0014] Implicit emotional sentence S n and relevant factual information E m,n Interaction, the calculation formula is:

[0015]

[0016] Among them, the vector E m,n As a query, vector S nAs keys and values, deep semantic interactions are performed in the Transformer encoder, where the keys and values ​​are projected h times by different learnable linear layers; each Transformer encoder consists of a modular unit with two sublayers: multi-head self-attention and feed-forward network; the outputs are concatenated and converted to the original size to generate the final output:

[0017] Z=concat(H1,H2,…,H h )W o

[0018] Among them, H j =Attention(EW j E ,SW j S ,SW j S ), the linear transformation is Z is the output vector after concatenation, H1,…,H h They are the multi-head attention mechanism inside the Transformer encoder, E is the query vector, S is the key and value, and is the linear transformation parameter.

[0019] Furthermore, the specific process of step S3 is as follows:

[0020] The vector Z is fed into the BiGRU layer, and each word in the sequence is mapped to a forward hidden state. and the reverse hidden state

[0021]

[0022] in is the i-th output of the forward GRU network, is the i-th output of the reverse GRU network, Represents the connection of two vectors, g i is the i-th output of BiGRU, where i∈{0,1,…,L};

[0023] g i After 3 iterations of the BiGRU layer, the output sequence is subjected to attention pooling; let is the input sequence based on the attention pool block, and the output is the weighted sum: where α i is the attention weight.

[0024] Furthermore, the method for obtaining the attention weight is:

[0025] First, calculate the learnable parameter vector With each input q i The scaled dot product between them is then normalized using Softmax, which is calculated as follows:

[0026]

[0027] Aggregate the output into a vector using attention-based pooling:

[0028] z=AttPooling(g i )

[0029] in The vector is then projected onto a scalar and normalized using Softmax:

[0030] w=Softmax(W·z)

[0031] in Represents a linear transformation.

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

[0033] The present invention combines RoBERTa with BiGRU to capture the semantic features in implicit sentiment sentences, which not only improves the classification accuracy, but also simplifies the model architecture, making the training faster and more efficient, and effectively improving the overall performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] Figure 1 It is a flow chart of the present invention.

[0035] Figure 2 It is the overall framework diagram of the present invention.

[0036] Figure 3 It is a structural diagram of the embedding layer in the present invention. DETAILED DESCRIPTION

[0037] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0038] The specific implementation of the present invention is described in detail below in conjunction with specific embodiments.

[0039] An embodiment of the present invention provides a feature extraction method for implicit emotional sentences, the flow chart is as follows: Figure 1 As shown, the framework diagram is as follows Figure 2 As shown, the specific steps include:

[0040] Step S1, embedding layer: use RoBERTa model to embed words.

[0041] Step S2, semantic interaction layer: a 12-layer Transformer bidirectional encoder is used to extract global features in implicit sentiment sentences;

[0042] Step S3, BiGRU layer: Bidirectional gated recurrent unit (BiGRU) is used to extract local features in sentiment sentences;

[0043] Step S4, output layer: Use Softmax to perform classification prediction and output the obtained label results.

[0044] As a preferred embodiment of the present invention, in step S1, we use RoBERTa to embed words. RoBERTa has three embedding codes, namely, tag embedding, segmentation embedding and position embedding. Figure 3 The figure shows the structure of the embedding layer. The token embedding is a word vector obtained by pre-training the RoBERTa model based on WordPiece embedding. When processing the input text, the RoBERTa model not only inserts special flags (CLS and SEP) at the beginning and end of the word, but also corresponds each word to a token embedding vector to segment the sentence. Using WordPiece embedding can better handle unknown word and subword combinations than traditional word vectors.

[0045] As a preferred embodiment of the present invention, the specific process of step S2 is as follows:

[0046] S n ={s1,s2,…,s n} is regarded as a set of n implicit sentiment sentences, L is the maximum sequence length, d is the feature size; E m,n ={e1,e2,…,e m} is considered as S n A collection of relevant factual information,

[0047] For any given implicit sentiment sentence S n and some relevant factual information m,n Perform classification prediction to get label Y m,n , indicating its sentiment polarity, where Y m,n =1 represents positive meaning, Y m,n = 0 represents derogatory. The following formula defines the classification task of implicit sentiment sentences:

[0048] (S n ,E m,n )→Y m,n={0,1}

[0049] In the semantic interaction layer, a 12-layer Transformer bidirectional encoder is used to extract features from emotional sentences. First, the implicit emotional sentence S n and relevant factual information E m,n Interaction, the calculation formula is:

[0050]

[0051] Among them, the vector E m,n As a query, vector S n As key and value, deep semantic interaction is carried out in the Transformer encoder, and the key and value are projected h times by different learnable linear layers; each Transformer encoder consists of a modular unit with two sublayers: multi-head self-attention and feed-forward network; the output is concatenated and converted to the original size to generate the final output:

[0052] Z=concat(H1,H2,…,H h )W o

[0053] Among them, H j =Attention(EW j E ,SW j S ,SW j S ), the linear transformation is Z is the output vector after concatenation, H1,…,H h They are the multi-head attention mechanism inside the Transformer encoder, E is the query vector, S is the key and value, and is the linear transformation parameter.

[0054] As a preferred embodiment of the present invention, the specific process of step S3 is as follows:

[0055] The vector Z is fed into the BiGRU layer, and each word in the sequence is mapped to a forward hidden state. and the reverse hidden state

[0056]

[0057] in is the i-th output of the forward GRU network, is the i-th output of the reverse GRU network, Represents the connection of two vectors, gi is the i-th output of BiGRU, where i∈{0,1,…,L};

[0058] g i After 3 iterations of the BiGRU layer, the output sequence is subjected to attention pooling; let is the input sequence based on the attention pool block, and the output is the weighted sum: where α i are the attention weights. To obtain these weights, we first calculate the learnable parameter vector With each input q i The scaled dot product between them is then normalized using Softmax, which is calculated as follows:

[0059]

[0060] Aggregate the output into a vector using attention-based pooling:

[0061] z=AttPooling(g i )

[0062] in The vector is then projected onto a scalar and normalized using Softmax:

[0063] w=Softmax(W·z)

[0064] in Represents a linear transformation.

[0065] Example 1: In order to evaluate the performance of this method, we use appropriate evaluation indicators to evaluate the classification results, namely, accuracy, F1-score, precision and recall. Table 1 lists the results of this method and traditional methods on various evaluation indicators on the PolitiFact and Snopes datasets.

[0066] Table 1 Experimental results of this method and traditional method

[0067]

[0068] As can be seen from Table 1, the traditional word embedding-based CNN and LSTM models have the worst classification performance. When transferring from the classic deep learning language model to the Transformer-based model, all indicators of both datasets have significant improvements of about 8%-13%. Among these methods, Longformer excels in processing long sequences, with an accuracy improvement of 15% compared to the classic deep learning language model. BERT and RoBERTa are both state-of-the-art in general text classification tasks. However, compared with these two methods, our method improves the accuracy by 2.9% on the Snopes dataset and 3.3% on the Politifact dataset. This proves that combining the BiGRU module into the RoBERTa architecture can better extract semantic features in implicit sentiment sentences.

[0069] The above are only preferred embodiments of the present invention. It should be pointed out that, for those skilled in the art, several modifications and improvements can be made without departing from the concept of the present invention. These should also be regarded as the protection scope of the present invention. These will not affect the effect of the implementation of the present invention and the practicality of the patent.

Claims

1. A feature extraction method for implicit emotional sentences, characterized in that: The following steps are involved: Step S1, embedding layer; The RoBERTa model is used for word embedding. Step S2, semantic interaction layer: a 12-layer Transformer bidirectional encoder is used to extract global features in implicit sentiment sentences; Step S3, BiGRU layer: using bidirectional gated recurrent unit to extract local features in sentiment sentences; Step S4, output layer: Use Softmax to perform classification prediction and output the obtained label results.

2. The feature extraction method for implicit emotional sentences according to claim 1 is characterized in that: In step S1, the RoBERTa model includes three types of embedding codes, namely, tag embedding, segmentation embedding and position embedding; the tag embedding is a word vector obtained by pre-training the RoBERTa model based on WordPiece embedding; When processing input text, the RoBERTa model adds a [CLS] flag at the beginning of a word and a [SEP] flag at the end, and converts each word into a corresponding token embedding vector to segment the sentence.

3. The feature extraction method for implicit emotional sentences according to claim 1, characterized in that: The specific process of step S2 is as follows: S n ={s1,s2,…,s n } is regarded as a set of n implicit sentiment sentences, L is the maximum sequence length, d is the feature size; E m,n ={e1,e2,…,e m } is considered as S n A collection of relevant factual information, Implicit emotional sentence S n and relevant factual information E m,n Interaction, the calculation formula is: Among them, the vector E m,n As a query, vector S n As keys and values, deep semantic interactions are performed in the Transformer encoder, where the keys and values ​​are projected h times by different learnable linear layers; each Transformer encoder consists of a modular unit with two sublayers: multi-head self-attention and feed-forward network; the outputs are concatenated and converted to the original size to generate the final output: Z=concat(H1,H2,…,H h )W o Among them, H j =Attention(EW j E ,SW j S ,SW j S ), the linear transformation is Z is the output vector after concatenation, H1,…,H h They are the multi-head attention mechanism inside the Transformer encoder, E is the query input of the Transformer encoder, S is the key and value input of the Transformer encoder, and is the linear transformation parameter.

4. The feature extraction method for implicit sentiment sentences according to claim 1, characterized in that: The specific process of step S3 is as follows: The vector Z is fed into the BiGRU layer, and each word in the sequence is mapped to a forward hidden state. and the reverse hidden state in is the i-th output of the forward GRU network, is the i-th output of the reverse GRU network, Represents the connection of two vectors, g i is the i-th output of BiGRU, where i∈{0,1,…,L}; g i After 3 iterations of the BiGRU layer, the output sequence is subjected to attention pooling; let is the input sequence based on the attention pool block, and the output is the weighted sum: where α i is the attention weight.

5. The feature extraction method for implicit emotional sentences according to claim 1, characterized in that: The method for obtaining the attention weight is: First, calculate the learnable parameter vector With each input q i The scaled dot product between them is then normalized using Softmax, which is calculated as follows: Aggregate the output into a vector using attention-based pooling: z=AttPooling(g i ) in The vector is then projected onto a scalar and normalized using Softmax: w=Softmax(W·z) in Represents a linear transformation.