Aspect-level sentiment analysis method and system based on BAGCNN model

Through the multi-head attention mechanism and gated convolution layer of the BAGCNN model, combined with the pre-trained word embedding model, the problem of insufficient integration of contextual information in the existing technology is solved, and more accurate aspect-level sentiment analysis is achieved.

CN113553831BActive Publication Date: 2024-09-27HEFEI UNIV OF TECH
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202110651397.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-10
Publication Date
2024-09-27
Estimated Expiration
2041-06-10

AI Technical Summary

Technical Problem

Existing aspect-level sentiment analysis models fail to fully and effectively integrate the contextual information of review texts, resulting in the inability to accurately mine the true sentiments of all aspects of review texts.

Method used

A method based on the BAGCNN model is adopted, including word embedding layer, attention autoencoding layer and gated convolution layer. The final features are obtained through multi-head attention mechanism and convolution kernel parallel calculation of multiple sizes, combined with the aspect word feature matrix. matrix and determine the emotion categories using pre-trained classifiers.

Benefits of technology

Without the need for complex downstream structures to extract features, it is possible to more accurately mine the true emotions of all aspects of review texts and improve the accuracy of sentiment analysis.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113553831B
    Figure CN113553831B
Patent Text Reader

Abstract

The present invention provides an aspect-level sentiment analysis method, system, storage medium and electronic device based on a BAGCNN model, and relates to the field of sentiment analysis technology. The present invention inputs a comment text sequence into a word embedding layer, obtains a context word embedding matrix and an aspect word feature matrix based on a pre-trained word embedding model; inputs the context word embedding matrix into an attention autoencoder layer, obtains a correlation context feature matrix based on a multi-head attention mechanism; inputs the correlation context feature matrix into a gated convolution layer, uses convolution kernels of various sizes to parallelly calculate the convolution results, and combines the aspect word feature matrix to obtain a final feature matrix; inputs the final feature matrix into an output layer, obtains the probability value of the corresponding aspect word sentiment category based on a pre-trained classifier, and determines the sentiment category. In the word embedding process, the context and aspect word information are fused, and no complex downstream structure is required to extract features, so as to more accurately mine the real emotions of various aspects of the comment text.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of sentiment analysis, and in particular to an aspect-level sentiment analysis method, system, storage medium and electronic device based on a BAGCNN model. Background Art

[0002] Sentiment analysis, as a branch of natural language processing, can analyze the opinions or attitudes expressed by users from comment information. Researching this task has practical application value. For example, analyzing the evaluation of stockholders can predict stock prices, and analyzing the evaluation of customers on products can make product recommendations. Different aspects of the comment text may have different emotions. For example, in the sentence "the price is reasonable although the service is poor", the "price" and "service" aspects express positive and negative emotions respectively. At this time, analyzing the entire comment text cannot accurately extract the user's emotional information on various aspects of the product, so it is necessary to adopt an aspect-level sentiment analysis method. This method can be used to complete fine-grained sentiment analysis tasks, that is, to mine different aspects of sentiment information in the comment text.

[0003] At present, traditional aspect-level sentiment analysis models based on machine learning can achieve good classification results, such as sentiment classification models based on SVM model training. However, such models rely on a large number of complex feature engineering. The process of constructing feature engineering requires the knowledge support of experts in related fields, and the process is time-consuming, labor-intensive and error-prone. In addition, since deep learning models can automatically extract feature information of text, a large amount of deep learning knowledge is constantly being applied to aspect-level sentiment analysis tasks.

[0004] For example, the IAN model proposed in the paper "Interactive Attention Networks for Aspect-Level Sentiment Classification" by Dehong Ma et al. provides an interactive attention network that uses the network to weight aspect words according to context information, and weights contexts through aspect word information, respectively extracting important information of context and aspect words. The model first uses the pre-trained corpus glove to obtain the feature representation of context and aspect words as E c and E a , and then use LSTM network to extract corresponding features for both to get H c and H a , and then use the average pooling operation to obtain the feature representation of context and aspect words respectively and Afterwards through Use attention to change the feature representation of aspect words to get t r , in the same way through Use attention to change the feature representation of the context to get c r , then t r and c r After splicing, they are used as the final extracted features.

