Sentiment analysis method of graph attention network model based on syntactic and lexical enhancement
By introducing a syntactic lexical enhanced graph attention network into the aspect-level sentiment analysis model, combining syntactic distance and part-of-speech weight, the limitations of the existing model in complex contexts and long-distance dependency processing are solved, and the emotional extreme is significantly improved accuracy and performance of sexual classification.
Patent Information
- Application Number
- CN202411071411.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-06
- Publication Date
- 2024-11-22
- Estimated Expiration
- 2044-08-06
AI Technical Summary
The existing aspect-level sentiment analysis model has limitations in dealing with complex contexts and long-distance dependencies, especially the failure to fully consider the key role of different vocabulary in sentiment analysis, resulting in insufficient ability to capture key emotional information.
Using a graph attention network model based on syntactic lexical enhancement, by introducing syntactic distance and part-of-speech weights, combining self-attention mechanisms and multi-head attention mechanisms, dynamically adjusting the weight matrix to explicitly express the syntactic and semantic relationships between words, enhance the pair The ability to extract related characteristics of the aspect word.
It improves the accuracy of emotional polarity classification, can better handle complex contexts and long-distance dependencies, significantly improves the performance of aspect-level sentiment analysis, and performs better than multiple benchmark data sets.
Smart Images

Figure CN119003774A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an aspect-level sentiment analysis method, and in particular, designs a sentiment analysis method based on a syntactic-lexical enhanced graph attention network model. Background Art
[0002] With the development of natural language processing technology, aspect-based sentiment analysis (ABSA) has attracted widespread attention as an important branch of fine-grained sentiment analysis tasks. Its purpose is to predict the sentiment polarity of specific aspect words in a sentence, including positive, negative, and neutral. For example, in the sentence "The price is reasonable although the service is poor.", the aspect words "price" and "service" need to identify their corresponding sentiments "reasonable" (positive) and "poor" (negative), respectively.
[0003] Early aspect-level sentiment analysis methods mainly rely on traditional machine learning algorithms, such as support vector machines (SVM) and Naive Bayes, which are effective in processing the sentiment polarity judgment of the entire sentence. However, these algorithms usually find it difficult to use the details in the context for more specific analysis, so they have limitations in implementing aspect-level sentiment analysis.
[0004] With the rapid development of deep learning technology, aspect-level sentiment analysis methods have been significantly improved. For example, convolutional neural networks (CNN) and recurrent neural networks (RNN), including long short-term memory networks (LSTM) and gated recurrent units (GRU), have been applied to solve this problem. These models can significantly improve the performance of aspect-level sentiment analysis by learning complex word embeddings and contextual interactions. In addition, the introduction of the attention mechanism further enhances the model's grasp of relevant lexical relationships in the context, although it is still affected by sentence noise.
[0005] In response to the above challenges, researchers began to use graph convolutional network (GCN) technology. Zhang et al. designed a GCN method based on dependency parse tree, which transfers the representation of context words to target aspect words by connecting the boundaries between words and using graph convolution propagation mechanism. Sun et al. proposed the dependency tree convolution model (CDT), which uses bidirectional long short-term memory (Bi-LSTM) to learn sentence feature representation and further enhances embedding through GCN. Qian et al. proposed hierarchical syntactic graph and hierarchical lexical graph, and designed a two-layer interactive graph convolutional network (BiGCN) to fully integrate hierarchical syntactic and lexical graphs.
[0006] However, these models usually assign the same weight to each edge in the graph, failing to fully consider the key role of different words in sentiment analysis. To address this problem, Yuan et al. proposed a graph attention network model (G-ATT) combined with an adaptive attention mechanism, which assigns unequal weights to different edges in the graph, allowing the model to dynamically learn the importance of edges, thereby improving the ability to capture key sentiment information. Nevertheless, G-ATT still faces some challenges in dealing with long-distance dependencies, showing potential limitations in processing multi-dimensional information. Summary of the invention
[0007] In view of the problems and shortcomings of the prior art in aspect-level sentiment analysis tasks mentioned above, the present invention provides a sentiment analysis method based on a syntactic-lexical enhanced graph attention network model, which is a method based on the syntactic-lexical enhanced graph attention network (SLGAT) model. The method comprehensively considers the syntactic structure and lexical information of the text, and makes improvements in sentiment polarity classification. By introducing syntactic distance and part-of-speech weights, the model's ability to extract aspect-word related features is enhanced, making it more suitable for the field of sentiment analysis.
[0008] In order to solve the above problems, the present invention adopts the following technical solutions:
[0009] The present invention is a sentiment analysis method based on a graph attention network model enhanced by syntax and lexical structure, which is characterized by the following specific steps:
[0010] A. Text representation:
[0011] The review text sentence is divided into left text and right text, and the aspect word set is embedded in it to form the input sequence of the BERT pre-trained model. The hidden layer state is generated by the BERT model as the aggregate representation of the entire sentence.
[0012] B. Syntactic and lexical enhanced graph attention network:
[0013] The shortest dependency syntactic path length and syntactic distance vector between each word in the text and the aspect word are transformed through a linear layer and processed using a self-attention mechanism, and finally concatenated with the BERT embedding on the feature dimension.
[0014] The two dimensions of syntactic distance and part-of-speech category are considered at the same time to generate syntactic weights and part-of-speech weights. After normalization, the final weight matrix is generated through multiplication and combination to explicitly express the syntactic and semantic relationships between words.
[0015] Multi-dimensional feature information is extracted through a multi-head attention mechanism, and the mask vector and input features are combined for weighted summation to focus on the text parts related to aspect words.
[0016] The representation of the weighted multi-head attention is input into the linear layer, the linear output is converted into a probability distribution through the softmax function, and the sentiment polarity is classified and output.
[0017] The sentiment analysis method based on the graph attention network model with syntactic and lexical enhancement described in the present invention has a preferred technical solution: the generation of the text representation described in step (A) comprises the following specific steps:
[0018] A1. The model first divides the comment text sentence into the left text S L and the right text S R , the aspect word set A is embedded between the two. Then, the input sequence of the BERT model is constructed according to the following structure: X = [CLS] + S L +A+S R +[SEP]+A+[SEP].
[0019] A2. Each element in the sequence is converted into a BERT index through the tokenizer to form the final BERT input sequence. The first element in the hidden layer state generated by the BERT model is finally used as the aggregate representation of the entire sentence H = [h 1 ,h 2 ,h 3 ,...,h n ].
[0020] The event prediction method integrating the hierarchical attention mechanism described in the present invention has a preferred technical solution: the syntactic and lexical enhanced graph attention network described in step (A), and the specific steps are as follows:
[0021] B1. Using the open source natural language processing library SpaCy, calculate the shortest dependency syntactic path length and syntactic distance vector between each word in the text and all words in the aspect phrase. Transform the syntactic distance vector through a linear layer, process it using the self-attention mechanism, and finally concatenate it with the BERT embedding on the feature dimension.
[0022]
[0023] d'=wd(2)
[0024]
[0025] E=[H||SA(d')] (4)
[0026] B2. Generate syntactic weight and part-of-speech weight based on the two dimensions of syntactic distance and part-of-speech category. The normalized weights are combined by multiplication to obtain the final weight matrix. irepresents the syntactic distance between the i-th word and the aspect word, and seq_len represents the feature dimension size of the sentence, and is the calculated syntactic weight, represents the part-of-speech weight of the i-th word, and sets the threshold to 0.55, where A m It is based on w norm The mask matrix generated by the weight vector.
[0027]
[0028]
[0029] B3. Use the weighted multi-head attention mechanism to extract multi-dimensional feature information, combine the mask vector and input features for weighted summation, and focus on the text part related to the aspect words. Input the representation of the weighted multi-head attention into the linear layer, convert the linear output into a probability distribution through the softmax function, and classify and output the sentiment polarity. Define a weight matrix weights∈R n×n , weights i,j Represents the weight between the i-th word and the j-th word. The input data x is transformed into the query matrix Q, key matrix K and value matrix V through linear transformation. and is a learnable parameter matrix, i is the index of the attention head, where d k is the dimension of the bond matrix, W O is another learnable parameter matrix.
[0030] Q i =XW i Q (11)
[0031] K i =XW i K (12)
[0032] V i =XW i V (13)
[0033]
[0034] aspect=X·A m (15)
[0035] scores=linear(aspect)+Attention (16)
[0036] scores=softmax(scores·weights) (17)
[0037] Output=scores·V (18)
[0038] M=Concat(head 1 ,head 2 ,...,head h )W O (19)
[0039] Compared with the prior art, the present invention has the following beneficial effects:
[0040] By combining syntactic distance and part-of-speech information, the model's ability to extract features related to aspect words is enhanced, and the accuracy of sentiment polarity classification is improved. By dynamically adjusting the weight matrix, the syntactic and semantic relationships between words are explicitly expressed, enabling the model to better handle complex contexts and long-distance dependencies. The proposed SLGAT model outperforms existing methods on multiple benchmark datasets, verifying its effectiveness and application value in sentiment analysis tasks.
[0041] The present invention comprehensively considers the syntactic structure and lexical information of the text, makes improvements in sentiment polarity classification, and enhances the model's ability to extract features related to aspect words by introducing syntactic distance and part-of-speech weights, making it more suitable for the field of sentiment analysis. The effectiveness and application value of the proposed SLGAT model are verified through experiments on multiple benchmark datasets.
[0042] To overcome these problems, this paper proposes a syntactic-lexical enhanced graph attention network (SLGAT) model. By fully mining and utilizing syntactic structure and lexical information, this model designs a graph attention network model that can effectively extract feature representations related to aspect words and use weighted edge enhancement matrices to represent special dependencies. Through the weighted multi-head attention mechanism, the feature representations related to aspect words and the weighted edge embedding information are integrated, focusing on special syntactic dependencies.
[0043] Experimental results on multiple benchmark datasets show that the proposed SLGAT model performs significantly better than existing methods in aspect-level sentiment classification tasks, verifying its effectiveness and robustness. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] Figure 1 It is a model framework structure diagram of the present invention;
[0045] Figure 2 It is a dependency tree diagram of an example sentence of the present invention;
[0046] Figure 3Schematic diagram of the architecture of the multi-head attention mechanism of the present invention;
[0047] Figure 4 is a diagram of ablation experiment results of various data sets of the present invention;
[0048] Figure 5 This is a comparative experiment of the number of GAT layers for each data set of the present invention; DETAILED DESCRIPTION
[0049] The implementation process of the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods.
[0050] Reference Figure 1 The aspect-level sentiment analysis of the syntactic-lexical enhanced graph attention network of the present invention comprises the following steps:
[0051] Step 101: The model first divides the comment text sentence into left text S L and the right text S R , the aspect word set A is embedded between the two. Then, the input sequence of the BERT model is constructed as follows: X = [CLS] + S L +A+S R +[SEP]+A+[SEP]
[0052] Reference Figure 2 , the specific steps are as follows:
[0053] Step 201: Calculate the shortest dependency syntactic path length and syntactic distance vector between each word in the text and all words in the aspect phrase. The formula is as follows:
[0054]
[0055] The shortest dependency syntactic path length is d(s i ,s j ) and take the maximum value of these lengths, s i It is the word other than aspect words in the sentence. j It is an aspect phrase;
[0056] Step 202: The syntactic distance vector d is transformed through a linear layer, and then the self-attention mechanism is used to process the transformed syntactic distance vector, and finally the BERT embedding and self-attention output are concatenated on the feature dimension.
[0057] d'=wd (2)
[0058]
[0059] X=[H||SA(d')] (4)
[0060] Where w represents the linear layer, d k is the dimension of the key, SA(d') is the self-attention output, and "||" represents the merging operation. The concatenation process obtains the final text representation E = {e 1 l ,e 2 l ,e 3 l ...,e n l}, l represents the output of the last layer, and the input vector that combines syntactic information with semantic information is obtained.
[0061] Reference Figure 3 , the specific steps are as follows:
[0062] Step 301: Obtain the syntactic weight vector according to the following principle:
[0063]
[0064] Where d i represents the syntactic distance between the i-th word and the aspect word, and seq_len represents the feature dimension size of the sentence, and is the calculated syntactic weight;
[0065] Step 302: Obtain a part-of-speech weight vector according to the following principles
[0066]
[0067] in Indicates the part-of-speech weight of the i-th word. After obtaining the syntactic weight and part-of-speech weight, the syntactic weight and part-of-speech weight are normalized.
[0068] Step 303: Normalize the syntactic and part-of-speech weights to balance the differences in weight scales.
[0069]
[0070] Step 304: The normalized weights are combined by multiplication to obtain the final weight matrix
[0071]
[0072] Among them A m It is based on w norm Mask matrix generated by weight vector
[0073] Step 305: Use a weighted edge enhancement strategy to handle special dependencies.
[0074] Define a weight matrix weights∈R n×n, weights i,j Represents the weight between the i-th word and the j-th word;
[0075]
[0076]
[0077] In the formula, ε usually takes a minimum value, and if the word w i is an adjective ADJ, and w j is a noun in its dependency relationship, and the dependency relationship label is "amod", then it is defined as 0.8; if word w i is an adjective ADV, and w j is the noun ADJ in its dependency relationship, and the dependency relationship label is the modification relationship "amod", then it is defined as 0.7.
[0078] Step 306: By taking a weighted sum of the mask vector and the input features, the model focuses on the part of the text that is directly related to the aspect words, and calculates the attention score and weight by scaling the dot-product attention (ScaledDot-ProductAttention):
[0079]
[0080] Step 307: Then calculate the feature representation of the aspect words:
[0081] aspect=X·A m (12)
[0082] scores=linear(aspect)+Attention (13)
[0083] scores=softmax(scores·weights) (14)
[0084] Output=scores·V (15)
[0085] Step 308: The outputs of each head are then combined through a concatenation operation and integrated into the final output through another linear layer, integrating information from multiple perspectives
[0086] M=Concat(head 1 ,head 2 ,...,head h )W O
[0087] W O is another learnable parameter matrix, the formula is as follows
[0088] Using the syntactic-lexical enhanced graph attention network aspect-level sentiment analysis proposed in this paper, the performance of the proposed model was verified by comparing multiple models on four datasets, using accuracy and macro F1 value as evaluation indicators.
[0089] (1) Tested on four datasets: Twitter, Lap14, Rest14, and MAMS, with the accuracy and macro F1 value as indicators;
[0090] (2) The compared models include G-ATT, AEN-BERT, BART-ABSA, BERT-SPC, ASGCN, CDT, SD-GCN, BiGCN, R-GAT, SSEGCN, SGAN and SLGAT.
[0091] The experimental results show that the SLGAT model performs better than most comparison models on the Twitter, Lap14, Rest14 and MAMS datasets, especially on the MAMS dataset, with the accuracy and F1 score reaching 0.8973 and 0.9411 respectively.
[0092] Ablation experiments were conducted on Twitter, Lap14, Rest14, and MAMS datasets, and a systematic evaluation was conducted on the three key components of the model: syntactic embedding, aspect word feature extraction, and weight enhancement. Figure 4 :
[0093] (1) After removing the syntactic embedding, the accuracy and F1 score of each dataset generally decrease. For example, the accuracy of the Twitter dataset drops from 77.31% to 76.73%, and the F1 score drops from 76.23% to 75.79%.
[0094] (2) After removing the aspect word feature extraction, the model performance deteriorated, especially in the Restaurant dataset, where the F1 score dropped from 77.12% to 76.81%.
[0095] (3) After removing the weight-enhanced edges, the accuracy on most datasets changes little, but the F1 score of some datasets drops significantly. For example, in the Laptop dataset, the F1 score drops from 77.12% to 72.46%.
[0096] The effect of the number of graph attention network layers on model performance was evaluated on Twitter, Lap14, Rest14, and MAMS datasets. Figure 5 :
[0097] (1) Four-layer GAT shows the best performance in the Lap14 dataset, with an accuracy of 78.05% and an F1 value of 80.34% respectively. On the Twitter dataset, although the accuracy drops to 76.89%, the F1 value reaches 88.89%.
[0098] (2) For the five-layer GAT, the performance generally deteriorates. For example, in the MAMS dataset, the accuracy and F1 value drop to 76.64% and 76.09%, respectively.
[0099] The following analysis is made: The SLGAT model outperforms most of the comparison models on Twitter, Lap14, Rest14, and MAMS datasets. On the MAMS dataset, the accuracy and F1 score reach 0.8973 and 0.9411 respectively. SLGAT enhances information richness and generalization ability and reduces the impact of noise by integrating syntactic information, lexical information, and weighted multi-head attention mechanism. On the Rest14 dataset, it is slightly inferior to the R-GAT-BERT model, which may be due to ignoring the subtle differences and complex interactions between syntactic information and lexical information vectors. The four-layer GAT performs well on multiple datasets, and the moderate number of layers is crucial for feature integration and extraction.
[0100] Example 2, experimental verification and analysis
[0101] 2.1 Dataset and Evaluation Criteria
[0102] Four English benchmark datasets based on aspect-level sentiment analysis are used, including the Lap14 and Res14 comment datasets from SemEval-2014 Task 4, posts on Twitter, and the MAMS dataset. The datasets involve three sentiment categories: positive, neutral, and negative, where each piece of data is labeled with one or more aspect items and sentiment polarity labels. The specific distribution is shown in Table 1.
[0103] Table 1 Dataset distribution
[0104]
[0105] On these datasets, two standard evaluation indicators, accuracy (Acc) and macro F1 score (MF1), are used to measure model performance. The formula is
[0106]
[0107] Among them, TP stands for true positive examples, TN stands for true negative examples, FP stands for false positive examples, and FN stands for false negative examples. The macro F1 score is the harmonic average of precision and recall, and the formula is:
[0108]
[0109] Where i represents the category index. The macro-average F1 score takes into account the F1 scores of all categories and provides a balanced measure of the model's performance in multi-category classification tasks, especially when the categories in the dataset are unevenly distributed.
[0110] 2.2 Experimental Setup
[0111] In the experimental setting of this study, Google's pre-trained model bert-base-uncased is used to encode text, where the BERT dimension is set to 768. During training, the model uses the Rmsprop optimizer and sets the dropout ratio to 0.3 to prevent overfitting. The batch size of 16 and 48 samples is used in the training and verification stages, respectively, the model learning rate is 0.00002, and the L2 regularization is set to 0.0001 to prevent the model from overfitting. The specific parameters are shown in Tables 2 and 3.
[0112] Table 2 Experimental configuration
[0113]
[0114] Table 3 Experimental parameters
[0115]
[0116] 2.3 Comparative test
[0117] ASGCN (Aspect-Specific Graph Convolution-alNetwork): It combines the attention mechanism with the graph convolutional network. The model includes two sub-models: ASGCN-DG and ASGCN-DT, which respectively explore the different effects of using directed graphs and undirected graphs on text encoding.
[0118] CDT: The model uses graph convolutional networks to encode grammatical structures, enhances the semantic expression of the target, and provides rich structured contextual information for sentiment classification tasks.
[0119] SD-GCN: emphasizes the importance of aspect words in the analysis context, and extracts deep semantic features of the text by combining the attention mechanism with GCN.
[0120] G-ATT: Combining memory networks and graph attention mechanisms, it effectively integrates grammatical structure and local context information to identify key contextual words in text.
[0121] BiGCN: The model uses two parallel GCN models to simultaneously process syntactic dependencies at the lexical level and word co-occurrences at the corpus level, thereby fully capturing complex contextual information in the text.
[0122] R-GAT and R-GAT-BERT: These two models use syntactic tree pruning technology and apply the relationship graph attention mechanism for effective encoding. The R-GAT-BERT model further integrates BERT, significantly improving the performance of the model on sentiment analysis tasks.
[0123] AEN-BERT: Utilizes standard attention mechanism combined with multi-head attention, showing strong processing capabilities.
[0124] BART-ABSA: A unified generative model for aspect-based sentiment analysis, specifically designed to comprehensively handle various subtasks of aspect-level sentiment analysis in an end-to-end framework.
[0125] BERT-SPC: As a text pair classification framework, the BERT-SPC model optimizes the construction of input sequences by integrating aspect terms into the context, thereby improving the accuracy of classification tasks.
[0126] SSEGCN: The aspect-aware attention mechanism combined with the self-attention mechanism significantly enhances the model's deep perception of text data.
[0128] SGAN: Combined with the syntactic graph attention network, the knowledge of dependency types is incorporated into GAT, the attention weight of the edge is optimized, and the sensitivity of the model to the syntactic structure is further improved.
[0129] 2.4 Experimental Results and Analysis
[0130] By comparing these models on four datasets, the performance of the proposed model is verified using accuracy and macro F1 value as evaluation indicators. The specific results are shown in Table 4. These experiments show the efficiency and robustness of combining graph structure and attention mechanism.
[0131] The data in Table 2 reveals the impact of different word embedding technologies on model performance. Although GloVe word embedding technology performs well in capturing word co-occurrence relationships, its statistical nature limits its ability to capture deep semantics. In contrast, the pre-trained models based on BERT and its variants include: AEN-BERT, BART-ABSA, BERT-SPC. These models are trained with large-scale datasets, process complex semantic information more effectively, and dynamically adjust word meanings according to context, significantly outperforming the G-ATT model using GloVe.
[0132] The ASGCN model significantly improves the performance by using aspect word representation as attention weights. The CDT method effectively captures the semantic relationship between aspect words and opinion words by propagating context and dependency information, thereby improving the effect. Although SD-GCN uses position information to obtain relevant context, its tree structure contains a lot of useless information, which causes great interference. BiGCN successfully captures the long-term dependency relationship between aspect words and opinion expressions by constructing a dependency-based graph and applying a bidirectional graph convolutional network. Although R-GAT reconstructs the syntactic dependency tree, it lacks external knowledge support. SSEGCN combines the sparse self-attention mechanism to effectively filter out irrelevant words and improve the effect. SGAN uses the attention mechanism to focus on the most relevant words and aspects when predicting sentiment polarity.
[0133] The SLGAT model outperforms most of the comparison models on Twitter, Lap14, Rest14, and MAMS datasets, especially on the MAMS dataset, where the accuracy and F1 score reach 0.8973 and 0.9411 respectively. This shows that the model has advantages in processing sentiment analysis tasks with large datasets. SLGAT effectively captures the relationship between aspect words and context by integrating syntactic information, lexical information, and weighted multi-head attention mechanism, enhances the richness and generalization ability of information, and reduces the impact of noise through information screening.
[0134] However, the performance of the SLGAT model in the Rest14 dataset is slightly worse than that of the R-GAT-BERT model, probably because SLGAT simply concatenates the syntactic information and lexical information vectors, ignoring the subtle differences and complex interactions between the two.
[0135] Table 4. Comparison results of different models (Note: ours represents the SLGAT model in this paper, the best results are in bold, and “—” represents the lack of original data)
[0136] 2.5 Ablation Experiment
[0137] 2.5.1 Impact of Model Components
[0138] Ablation experiments were conducted on Twitter, lap14, Res14, and MAMS to systematically evaluate the three key components of the model: syntactic embedding, aspect word feature extraction, and weight edge enhancement. Figure 4 The results of Twitter / Lap14 / Rest14 MAMS ablation experiments are shown in the figure.
[0139] Syntactic embedding is done by concatenating BERT embedding and syntactic distance. After removing this processing, the accuracy (ACC) and F1 score of each dataset generally declined. Taking the Twitter dataset as an example, the accuracy dropped from 77.31% to 76.73%, and the F1 score decreased from 76.23% to 75.79%. This change shows that syntactic embedding plays a vital role in enhancing the model's ability to understand sentence structure, thereby promoting the accuracy and stability of sentiment classification.
[0140] In addition, when the aspect-related feature extraction module is removed, the performance of the model on different datasets also decreases, especially in the Restaurant dataset, where the F1 score drops from 77.12% to 76.81%. This result emphasizes the core role of aspect word feature extraction in accurately capturing and parsing the target emotional expression.
[0141] Finally, after eliminating the configuration of weight-enhanced edges, although the accuracy on most datasets changed little, the F1 scores of some datasets dropped significantly (for example, the F1 score in the Laptop dataset dropped from 77.12% to 72.46%), indicating that weight-enhanced edges are crucial for the model to analyze the interaction between words and their impact on the overall sentiment tendency.
[0142] 2.6 GAT layer analysis
[0143] 2.6.1 Impact of GAT Layers
[0144] In order to study the impact of the number of layers of the graph attention network on the model performance, the number of layers of GCN is set to respectively to evaluate the impact of different numbers of layers on the model accuracy and F1 value. The experiments are conducted on 4 datasets, such as Figure 5 The comparison experiment of the number of layers of Twitter GAT / Lap14GAT / Rest14 GAT / MAMS GAT is shown.
[0145] The results show that GAT exhibits the best performance in the Lap14 dataset with a four-layer structure, with an accuracy and F1 value of 78.05% and 80.34% respectively. This indicates that the four-layer GAT can effectively balance feature extraction and information integration and optimize the overall performance. In addition, when GAT processes the Twitter dataset, although the accuracy drops slightly to 76.89%, the F1 value is as high as 88.89%, showing its excellent sentiment classification ability when analyzing complex social media texts. However, when the number of layers increases to five, the performance of all datasets generally decreases, such as the accuracy and F1 value of the MAMS dataset drop to 76.64% and 76.09% respectively. The performance degradation may be due to the excessive fusion of features and gradient problems caused by too many layers, which affect the stability of the model. Overall, the four-layer GAT performs well on multiple datasets, and a moderate number of layers is crucial for feature integration and extraction.
[0146] 2.6 Case Analysis
[0147] In order to evaluate the performance and expression of the proposed model in practical applications, individual cases are selected from the four datasets and compared with the ASGCN, CDT, SSEGCN, and SLGAT classic models. The detailed experimental results are shown in Table 5.
[0148] Sentence 1 contains an aspect word "service", and the distance between "service" and the opinion word "dreadful" is close, and the syntactic dependency is also obvious, so all models made correct predictions. Sentence 2 contains multiple aspect words "fact" and "i5", and the aspect sentiment polarity is different. The first group of models mainly rely on context and attention mechanism, which cannot capture the sentiment characteristics of specific aspects well, resulting in misjudgment. Although the third group of models introduced some syntactic information, it still failed to completely solve this problem. The SLGAT model, by combining syntactic distance, syntactic weight and lexical weight, can better guide the model to pay attention to opinion words related to aspect words, enrich the semantic features of the text, and then make correct predictions. In sentence 3, "Tequila" and "notbe disappointed" are far apart, and the emotional expression is not obvious. The first three groups of models failed to correctly capture the emotional association, resulting in prediction failure. The SLGAT model integrates and strengthens the feature representation and weight edge embedding information related to aspect words through the multi-head attention mechanism, carefully refines the context information related to aspect words, and focuses on special syntactic dependencies, so it can make correct predictions. In sentence 4, "keyboard" does not have a clear corresponding opinion word, and the first three groups of models also failed to successfully identify its sentiment tendency, resulting in prediction failure. The SLGAT model effectively extracts the relevant feature representation of aspect words through its designed syntactic-lexical enhanced graph attention network, and can learn implicit emotions from semantics to make correct judgments. Experimental results show that the SLGAT model performs significantly better than existing methods in aspect-level sentiment classification tasks on four benchmark datasets, further demonstrating its effectiveness and robustness.
[0149] Table 5 Case prediction results
[0150]
[0151] (Note: P, O, N represent positive, neutral, and negative respectively; aspect words are bolded)
[0152] It can be seen from the experiments that the syntactic-lexical enhanced graph attention network (SLGAT) model of the present invention is used for aspect-level sentiment analysis. This model makes full use of syntactic and lexical information to improve the accuracy of sentiment analysis. The study designed an aspect word feature extraction and weighted edge enhancement strategy to generate aspect word feature representations through syntax and part-of-speech weights. In the graph attention network, a weighted multi-head attention mechanism is introduced to integrate aspect word features and weighted edge enhancement matrices, thereby more accurately capturing aspect-related information and significantly improving performance. The experimental results of four public datasets verify the effectiveness of the model and highlight the importance of syntactic and lexical information.
Claims
1. A sentiment analysis method based on a graph attention network model with syntactic and lexical enhancement, characterized in that: include: A. Design a graph attention network model that combines syntactic distance, syntactic weight and lexical weight to extract relevant feature representations of aspect words and use weighted edge enhancement strategy to handle special dependencies; B. Through the weighted multi-head attention mechanism, we integrate the feature representations and weighted edge embedding information related to aspect words and focus on special syntactic dependencies.
2. The sentiment analysis method based on the graph attention network model with syntactic and lexical enhancement according to claim 1 is characterized in that: Syntactic embedding is performed before graph attention network modeling, including the following steps: A1. Use the BERT pre-trained model to obtain an input sequence containing contextual semantic information: H=[h1,h2,h3,...,h n ] (1); A2. Calculate the shortest dependency syntactic path length and syntactic distance vector between each word in the text and all the words in the aspect phrase: A3, where the shortest dependency syntactic path length is d(s i ,s j ) and take the maximum value of these lengths, s i It is the word other than aspect words in the sentence. j It is an aspect phrase; A4. Use the self-attention mechanism to process the converted syntactic distance vector, and concatenate the BERT embedding and self-attention output in the feature dimension: d' = wd (3); E = [H||SA(d')] (5); Where w represents the linear layer, d k is the dimension of the key, SA(d') is the self-attention output, "||" indicates the merge operation, and the concatenation process is performed to obtain the final text representation. l represents the output of the last layer, and the input vector is obtained by combining syntactic information with semantic information.
3. The sentiment analysis method based on the graph attention network model with syntactic and lexical enhancement according to claim 1 is characterized in that: The extraction of the related feature representation of the word comprises the following steps: B1. Derive the syntactic weight vector to express the relative importance of each word according to the following principles: B2, where d i represents the syntactic distance between the i-th word and the aspect word, and seq_len represents the feature dimension size of the sentence, and is the calculated syntactic weight; B3. Calculate part-of-speech weights: B4, among which Indicates the part-of-speech weight of the i-th word. After obtaining the syntactic weight and part-of-speech weight, the syntactic weight and part-of-speech weight are normalized: B5. The normalized weights are combined by multiplication to obtain the final weight matrix, and then the threshold is set to determine which weights are sufficient to indicate the high correlation between words and aspects: B6, among which A m It is based on w norm The mask matrix generated by the weight vector.
4. The sentiment analysis method based on the graph attention network model with syntactic and lexical enhancement according to claim 1 is characterized in that: The method of using the weight edge enhancement strategy to process special dependencies includes the following steps: Define a weight matrix weights∈R n×n , weights i,j Represents the weight between the i-th word and the j-th word; In the formula, ε usually takes a minimum value, and if the word w i is an adjective ADJ, and w j is a noun in its dependency relationship, and the dependency relationship label is "amod", then it is defined as 0.8; if word w i is an adjective ADV, and w j is the noun ADJ in its dependency relationship, and the dependency relationship label is the modification relationship "amod", then it is defined as 0.
7.
5. The sentiment analysis method based on the graph attention network model with syntactic and lexical enhancement according to claim 1 is characterized in that: The weighted multi-head attention mechanism integrates the feature representation and weight edge embedding information related to aspect words, including the following steps: D1, the input data x is transformed into the query matrix Q, key matrix K and value matrix V through linear transformation, and is a learnable parameter matrix, i is the index of the attention head, and the formula is as follows Q i =XW i Q (14); K i =XW i K (15); V i =XW i V (16); D2. In each head, the attention score and weight are calculated by scaling the dot product attention ScaledDot-ProductAttention: D3, d in the formula k is the dimension of the key matrix; the scaling operation is intended to prevent the inner product from being too large and affecting the gradient of the softmax function; the feature representation of the aspect word is calculated: aspect=X·A m (18); scores=linear(aspect)+Attention (19); scores=softmax(scores·weights) (20); Output = scores · V (21); D4. Finally, the outputs of each head are combined through a concatenation operation and integrated into the final output through another linear layer, integrating information from multiple perspectives, W O is another learnable parameter matrix, the formula is as follows M=Concat(head1,head2,...,head h )W O (22)。
Citation Information
Patent Citations
Text sentiment analysis method based on graph attention network
CN116702753A
Method and system for aspect-level sentiment classification by graph diffusion transformer
US20220092267A1
Cited By
Short video content auditing system based on sentiment analysis
CN120014524A
