Abstract
The purpose of aspect-level sentiment analysis is to identify the contextual sentence expressions given by sentiment for some aspects. For previous works, many scholars have proved the importance of the interaction between aspects and contexts. However, most existing methods ignore or do not specifically capture the position information of the aspect targets in the sentence. Thus, we propose an aspect-level sentiment analysis based on joint aspect and position hierarchy attention mechanism network. At the same time, the model adopts a joint approach to make the model of the aspect features and the position features. On the one hand, this method clearly captures the interaction between aspect words and context when inputting word vector information. On the other hand, this method can enhance the importance of position information in the sentence and boost the information retrieval ability of the model. Additionally, the model utilizes a hierarchical attention mechanism to extract feature information and to differentiate sentiment towards, which is similar to filtering useless information again. Experiment on the SemEval 2014 dataset represent that our model achieves better performance on aspect-level sentiment classification.
Keywords
Introduction
With the development of technology, online reviews have become a way for consumers to evaluate goods. Sentiment analysis has not only highly attention from domestic and foreign scholars in academic circles, but also has been favored by industry. In Natural Language Processing (NLP), aspect-based sentiment analysis is a fine-grained classification task, which can infer to two and more sentiment polarities according to the aspects in a given sentence. For example, given a restaurant review “while there’s a decent menu, it shouldn’t take ten minutes to get your drinks, and 45 minutes to get a dessert pizza”. We need to extract the three aspects of “menu”, “drinks” and “dessert pizza” from the sentence, and also be able to identify the sentiment polarity corresponding to the aspect terms in the model. In this review, the sentiment polarities of “menu”, “drinks” and “dessert pizza” are different, and their corresponding sentient polarities are positive and neutral respectively.
A large number of methods have been proposed for fine-grained classification tasks, and the effectiveness of these methods has been verified. In traditional methods, the bag-of-words model and TF-IDF are mainly used as features. Support vector machines (SVM) [26] and k-nearest neighbor (KNN) are used as classifiers to achieve classification tasks [29]. Although traditional methods are easy to implement and have a small amount of calculation, they are not suitable for highly complex data. In addition, if scholars want to obtain a robust model, they must manually construct features, which inevitably wastes a lot of manpower and financial resources. With the recent development of neural networks, neural network-based methods have also been used in aspect-level sentiment analysis tasks, such as Long short-term memory (LSTM) [23], Convolutional Networks [30] and Target-Connection LSTM (TC-LSTM) [7]. However, the above methods cannot effectively recognize the importance of words in a given sentence, leading to poor final results. But the attention mechanism effectively overcomes their shortcomings.
The attention mechanism was originally used in image recognition [18], machine translation and reading comprehension [4, 18] to extract local key features. Later, many scholars discovered that the attention mechanism can also be used to extract important features in the text. Compared with the model without attention mechanism, the effect of the model using the attention mechanism has been greatly improved. Therefore, a large number of scholars have proposed models based on attention mechanisms in fine-grained sentiment analysis tasks, such as AE-LSTM [32], ATAE-LSTM [32] and IAN [5].
As mentioned above, many models ignore the importance of location information to aspect terms. In order to solve this problem, we have added location information features to the model. At the same time, existing research shows that the interaction between aspect and context is very important for aspect-level sentiment analysis. By taking advantage of this idea, a joint aspect and position hierarchy attention mechanism is also adopted to the model. For instance, a sentence from the restaurant dataset that “this particular location certainly uses substandard meats”. After adding the position index to the model, the index of “meat” is regarded as “0”, which makes the model more accurate in terms of word extraction. If there is no location information, the model can extract both “specific location” and “meat” as aspect terms. In addition, the location information is used to classify the aspect word sentiment polarity, which also makes the network forget useless information when extracting features. Therefore, we make the model of the position information and obtained the feature representation of the position information. Since position information can be regarded as a feature in the sentence, which helps the model to better learn the important information in the sentence. At the same time, the model uses the position index to better extract the aspect words and identify the corresponding emotional polarity.
Eventually, the results of various baseline models are reproduced on the SemEval-2014 dataset and compare these results with joint modeling of aspect and position hierarchical attention mechanism. The results of comparing our model with many baseline models reveal that our model performs better than the baseline model.
In summary, the contribution of our proposed model can be summarized in the following perspectives: The position information of the aspect words is effectively added to the model, and the Bi-GRU network is adopted to better capture the important part of the context. GRU network not only has lower computational complexity than LSTM network, but also has fewer network parameters. A joint approach is utilized for aspect features and position features in the model, and a simple hierarchical attention mechanism is used to optimize the vector information in aspect-level sentiment analysis, which is conducive to the accurate extraction of the network. In order to optimize all parameters to prevent overfitting, the model is trained in a supervised learning framework through an end-to-end manner.
In this paper, the remaining parts are as follows. Specifically, the second part is relevant work of the article. The third part is a detailed introduction to the model. The fourth part is to interpret the experiment of the model and have a better understanding of our proposed model through the case analysis. The fifth section is the conclusion of the article.
Related work
The whole task of aspect-based sentiment analysis consists of several subtasks such as aspect extraction, entity extraction, and aspect sentiment classification [16]. In this part, we briefly introduce the development of sentiment analysis research methods in recent years. The research methods can be segmented into two aspects, including the traditional machine learning methods and the neural network methods.
Traditional machine learning methods are widely used in early sentiment analysis tasks. This method is mainly based on artificial feature engineering to realize sentiment classification. Many scholars usually use sentiment dictionaries to extract features, and use SVM [14], Bayes [9] and other classifiers to identify the sentiment direction corresponding to aspect words. Target-dependent [15] proposed statistic methods, which largely depended on the effectiveness of feature engineering works. Dcu [12] used the SVM classifier to distinguish the emotional polarity of the aspect words from the various features extracted by manual design. Nevertheless, traditional machine learning methods mentioned above are labor-intensive and prone to lead to high -dimensional and sparse text representation [22].
Therefore, many models based on neural network have been put forward in recent years. Recurrent Neural Networks (RNNs) such as LSTM [1] and GRU [10] have been used for sentiment analysis on data instances having variable length [6, 7]. Many tasks are also based on the convolutional neural networks (CNNs) [30] for feature extraction in NLP, which also confirmed that convolution operations can capture significant information in the text, and does not require a lot of labor to manually feature. At present, aspect-based sentiment analysis studies pay more attention to the fusion of target words and contextual words. TC-LSTM [7] take target information into account and achieve good results in target dependent sentiment classification. AT-LSTM [32] and ATAE-LSTM [32] input different target adopted the focus of attention mechanism in contextual words. ATAE-LSTM [6] and IAN [5] adopt two separate LSTM layers and an interactive attention mechanism. MemNet [32], RAM [20]and IARM [19] in sentence level memory into the deep memory network and multiple-hops attention model, integrating target information to the characterization of the sentence. CEA [13] proposed a unified model that leverages and integrates multiple knowledge sources to enhance its capabilities on ABSA. AF-LSTM [31] obtained a joint representation by independently learning between the context and aspect relationship, which joint attention mechanism to learn the relative importance of the context. GCAE [28] and PG-CNN [2] are based on CNN models, gate mechanism is used to realize the interaction between the target with the context token. Unified Generative Framework [8] defines the subtask target as a sequence of pointer index and emotion index, and adopts a unified framework for subtasks to handle multiple subtasks. SENTA [33] resolves confounding factors such as non-target aspects by applying backdoor adjustments. DCRAN [25] proposes the interactive relationship between the explicit self-supervision strategy and the subtasks of deep contextual information. MTKFN-Senti [24] proposed a unified model that leverages and integrates multiple knowledge sources to enhance its capabilities on ABSA. ATAE-LSTM(AA) [3] and AA-LSTM [3] are novel variant of LSTM, which merged the aspect information into the LSTM unit in the context modeling stage before the attention mechanism. SPAN-collapsed [17] learned the deep associations between sentences and aspects and the long-term dependencies within sentences by using the pre-trained Bert model. HAM-GLOVE [1] proposed a hierarchical attention-based approach for aspect-based polarity classification of text.
In spite of the above models having achieved certain results, it is still a challenge to distinguish different emotional polarities in fine-grained terms. Therefore, we propose a hierarchical attention mechanism model that combines aspect terms and location information. This model not only verifies the importance of aspect terminology’s location information in aspect hierarchical sentiment analysis, but also uses a hierarchical attention mechanism. The enhancement vector is regarded as the necessity of the object.
Methods
Although most of the researches on aspect-based sentiment analysis that rely on aspects have achieved certain results, these studies ignore the importance of the position index of the aspect word in the sentence. To solve this problem, the JAP-HAM model adds location information to enhance the characteristics of important information. At the same time, this paper also uses the Bi-GRU network to obtain the hidden units of the position vector and the aspect word vector, so that their hidden units can be combined to obtain new features through the LSTM network for feature extraction. Finally, the model uses the attention mechanism to obtain aspect words and their corresponding emotional polarity, and an end-to-end method is adopted to prevent the model from overfitting.
In this section, we introduce detail the Aspect-level sentiment analysis based on joint aspect and position hierarchy attention mechanism network (JAP-HAM). As shown in Fig. 1, the JAP-HAM model consists of input model, feature extraction module, attention mechanism module and training loss function model.