[0005] For example, the ATAE-LSTM model proposed in the paper "Attention-based LSTM for aspect-level sentiment classification" by Yequan Wang et al. takes into account the fact that aspect-level sentiment analysis tasks rely on aspect words, uses aspect word feature representation twice, and uses LSTM and attention mechanism for feature extraction. The model first obtains the feature representation of context and aspect words as W through the pre-trained corpus glove. c and W a , in the word embedding layer, W c and W a The concatenation is used as the input of the LSTM model to obtain the feature vector H. At this time, the aspect word feature representation W is used again a , and after being concatenated with H, an attention mechanism is used to capture important information in the feature vector.

[0006] However, the above-mentioned aspect-level sentiment analysis schemes all have many drawbacks. For example, they fail to fully and effectively integrate the contextual information of the review text, and thus fail to accurately mine the true emotions of all aspects of the review text. Summary of the invention

[0007] 1. Technical issues to be resolved

[0008] In view of the shortcomings of the prior art, the present invention provides an aspect-level sentiment analysis method, system, storage medium and electronic device based on the BAGCNN model, which solves the technical problem that the contextual information of the comment text cannot be fully and effectively integrated, and thus the true emotions of various aspects of the comment text cannot be accurately mined.

[0009] (II) Technical solution

[0010] To achieve the above objectives, the present invention is implemented through the following technical solutions:

[0011] An aspect-level sentiment analysis method based on a BAGCNN model, wherein the BAGCNN model includes a word embedding layer, an attention autoencoder layer, a gated convolutional layer, and an output layer; the method includes:

[0012] S1. Preprocess the review text to be analyzed to obtain the review text sequence and the corresponding aspect word sequence;

[0013] S2, inputting the comment text sequence into the word embedding layer, obtaining a context word embedding matrix based on a pre-trained word embedding model; and extracting an aspect word feature matrix from the context word embedding matrix;

[0014] S3, inputting the context word embedding matrix into the attention self-encoding layer, and obtaining the associated context feature matrix based on the multi-head attention mechanism;

[0015] S4, inputting the associated context feature matrix into the gated convolution layer, using convolution kernels of various sizes to parallelly calculate the convolution results, and combining the aspect word feature matrix to obtain a final feature matrix;

[0016] S5. Input the final feature matrix into the output layer, obtain the probability value of the emotion category of the corresponding aspect word based on the pre-trained classifier, and determine the emotion category.

[0017] Preferably, the pre-trained word embedding model in S2 includes a BERT model.

[0018] Preferably, S3 specifically includes:

[0019] S31, embedding the context words into a matrix E c Input the attention self-encoding layer, in the single-head self-attention calculation, the E c According to the parameter matrix W i Q , W i K , W i V Perform a linear transformation and use the result of the transformation as the Q, K, and V inputs of the scaled dot product attention.

[0020] head i =Attention(E c W i Q ,E c W i K ,E c W i V ) (1)

[0021] Among them, head i represents the context feature matrix extracted by the i-th single head; Attention represents the scaled dot product function,

[0022]

[0023] Among them, d inrepresents the input dimension of the K vector; softmax represents the activation function;

[0024] S32: Concatenate multiple single-head self-attention calculation results to obtain the associated context feature matrix A c ,

[0025] A c =[head 1 ;head 2 ;…;head h ]W h (3)

[0026] in, is the parameter matrix required for linear transformation after concatenating multiple results, d out Represents the associated context feature matrix A c The output dimension of ; “;” indicates the concatenation operation.

[0027] Preferably, the S4 specifically includes:

[0028] S41, the associated context feature matrix A c The gated convolution layer is input, and convolution kernels of various sizes are used to calculate the convolution results in parallel; depending on whether an activation function is used, the convolution results include a first context feature matrix as a normal convolution result And the second context feature matrix after feature enhancement

[0029]

[0030]

[0031] in, W c and W c ′ represents the pre-trained parameter matrix, b c and b′ c represents the bias term; k represents the convolution kernel window size; d conv represents the number of output channels; tanh represents the activation function; “*” represents the convolution operation; m′ represents the vector length;

[0032] S42, according to and aspect word feature matrix E a , get the filter matrix F k ;

[0033]

[0034] Among them, W f represents the pre-trained parameter matrix, b fRepresents the bias term; aspect word feature matrix E a After maximum pooling, relu represents the activation function;

[0035] S43, according to and F k , after maximum pooling, the third context feature matrix c is obtained k ;

[0036]

[0037] S44, merge the c corresponding to the convolution kernels of various sizes k , obtain the final feature matrix G;

[0038] G=[c 3 ;c 4 ;c 5 ] (8)

[0039] Among them, the convolution kernel window size k includes 3, 4 and 5.

[0040] Preferably, the method for obtaining the aspect word feature matrix in S2 comprises: extracting aspect word feature representations from the context word embedding matrix according to predefined position indexes of aspect words in the comment text context.

[0041] Preferably, the pre-trained classifier in S5 includes a softmax classifier.

[0042] Preferably, the probability value of the sentiment category of the aspect word S5 is expressed as

[0043]

[0044] Among them, G represents the final feature matrix; W o represents the pre-trained parameter matrix; b o Indicates bias.

[0045] An aspect-level sentiment analysis system based on a BAGCNN model, wherein the BAGCNN model includes a word embedding layer, an attention autoencoder layer, a gated convolution layer, and an output layer; the system includes:

[0046] A preprocessing module is used to preprocess the review text to be analyzed and obtain the review text sequence and the corresponding aspect word sequence;

[0047] A word embedding module, used for inputting the comment text sequence into the word embedding layer, obtaining a context word embedding matrix based on a pre-trained word embedding model; and extracting an aspect word feature matrix from the context word embedding matrix;

[0048] An attention self-encoding module, used for inputting the context word embedding matrix into the attention self-encoding layer, and obtaining a correlation context feature matrix based on a multi-head attention mechanism;

[0049] A gated convolution module, used to input the associated context feature matrix into the gated convolution layer, use convolution kernels of various sizes to calculate the convolution results in parallel, and combine the aspect word feature matrix to obtain a final feature matrix;

[0050] The output module is used to input the final feature matrix into the output layer, obtain the probability value of the emotion category of the corresponding aspect word based on the pre-trained classifier, and determine the emotion category.

[0051] A storage medium stores a computer program for aspect-level sentiment analysis based on a BAGCNN model, wherein the computer program enables a computer to execute the aspect-level sentiment analysis method as described above.

[0052] An electronic device, comprising:

[0053] one or more processors;

[0054] Memory; and

[0055] One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs comprising instructions for executing the aspect-level sentiment analysis method as described above.

[0056] (III) Beneficial effects

[0057] The present invention provides an aspect-level sentiment analysis method, system, storage medium and electronic device based on the BAGCNN model. Compared with the prior art, it has the following beneficial effects:

[0058] The present invention includes obtaining a comment text sequence and a corresponding aspect word sequence; inputting the comment text sequence into a word embedding layer, obtaining a context word embedding matrix and an aspect word feature matrix based on a pre-trained word embedding model; inputting the context word embedding matrix into an attention self-encoding layer, obtaining a correlation context feature matrix based on a multi-head attention mechanism; inputting the correlation context feature matrix into a gated convolution layer, using convolution kernels of various sizes to parallelly calculate the convolution results, combining the aspect word feature matrix, obtaining a final feature matrix; inputting the final feature matrix into an output layer, obtaining a probability value of a corresponding aspect word emotion category based on a pre-trained classifier, and determining the emotion category. In the word embedding process, the context and aspect word information are fused, and no complex downstream structure is required to extract features, so as to more accurately mine the real emotions of various aspects of the comment text. BRIEF DESCRIPTION OF THE DRAWINGS

[0059] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0060] Figure 1 A flowchart of an aspect-level sentiment analysis method based on a BAGCNN model provided in an embodiment of the present invention;

[0061] Figure 2 A schematic diagram of the structure of a BAGCNN model provided by an embodiment of the present invention;

[0062] Figure 3 A structural block diagram of an aspect-level sentiment analysis system based on a BAGCNN model provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0063] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention are clearly and completely described. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0064] The embodiments of the present application provide an aspect-level sentiment analysis method, system, storage medium and electronic device based on the BAGCNN model, thereby solving the technical problem of failing to fully and effectively integrate the contextual information of the review text and thus failing to accurately mine the true emotions of various aspects of the review text.

[0065] The technical solution in the embodiment of the present application is to solve the above technical problems, and the overall idea is as follows:

[0066] The embodiment of the present invention includes obtaining a comment text sequence and a corresponding aspect word sequence; inputting the comment text sequence into a word embedding layer, obtaining a context word embedding matrix and an aspect word feature matrix based on a pre-trained word embedding model; inputting the context word embedding matrix into an attention autoencoder layer, obtaining a correlation context feature matrix based on a multi-head attention mechanism; inputting the correlation context feature matrix into a gated convolution layer, using convolution kernels of various sizes to parallelly calculate the convolution results, combining the aspect word feature matrix, obtaining a final feature matrix; inputting the final feature matrix into an output layer, obtaining a probability value of a corresponding aspect word sentiment category based on a pre-trained classifier, and determining the sentiment category. In the word embedding process, the context and aspect word information are fused, and no complex downstream structure is required to extract features, so as to more accurately mine the real emotions of various aspects of the comment text.