The JAP-HAM model.
In order to categorize the sentiment towards of the aspect in the sentence. In the model, the 300-dimensional GloVe [10] vector is used as a pre-training language model to acquire the representation of each word in the sentence. For a given sentence, the text c is composed of n words,
Position embedding
In order to reduce the interference of information irrelevant to the aspect term, and the weight of other words far away from the aspect term is reduced more quickly. Inspired by [22], we introduced positional embedding. For a given sentence, the position of the aspect word in the sentence is marked as “0”, and the corresponding position sequence is obtained according to the distance between the aspect words and other words in the given sentence. The formula is as follows:
In the traditional RNN, since the activation function continuously accumulates and expands during the back propagation process, it is easy to give rise to the gradient to explode and disappear. To solve this trouble, we proposed Bi-GRU to extract features.
Firstly, aspect word vectors are embedded into the left Bi-GRU network to obtain the hidden context representation, which is composed of forward hidden state
This model combines auxiliary information vector and word vector as the input of LSTM network. When the information feature is extracted by the LSTM network, the LSTM network obtains the unit status and updates the h
t
by looking at the hidden unit and the input information at the previous moment. For example, “Restaurant service is very good.”. When this sentence vector is input to the LSTM network, the sigmoid unit in the forgetting gate determines what information the cell state needs to discard or retain. The aspect term here may be restaurant and service. According to the location index, it be easier to find that “service” is an aspect term. The formula is as follows.
The LSTM network cannot well identify the emotional polarity corresponding to the aspect words in the sentence. In order to solve this problem, we adopt an attention mechanism to capture the important information in the sentence. As can be seen in Fig. 1, H is the matrix output by the LSTM network, which is a matrix composed of N hidden vectors. v
a
represents the embedding of aspect words and location information.
The final sentence representation is given by:
Although the model can predict the overall samples in the training data set well, the prediction results in the test set samples are very poor. This prediction result shows that the generalization ability of the model is not good. Such a problem may be that the model is too complex and leads to overfitting. However, in practice, we cannot well control the number of layers and neurons in the network well. Therefore, we use the neural network L2 regularization and dropout method to prevent the network from overfitting.
And the cross-entropy is utilized as a loss function to optimize all parameters in an end-to-end manner. The formula is as follows.
Dataset
The experiment adopts SemEval 2014 datasets to effectively verify the model. The dataset contains laptop reviews and restaurant reviews. Each review contains two or more aspect terms, and each aspect term has a corresponding sentiment polarity. The sentiment polarity in this experiment including three parts {positive, neutral and negative}. The training, verification and testing samples for each sentiment polarities are shown in Table 1.
The detailed data from Semeval 2014 DataSets
The detailed data from Semeval 2014 DataSets
In this experience, the model uses 300-dimension word vectors as pre-trained by GloVe on the SemEval 2014 dataset to initialize. The JAP-HAM model adopts randomly initialize from uniform distribution U (- 0.1, 0.1) to obtain the initial value of all weight matrices, and biases are all set to 0. The dimensions of word embedding and aspect embedding are both set to 300. The size of the hidden state is set to 200, and the size of the position embedding is set to 100. In the experiment, we use Pytorch as the model framework. The initial learning rate of the Adam optimizer is 0.01, the batch is size to 64 and the dropout rate is set to 0.1.
Evaluation metric
In order to assess the effect of the JAP-HAM model. We use Accuracy and Macro-F1 for evaluation, which is defined as:
In order to testify to performance availability of the JAP-HAM model by accuracy and Macro F1 value are used as the criteria to measure performance. At the same time, we also compare with several baseline models, including LSTM, CNN, TC-LSTM, AT-LSTM, ATAE-LSTM, ATAE-Bi-LSTM, MemNet, IAN, RAM, AF-LSTM(CORR), AF-LSTM(CONV), GCAE, DAuM, IARM, CEA, MTKFN-Senti, AA-LSTM, ATAE-LSTM(AA), PG-CNN and HAM-GLOVE. And we show in Tables 2 3.
Comparison of the performance on restaurant data sets
Comparison of the performance on restaurant data sets
Comparison of the performance on laptop data sets
DAuM uses auxiliary memory to implicitly generate aspect or terminology. And through the interaction between the two memories, the aspect words can provide more general terminology.
The effectiveness of the model in the data set is evaluated using accuracy and macro f1 values and compared with a series of baseline models. We can be seen from the Tables 2 3, the performance of our proposed model is the best model, and the performance of the two baseline models of LSTM and CNN are the worst model.
Since LSTM neural network ignores the importance of aspect terms, its accuracy is the lowest in whole baseline models. Although the CNN model uses different convolution kernels to extract information, its accuracy is 0.88%and 0.43%higher than that of the LSTM network in different data sets. However, a large amount of important information and merging operations will be lost during the convolution process, resulting in poor performance of the CNN model. TC-LSTM, AT-LSTM, ATAE-LSTM and ATAE-Bi-LSTM are derived models of LSTM. Compared with the LSTM model, the TC-LSTM network strengthens the interaction between aspects and sentences, and the accuracy of the two data sets is increased by 3.11%and 0.58%, respectively. Because ATAE-LSTM considers the attention mechanism, it is better than TC-LSTM in the accuracy of sentiment classification. In order to better capture semantic information and increase the accuracy of feature extraction, the ATAE-LSTM model is improved to a left-to-right and right-to-left bidirectional LSTM model. MemNet, IAN, and RAM models all consider the modeling of aspect words and use the attention mechanism to pay attention to important information. It can be seen from the above table that the use of aspect words and attention mechanism has a certain impact on the improvement of model performance.
Obviously, the attention mechanism enhances the performance of aspect-level sentiment analysis tasks to a certain extent, so the GCAE, DAuM, IARE and CEA models continue to improve the memory module, but their performance is lower than our model. Although the PG-CNN model uses parameterized filters and parameterized gates to effectively capture specific aspects of the characteristics, the CNN network loses information due to the reason that the performance is not as good as our model. It can be seen from Tables 2 3 that the accuracy of the PG-CNN network in the restaurant dataset is better than our model. However, it can be seen that our model is better than the PG-CNN model from the results of the laptop dataset and the F1 value of the restaurant. SPAN-collapsed model uses the Bert model for pre-training, which considers the deep associations between sentences and aspects and the long-term dependencies in sentences, but its effect is still inferior to our model. Because the HAM-GLOVE model ignores the importance of the location information corresponding to the aspect words. Compared with the HAM-GLOVE model, our model has improved accuracy by 1.515%and 1.256%in the two data and the F1 value has also increased 2.9%and 1.757%. In short, the JAP-HAM model uses a joint method to obtain features for the position hidden state and aspect word hidden state, and utilizes a hierarchical attention mechanism to strengthen the weight of important information. It is obvious that the JAP-HAM model has better performance. This method can effectively estimate the emotion of diverse aspects of the corresponding sentence and improve the accuracy of classification.
In this part, several models are utilized to prove the availability of the JAP-HAM model. First of all, through the analysis of the ATAE-Bi-LSTM model and the ATAE-LSTM model, because ATAE-Bi-LSTM is a derivative model of ATAE-LSTM, and the merely distinction between the two models is that the ATAE-Bi-LSTM model utilizes bidirectional LSTMs model, which is more conducive to capturing grammatical information between sentences. In addition, comparing the HAM-LSTM model with the ATAE-LSTM model, it can be seen that the difference between this model and the ATAE-LSTM is that the model uses a hierarchical attention mechanism, so that the model can optimize the vector. The Bi-GRU network is used in the ATAE-Bi-GRU model because the network parameters and calculations are less. Finally, it can be seen from the HAM-Bi-GRU model that the model only uses aspect terms and sentence representations, and the model does not consider the position information of the aspect words. As can be seen from Tables 4, 5 and Figs. 2, 3, among these models, the JAP-HAM model achieves optimum performance.
The Accuracy value of different models
The Accuracy value of different models
The Marco F1 value of different models