[0067] Example:

[0068] First, as Figure 1 As shown, the embodiment of the present invention provides an aspect-level sentiment analysis method based on the BAGCNN model, such as Figure 2 As shown, the BAGCNN model includes a word embedding layer, an attention autoencoder layer, a gated convolution layer and an output layer; the method includes:

[0069] S1. Preprocess the review text to be analyzed to obtain the review text sequence and the corresponding aspect word sequence;

[0070] S2, inputting the comment text sequence into the word embedding layer, obtaining a context word embedding matrix based on a pre-trained word embedding model; and extracting an aspect word feature matrix from the context word embedding matrix;

[0071] S3, inputting the context word embedding matrix into the attention self-encoding layer, and obtaining the associated context feature matrix based on the multi-head attention mechanism;

[0072] S4, inputting the associated context feature matrix into the gated convolution layer, using convolution kernels of various sizes to parallelly calculate the convolution results, and combining the aspect word feature matrix to obtain a final feature matrix;

[0073] S5. Input the final feature matrix into the output layer, obtain the probability value of the emotion category of the corresponding aspect word based on the pre-trained classifier, and determine the emotion category.

[0074] The embodiment of the present invention fuses context and aspect word information in the word embedding process, does not require complex downstream structure extraction features, and achieves more accurate mining of various aspects of the true emotions of the review text.

[0075] The following will introduce the various steps of the above solution in combination with specific content:

[0076] S1. Preprocess the review text to be analyzed to obtain the review text sequence and the corresponding aspect word sequence.

[0077] Preprocess the comment text to be analyzed and obtain a comment text sequence of length m and the corresponding aspect word sequence Wherein, aspect word a is a subsequence of length n in the comment text c; the main task of the aspect-level sentiment analysis method provided by the embodiment of the present invention is to determine the sentiment polarity corresponding to aspect word a in the comment text c; and Represent the i words in the context and aspect words respectively.

[0078] S2. Input the comment text sequence into the word embedding layer, obtain a context word embedding matrix based on a pre-trained word embedding model; and extract an aspect word feature matrix from the context word embedding matrix.

[0079] In this step, the comment text sequence c is The pre-trained word embedding model, such as the BERT model, is input in the form of, where the placeholders [CLS] and [SEP] represent the input start symbol and sentence symbol respectively; after encoding, the context word embedding matrix is ​​generated As shown in formula (1).

[0080] E c =BERT(c) (1)

[0081] According to the predefined position index of the aspect word in the comment text context, the context word embedding matrix E c Extracting aspect word feature representation As shown in formula (2).

[0082]

[0083] Where i′ represents the starting position of the aspect word in the encoded comment text context, m′ and n′ represent the encoded comment text context and the length of the corresponding aspect word sequence, respectively, and d emb Represents the word vector dimension.

[0084] In this step, the BERT model is used to fuse the context and aspect word information in the word embedding process, which is conducive to more accurately mining the true emotions of various aspects of the comment text.

[0085] S3. Input the context word embedding matrix into the attention self-encoding layer, and obtain the associated context feature matrix based on the multi-head attention mechanism.

[0086] Different from the recurrent neural network plus attention structure, the embodiment of the present invention applies the multi-head self-attention mechanism to the word embedding layer, and calculates the correlation between each word by multi-head parallel weighting. For example, in the context of "the price is reasonable although the service is poor", the modifier "reasonable" can obtain a larger weight for the aspect word "price", and the same is true for the modifier "poor" and the aspect word "service". Therefore, the introduction of the multi-head self-attention mechanism can effectively solve the problem of long-distance dependency of aspect words.

[0087] The S3 specifically includes:

[0088] S31, embedding the context words into a matrix E c Input the attention self-encoding layer, in the single-head self-attention calculation, the E c According to the parameter matrix W i Q , W i K , W i V Perform a linear transformation and use the result of the transformation as the Q, K, and V inputs of the scaled dot product attention.

[0089] head i =Attention(E c W i Q ,E c W i K ,E c W i V ) (3)

[0090] Among them, head i represents the context feature matrix extracted by the i-th single head; Attention represents the scaled dot product function,

[0091]

[0092] Among them, d in represents the input dimension of the K vector; softmax represents the activation function.

[0093] S32: Concatenate multiple single-head self-attention calculation results to obtain the associated context feature matrix A c ,

[0094] A c =[head 1 ;head 2;…;head h ]W h (5)

[0095] in, is the parameter matrix required for linear transformation after concatenating multiple results, d out Represents the associated context feature matrix A c The output dimension of ; “;” represents the concatenation operation. The essence of the scaled dot product attention represented by formula (5) is to use the dot product attention to calculate the similarity, which plays a regulating role by dividing by the input dimension.

[0096] S4. Input the associated context feature matrix into the gated convolution layer, use convolution kernels of various sizes to parallelly calculate the convolution results, and combine the aspect word feature matrix to obtain the final feature matrix.

[0097] In order to capture local features of the context, the prior art often uses a convolutional neural network sliding convolution window to extract feature information of adjacent words in the context. Since the convolution process is not affected by the sequence, setting up multiple sliding windows can extract local features of different levels in parallel. However, during the convolution process, context information that is not related to aspect words may become noise information, affecting the convolution results. Therefore, when the embodiment of the present invention uses a multi-level convolutional neural network to extract local feature information in parallel, combined with a gating mechanism, it can achieve selective extraction of local context features related to aspect words.

[0098] The S4 specifically includes:

[0099] S41, the associated context feature matrix A c The gated convolution layer is input, and convolution kernels of various sizes are used to calculate the convolution results in parallel; depending on whether an activation function is used, the convolution results include a first context feature matrix as a normal convolution result And the second context feature matrix after feature enhancement

[0100]

[0101]

[0102] in, W c and W c ′ represents the pre-trained parameter matrix, b c and b′ c represents the bias term; k represents the convolution kernel window size; d conv represents the number of output channels; tanh represents the activation function; “*” represents the convolution operation; m′ represents the vector length.

[0103] S42, according to and aspect word feature matrix E a , get the filter matrix F k ;

[0104] Specifically, in order to associate the comment text context information with aspect words in the gating mechanism, it is necessary to extract the most representative aspect word features, so the aspect word feature matrix E a After maximum pooling, The second context feature matrix after feature enhancement and the most representative aspect word feature information V a By adding, the relevance between the comment text context and the aspect words can be calculated; then the relu activation function is used to set the context feature information that is not related to the aspect word information to zero, thereby forming the filter matrix F k .

[0105]

[0106] Among them, W f represents the pre-trained parameter matrix, b f represents the bias term; relu represents the activation function;

[0107] S43, according to and F k , after maximum pooling, the third context feature matrix c is obtained k ;

[0108] The filter matrix is ​​used to further extract context feature information from the convolution result, that is, to achieve the gating effect. As shown in formula (9), With F k The corresponding elements are multiplied to represent the convolution result without using the gating mechanism, that is, the first context feature matrix of the normal convolution result above. By filtering the matrix F k , remove the contextual information of the comment text that is not related to the aspect words; finally, the most important convolutional features are selected as the third contextual feature matrix c through maximum pooling. k ;

[0109]

[0110] S44, merge the c corresponding to the convolution kernels of various sizes k , obtain the final feature matrix G;

[0111] Since multi-level convolution operations are parallel computing processes, they do not increase the complexity of the model. Therefore, in order to extract local context information at different levels, this step sets the convolution kernel window size to 3, 4, and 5. Finally, the convolution results at each level are concatenated as the feature matrix G extracted by the gated convolution network.

[0112] G=[c 3 ;c 4 ;c 5 ] (10).

[0113] S5. Input the final feature matrix into the output layer, obtain the probability value of the emotion category of the corresponding aspect word based on the pre-trained classifier, and determine the emotion category.

[0114] The pre-trained classifier in S5 includes a softmax classifier. Specifically, the final feature matrix obtained by convolution is normalized by the softmax classifier to obtain the probability value of the corresponding aspect word sentiment category. The sentiment categories in the embodiment of the present invention include positive, neutral and negative. The sentiment corresponding to the maximum probability value is the result predicted by the model, as shown in formula (11);

[0115]

[0116] Among them, G represents the final feature matrix; W o represents the pre-trained parameter matrix; b o Indicates bias.