The Accuracy value of different models.

The Macro-F1 value of different models.
Since the Bi-LSTM network can obtain more semantic information, the performance of the ATAE-Bi-LSTM model is significantly better than that of the ATAE-LSTM model. For the HAM-LSTM model, the performance of this model is better than the ATAE-LSTM model. At the same time, it can be seen from the model effect that the ATAE-Bi-GRU model is better than the ATAE-Bi-LSTM model. Compared with HAM-Bi-GRU, it is concluded that the JAP-HAM model embeds the position vector to obtain the attention weight, instead of only strengthening the weight of the aspect word vector like the HAM-Bi-GRU model. Thus, based on the results of five experiments, the importance of position information in aspect-level sentiment analysis tasks can be demonstrated.
In summary, the JAP-HAM model is the best among the several experiments. We not only consider the importance of position information to aspect words, but also use the Bi-GRU model to reduce the amount of calculation and parameters, so that the model fulfills the best effect.
In this part, we use the three comments in the test set as cases to better understand our model. In order to analyze the contribution of words to sentences, we visualize the different importance the sentence attaches to the word in Table 6. In addition, the depth of the color represents the significance of the word in the sentence.
Case analysis
Case analysis
As we can see from the first instance, i.e., “the audio volume is quite low and virtually unusable in a room with any background.” According to the model we proposed, in this sentence, we first index the sentence, the index of the aspect word “audio volume” is “0”, and index to the left and right with the aspect word “audio volume” as the center. The result obtained is p={1,0,1,2,..., 12}. At the same time, the aspect words are embedded, and the result is t={0,1,1,0,..., 0}. Then, when the two auxiliary information vectors are obtained, the model uses the auxiliary vector and the sentence vector as the input of the LSTM network. In addition, in the LSTM network, important information is retained for the sentence by forgetting the gate and updating. Finally, the model uses the attention mechanism to add weight to some important words. For example, the model focuses on the word “low” around the aspect word according to the location index, and then focus on the relatively distant word “unavailable”. Using the attention mechanism, the model can well strengthen the weight of important information, and then gradually reduce the weight of other information. Obviously, the two words “low” and “unusable” are very important for the aspect term “audio volume” because they need to infer the emotion of the aspect term. It can be seen from Table 6 that these words all use darker colors to indicate how much the model attaches importance to the words, and the displayed results are consistent with our expected results.
Because traditional methods cannot effectively judge aspect information and emotional information. Therefore, this paper proposes a based on joint aspect and position hierarchy attention mechanism network (JAP-HAM). The model uses position information and aspect word information to form auxiliary information, and the important information is extracted in the LSTM network through the combination of auxiliary information vector and word vector. The cell state in the LSTM network is forgotten about the useless information in the sentence, and the important information is retained. At the same time, the model uses a hierarchical attention mechanism to enhance the important parts of the sentence to obtain the emotional polarity of the aspect words. Compared with traditional methods, the model proposed in this paper can effectively learn important information in sentences. At the same time, the JAP-HAM model is visually analyzed using case studies. Finally, the comparative experimental results on the two datasets of restaurant and laptop show that compared with multiple baseline models, the accuracy of our model and the macro-f1 value get better results.
Acknowledgments
This work was supported by the Postdoctoral Science Foundation of China (2016M592894XB), the National Natural Science Foundation of China (61866020), the general program of Yunnan Provincial Department of Science and Technology (2019FB082), and the general program of basic research in Yunnan Province (202001AT070047).