[0117] In particular, in order to verify the effectiveness of the BAGCNN model provided by the embodiment of the present invention in solving aspect-level sentiment analysis tasks, three public datasets are used for experiments:

[0118] First, there are two datasets included in SemEval-2014 task 4, which are customers’ evaluations of Restaurant and Laptop respectively. Second, there is the Twitter dataset collected in the paper “Attention-based LSTM for aspect-level sentiment classification” published by Yequan Wang et al. mentioned in the background technology.

[0119] Each data in the above three data sets includes three fields: comment context, aspect words and corresponding sentiment categories, where the sentiment categories are composed of positive, neutral and negative.

[0120] Experimental parameter setting: word embedding dimension d obtained by pre-trained BERT modelemb is 768, the gated convolution window size is 3, 4 and 5, and the number of convolution output channels is d conv It is set to 100, and other hyperparameters are shown in Table 1. In order to evaluate the classification effect of the model, two evaluation indicators, Accuracy and Macro-F1, are selected. In order to reduce the impact of errors, the model is tested five times on three data sets, and the average of each experimental result is taken as the final result.

[0121] Table 1 Hyperparameter settings

[0122] parameter value dropout rate 0.1 batch size 32 epoch 6 optimizer Adam learning rate 2e-5

[0123] The experiment uses two evaluation indicators, Accuracy and Macro-F1, to represent the classification effect of the model, which are expressed as follows:

[0124] As shown in formula (12), Accuracy represents the ratio of the number of samples predicted correctly by the model to the total number of samples, where T represents the number of samples predicted correctly and N represents the total number of samples.

[0125]

[0126] As shown in formula (13), Macro-F1 is the harmonic mean of precision and recall represented by the F1 value of each category, where in each category, TP represents the number of predicted positive samples, FP represents the number of predicted incorrect positive samples, TN represents the number of predicted correct negative samples, and FN represents the number of predicted incorrect negative samples.

[0127]

[0128] First, in order to verify the rationality of the pre-trained BERT model in the embodiment of the present invention as a word embedding tool, the effectiveness of the multi-head self-attention mechanism and the applicability of the gated convolutional network, the following aspect-level sentiment analysis models (the embodiment of the present invention and two existing aspect-level sentiment analysis models in the background technology) are selected for analysis and comparison.

[0129] The experimental results are shown in Table 2. Various indicators of the present invention on the three data sets are optimal, which can verify the effectiveness of the present invention in this task.

[0130] Table 2 Model classification results

[0131]

[0132] Note: The data in bold indicates the best results

[0133] Second, in order to verify the advantage of low complexity of downstream structure in the embodiment of the present invention, the comparison models all select Glove as the word embedding tool. Remove the influence of the word embedding tool BERT model, replace the pre-trained BERT in the BAGCNN model with the Glove corpus as the word embedding tool, and form the model Glove-AGCNN.

[0134] At the same time, in order to compare with the complexity of sequence structure, the LSTM network plus attention structure replaces the gated convolutional network in the Glove-AGCNN model to construct another comparison model Glove-LSTM-ATT. During the experiment, all model experiments were controlled under the same conditions.

[0135] The experimental results are shown in Table 3, which records the number of parameters required for training each model and the size of the video memory occupied.

[0136] Table 3 Model dimensions

[0137] Models <![CDATA[Params×10 6 ]]> Memory(Mb) ATAE-LSTM 2.53 13.76 Glove-LSTM-ATT 2.07 16.90 IAN 2.17 12.40 Glove-AGCNN 1.02 11.13

[0138] This group of experiments is divided into parts I and II according to whether the comparison model uses a recurrent neural network. The overall comparison of the experimental results of parts I and II shows that the complexity of the model based on the recurrent neural network is higher than that of the non-recurrent neural network model. This is attributed to the fact that the recurrent neural network, as a sequence structure, cannot realize parallel operation and increase the overall complexity of the model. Among them, the complexity of the Glove-AGCNN model is second only to the lowest among the comparison models, because the attention layer of the model introduces more parameters that need to be trained. Compared with the Glove-LSTM-ATT model, both indicators of the Glove-AGCNN model are significantly better than the sequence structure, indicating that the downstream structure complexity of the embodiment of the present invention is lower than that of the model composed of a sequence structure.

[0139] Second, as Figure 3 As shown, an embodiment of the present invention provides an aspect-level sentiment analysis system based on a BAGCNN model, wherein the BAGCNN model includes a word embedding layer, an attention autoencoder layer, a gated convolution layer, and an output layer; the system includes:

[0140] A preprocessing module is used to preprocess the review text to be analyzed and obtain the review text sequence and the corresponding aspect word sequence;

[0141] A word embedding module, used for inputting the comment text sequence into the word embedding layer, obtaining a context word embedding matrix based on a pre-trained word embedding model; and extracting an aspect word feature matrix from the context word embedding matrix;

[0142] An attention self-encoding module, used for inputting the context word embedding matrix into the attention self-encoding layer, and obtaining a correlation context feature matrix based on a multi-head attention mechanism;

[0143] A gated convolution module, used to input the associated context feature matrix into the gated convolution layer, use convolution kernels of various sizes to calculate the convolution results in parallel, and combine the aspect word feature matrix to obtain a final feature matrix;

[0144] The output module is used to input the final feature matrix into the output layer, obtain the probability value of the emotion category of the corresponding aspect word based on the pre-trained classifier, and determine the emotion category.

[0145] It can be understood that the aspect-level sentiment analysis system based on the BAGCNN model provided in the embodiment of the present invention corresponds to the aspect-level sentiment analysis method based on the BAGCNN model provided in the embodiment of the present invention, and the explanations, examples and beneficial effects of the relevant contents can refer to the corresponding parts in the aspect-level sentiment analysis method based on blockchain, which will not be repeated here.

[0146] In a third aspect, an embodiment of the present invention provides a storage medium storing a computer program for aspect-level sentiment analysis based on a BAGCNN model, wherein the computer program enables a computer to execute the aspect-level sentiment analysis method as described above.

[0147] In a fourth aspect, an embodiment of the present invention provides an electronic device, including:

[0148] one or more processors;

[0149] Memory; and

[0150] One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs comprising instructions for executing the aspect-level sentiment analysis method as described above.

[0151] In summary, compared with the prior art, the present invention has the following beneficial effects:

[0152] 1. The embodiment of the present invention includes obtaining a comment text sequence and a corresponding aspect word sequence; inputting the comment text sequence into a word embedding layer, obtaining a context word embedding matrix and an aspect word feature matrix based on a pre-trained word embedding model; inputting the context word embedding matrix into an attention autoencoder layer, obtaining a correlation context feature matrix based on a multi-head attention mechanism; inputting the correlation context feature matrix into a gated convolution layer, using convolution kernels of various sizes to parallelly calculate the convolution results, combining the aspect word feature matrix, and obtaining a final feature matrix; inputting the final feature matrix into an output layer, obtaining the probability value of the corresponding aspect word emotion category based on a pre-trained classifier, and determining the emotion category. In the word embedding process, the context and aspect word information are fused, and no complex downstream structure is required to extract features, so as to more accurately mine the real emotions of various aspects of the comment text.

[0153] 2. The BERT model is used in the embodiment of the present invention to fuse context and aspect word information in the word embedding process, which is conducive to more accurately mining the true emotions of various aspects of the comment text.

[0154] 3. In order to address the defect that context information unrelated to aspect words may become noise information and affect the convolution result during the convolution process, the embodiment of the present invention reasonably uses a multi-level convolutional neural network to extract local feature information in parallel, and combines it with a gating mechanism to selectively extract local context features related to aspect words.

[0155] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0156] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. An aspect-level sentiment analysis method based on BAGCNN model, It is characterized in that The BAGCNN model includes a word embedding layer, an attention autoencoder layer, a gated convolution layer and an output layer; the method includes: S 1. Preprocess the review text to be analyzed to obtain the review text sequence and the corresponding aspect word sequence; S2, inputting the comment text sequence into the word embedding layer, obtaining a context word embedding matrix based on a pre-trained word embedding model; and extracting an aspect word feature matrix from the context word embedding matrix; S3, inputting the context word embedding matrix into the attention self-encoding layer, and obtaining the associated context feature matrix based on the multi-head attention mechanism; S4, inputting the associated context feature matrix into the gated convolution layer, using convolution kernels of various sizes to parallelly calculate the convolution results, and combining the aspect word feature matrix to obtain a final feature matrix; S5, inputting the final feature matrix into the output layer, obtaining the probability value of the emotion category of the corresponding aspect word based on the pre-trained classifier, and determining the emotion category; The pre-trained word embedding model in S2 includes a BERT model; S3 specifically includes: S31, embedding the context words into a matrix E c Input the attention self-encoding layer, in the single-head self-attention calculation, the E c According to the parameter matrix Perform a linear transformation and use the result of the transformation as the Q, K, and V inputs of the scaled dot product attention. Among them, head i represents the context feature matrix extracted by the i-th single head; Attention represents the scaled dot product function, Among them, d in represents the input dimension of the K vector; softmax represents the activation function; S32: Concatenate multiple single-head self-attention calculation results to obtain the associated context feature matrix A c , A c =[head 1 ;head 2 ;…;head h ]W h (3) in, is the parameter matrix required for linear transformation after concatenating multiple results, d out Represents the associated context feature matrix A c The output dimension of ; ";" indicates the concatenation operation.

2. The aspect-level sentiment analysis method based on the BAGCNN model as claimed in claim 1, It is characterized in that The S4 specifically includes: S41, the associated context feature matrix A c The gated convolution layer is input, and convolution kernels of various sizes are used to calculate the convolution results in parallel; depending on whether an activation function is used, the convolution results include a first context feature matrix as a normal convolution result And the second context feature matrix after feature enhancement in, W c and W′ c represents the pre-trained parameter matrix, b c and b′ c represents the bias term; k represents the convolution kernel window size; d conv represents the number of output channels; tanh represents the activation function; "*" represents the convolution operation; m' represents the vector length; S42, according to and aspect word feature matrix E a , get the filter matrix F k ; Among them, W f represents the pre-trained parameter matrix, b f Represents the bias term; aspect word feature matrix E a After maximum pooling, relu represents the activation function; S43, according to and F k , after maximum pooling, the third context feature matrix c is obtained k ; S44, merge the c corresponding to the convolution kernels of various sizes k , obtain the final feature matrix G; G=[c 3 ;c 4 ;c 5 ] (8) Among them, the convolution kernel window size k includes 3, 4 and 5.

3. The aspect-level sentiment analysis method based on the BAGCNN model as claimed in claim 1 or 2, It is characterized in that The method for obtaining the aspect word feature matrix in S2 includes: extracting aspect word feature representations from the context word embedding matrix according to predefined position indexes of aspect words in the comment text context.

4. The aspect-level sentiment analysis method based on the BAGCNN model as claimed in claim 1 or 2, It is characterized in that The pre-trained classifier in S5 includes a softmax classifier.

5. The aspect-level sentiment analysis method based on the BAGCNN model as claimed in claim 4, wherein the probability value of the sentiment category of the aspect word corresponding to S5 is expressed as in, G represents the final feature matrix; W o represents the pre-trained parameter matrix; b o Indicates bias.

6. An aspect-level sentiment analysis system based on the BAGCNN model, It is characterized in that Used to perform the aspect-level sentiment analysis method based on the BAGCNN model as claimed in claim 1, wherein the BAGCNN model includes a word embedding layer, an attention autoencoder layer, a gated convolution layer and an output layer; the system includes: A preprocessing module is used to preprocess the review text to be analyzed and obtain the review text sequence and the corresponding aspect word sequence; A word embedding module, used for inputting the comment text sequence into the word embedding layer, obtaining a context word embedding matrix based on a pre-trained word embedding model; and extracting an aspect word feature matrix from the context word embedding matrix; An attention self-encoding module, used for inputting the context word embedding matrix into the attention self-encoding layer, and obtaining a correlation context feature matrix based on a multi-head attention mechanism; A gated convolution module, used to input the associated context feature matrix into the gated convolution layer, use convolution kernels of various sizes to calculate the convolution results in parallel, and combine the aspect word feature matrix to obtain a final feature matrix; The output module is used to input the final feature matrix into the output layer, obtain the probability value of the emotion category of the corresponding aspect word based on the pre-trained classifier, and determine the emotion category.

7. A storage medium, It is characterized in that It stores a computer program for aspect-level sentiment analysis based on the BAGCNN model, wherein the computer program enables a computer to execute the aspect-level sentiment analysis method according to any one of claims 1 to 5.

8. An electronic device, It is characterized in that include: one or more processors; Memory; as well as One or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, the programs comprising a program for executing the aspect-level sentiment analysis method according to any one of claims 1 to 5.

Citation Information

Patent Citations

  • Attention-fused aspect-level user comment text sentiment analysis method and attention-fused aspect-level user comment text sentiment analysis system

    CN112329474A

  • Short text sentiment classification method based on CNN-BiMGU model

    CN112417098A

  • Hierarchical self-attention for machine comprehension

    US20210005195A1