Sentiment analysis studies are currently based on the application of deep learning approaches, which requires training and testing on specialized datasets. For English, popular sentiment analysis datasets include: Stanford Sentiment Treebank datasets SST[socher2013recursive], IMDB dataset of movie reviews [maas2011learning], Twitter sentiment datasets [nakov2016semeval, rosenthal2017semeval], and many others. For other languages, much less datasets have been created. In Russian several sentiment evaluations were previously organized, including ROMIP2012-2013 and SentiRuEval2015-2016 [chetviorkin2013evaluating, loukachevitch2015entity, loukachevitch2016rubtsova]
, which included the preparation of annotated data on reviews (movies, books and digital cameras), news quotes, and Twitter messages. The best results on these datasets were obtained with classical machine learning techniques such as SVM[chetviorkin2013evaluating], early neural network approaches [trofimovich2016comparison]
, or even engineering methods based on rules and lexicons[kuznetsova2013testing]. Currently, the results achieved in the above-mentioned Russian evaluations can undoubtedly be improved.
In this study, we test standard neural network architectures (CNN, LSTM, BiLSTM) and recently appeared BERT architectures on previous Russian sentiment evaluation datasets. We compare two variants of Russian BERT [devlin2018bert] and show that for all sentiment tasks in this study the conversational variant of Russian BERT performs better. The best results were achieved by BERT-NLI model, which treats sentiment classification problem as the natural inference task. In one of the tasks this model practically achieves the human level of sentiment analysis.
The contributions of this paper are as follows:
we renew previous results on five Russian sentiment analysis datasets using the state-of-the-art methods,
we test new conversational Russian BERT model in several sentiment analysis tasks and show that it is better than previous Russian RuBERT model,
we show that the BERT model, which treats sentiment analysis as a natural language inference task achieves the best results on all datasets under analysis.
This paper is structured as follows. In Section 2 we present sentiment analysis datasets previously created for Russian shared tasks, best methods and achieved results in previous evaluations. Section 3 describes preprocessing steps and methods applied to sentiment analysis tasks in the current study, including several BERT-based models. Section 4 presents the achieved results. In Section 5 we analyse the errors of models on difficult examples. Section 6 describes other available Russian sentiment analysis datasets and methods applied to these datasets.
In our study we consider five Russian datasets annotated for previous Russian sentiment evaluations: news quotes of the ROMIP-2013 evaluations [chetviorkin2013evaluating] and Twitter datasets of two SentiRuEval evaluations 2015-2016 [loukachevitch2015entity, loukachevitch2016rubtsova]. Table 1 presents the datasets under evaluation, the volumes of their training and test parts, main quality measures, achieved results, and the best methods. Table 2 contains the distribution of the datasets texts by sentiment classes.
|Dataset||Train vol.||Test vol.||Metrics||Result||Method|
|News Quotes ROMIP-2013333http://romip.ru/en/collections/sentiment-news-collection-2012.html||4260||5500||62.1||Lexicons+Rules|
|SentiRuEval-2016 Telecom555https://drive.google.com/drive/folders/0BxlA8wH3PTUfV1F1UTBwVTJPd3c||8643||2247||55.9||2-layer GRU|
|SentiRuEval-2016 Banks555https://drive.google.com/drive/folders/0BxlA8wH3PTUfV1F1UTBwVTJPd3c||9392||3313||55.1||2-layer GRU|
2.1 News Quotes Dataset
For creating news quotes collection, opinions in direct or indirect speeches were extracted from news articles [chetviorkin2013evaluating]
. The task was to classify quotations as neutral, positive or negative speaker comment about the topic of the quotation. It can be seen in Table 2 that class distribution in the dataset was rather balanced. The main quality measure was.
The participants experimented with classical machine learning approaches such as Naive Bayes and SVM classifiers, but the best results were obtained by a knowledge-based approach using a large sentiment lexicon and rules: 62.1 ofmeasure and 61.6 of accuracy score. This can be explained with great variety of topics and topic-related sentiment discussed in news quotes [chetviorkin2013evaluating].
|Train sample||Test sample|
|News Quotes ROMIP-2013||16||36||48||11||33||56|
2.2 Twitter Datasets
Twitter datasets were annotated for the task of reputation monitoring [amigo2013overview, loukachevitch2015entity]. The goal of Twitter sentiment analysis at SentiRuEval was to find sentiment-oriented opinions or positive and negative facts about two types of organizations: banks and telecom companies. In such a way the task can be classified as targeted (entity-oriented) sentiment analysis problem. Similar evaluations were organized twice in 2015 and 2016, during which four target-oriented datasets were annotated (Table 1). In 2016 training datasets in both domains were constructed by uniting of training and test data of the 2015 evaluation and, therefore they were much larger in size [loukachevitch2016rubtsova].
The participating systems were required to perform a three-way classification of tweets: positive, negative or neutral. It can be seen in Table 2 that neutral class was prevailing in the datasets. For this reason, the main quality measure was measure, which was calculated as the average value between measure of the positive class and measure of the negative class. measure of the neutral class was ignored because this category is usually not interesting to know. But this does not reduce the task to the two-class prediction because erroneous labeling of neutral tweets negatively influences on and . Additionally micro-average measures were calculated for two sentiment classes [loukachevitch2015entity, loukachevitch2016rubtsova].
It can be seen in Table 1 that the results in 2016 are much higher than in 2015 for the same tasks. There can be two reasons for this. The first reason is the larger volume of the training data in 2016. The second reason is the use by the participants of more advanced methods, including neural network models and embeddings.
We compare the following groups of sentiment analysis methods on the above-described datasets. SVM with pre-trained embeddings is a baseline for our study. We chose FastText666http://docs.deeppavlov.ai/en/master/features/pretrained_vectors.html embeddings (dimension 300) because of its better results compared with other types of Russian embeddings such as ELMo666http://docs.deeppavlov.ai/en/master/features/pretrained_vectors.html, Word2Vec777https://rusvectores.org/ru/models/, and GloVe888http://www.cs.cmu.edu/~afm/projects/multilingual_embeddings.html in preliminary studies. To submit data to the SVM algorithm, averaging token embeddings in a sentence was used. Grid search mechanism from scikit-learn999https://scikit-learn.org/stable/
framework was utilized to obtain optimal hyperparameters.
Since most of the data are tweets containing noise information, significant text preprocessing was implemented. The full cycle contained the following steps:
replacing URLs with url token;
replacing mentions with user token;
replacing hashtags with hashtag token;
replacing emails with email token;
replacing phone numbers with phone token;
replacing emoticons with appropriate tokens like sad, happy, neutral;
removing all special symbols except punctuation marks;
replacing any repeated more than 2 times in a row letter with 2 repetitions of that letter;
lemmatization and removing stop words.
It is worth to note that the last point was applied only in the case of SVM and classic neural networks. For BERT-based methods it did not make any difference and gave not a considerable change of about 0.01%.
3.2 Classical neural networks
The first group of methods is a set of classical convolutional and LSTM neural networks.
The architecture of the convolutional neural network considered in this paper is based on approaches[cliche2017bbtwtr, zhang2015]. Input data is represented as a matrix of size , where is the number of tokens in the tweet and is the dimension of the embedding space. The optimal matrix height
was chosen experimentally. If necessary, a sentence is truncated or zero-padded to the required length.
After that several convolution operations of various sizes are applied to this matrix in parallel. A single branch of convolution involves a filtering matrix with the size of the convolution
equal the number of words it covers. Then output of each branch is max-pooled. This helps to extract the most important information for each convolution, regardless of feature position in the text. After all convolution operations, obtained vectors are concatenated and sent to a fully connected layer, which is then passed through the softmax layer to give the final classification probabilities. In our model we chose the number of convolution branches equal towith windows sizes respectively. To reduce overfitting, dropout layers with probability of were added after max-pooling and fully connected layers.
The main idea of LSTM recurrent networks is the introduction of a cell state of dimension
equal to the dimension of network, running straight down the entire chain and ability of LSTM to remove or add information to the cell state using special structures called gates. This helps to avoid the exploding and vanishing gradient problems during the backpropagation training stage in recurrent neutral networks. In our work, we choseequal to the size of token embeddings.
Besides, we used the bidirectional LSTM (BiLSTM) model, which represents two LSTMs stacked together. Two networks read the sentence from different directions and their cell states are concatenated to obtain vector of dimension . As well as in LSTM network, this vector is sent to a fully connected layer of size 40 and then passed through a softmax layer to give the final classification probabilities.
In both LSTM architectures we used dropout to reduce over-fitting by adding a dropout layer with probability of before and after the fully connected layers. For all described neural networks we used pre-trained Russian FastText embeddings with dimension of .
3.3 Fine-tuning BERT model
The second group of methods is based on two pre-trained Russian BERT models and several approaches of application of BERT [devlin2018bert] to the sentiment analysis task. The utilized approaches can be subdivided into single sentence classification and constructing auxiliary sentences approach [utilizingbertforsa], which converts a sentiment analysis task into a sentence-pair classification problem. It seems possible since input representation of BERT can represent both a single sentence and a pair of sentences considering them as a next sentence prediction task.
The BERT sentence-single model uses only an initial sentence as an input and represents a vanilla BERT model with an additional single linear layer with matrix on the top. Here denotes the number of classes and the dimension of the hidden state. For the classification task, the first word of the input sequence is identified with a unique token [CLS]
. The input representation is constructed by summing the initial token, segment, and position embeddings for any token in the sequence. Classification probabilities distribution is calculated using the softmax function.
The BERT sentence-pair model architecture has some differences. The input representation converts a pair of sentences in one sequence of tokens inserting special token [SEP] between them. The classification layer is added over the final hidden state of the first token .
For the targeted task, there is a label for each object of sentiment analysis in a sentence so the real name of an entity was replaced by a special token. For example, the initial tweet ”Sberbank is a safe place where you can keep your savings” is converted to ”MASK is a safe place where you can keep your savings”.
Two sentence-pair models use auxiliary sentences and based on question answering (QA) and natural language inference (NLI) tasks. The auxiliary sentences for the targeted analysis are as follows:
pair-NLI: ”The sentiment polarity of MASK is”
pair-QA: ”What do you think about MASK?”
The answer is supposed to be one from the Positive, Negative, Neutral set.
In case of the general sentiment analysis task, there is one label per sentence and no objects of sentiment analysis to mask. So we proposed to assign the token to the whole sentence. Therefore the initial sentence ”56% of Rambler Group was sold to Sberbank” is converted to ”MASK = 56% of Rambler Group was sold to Sberbank”. The same auxiliary sentences were constructed for this task.
In our study, we compare two different pre-trained BERT models from DeepPavlov framework [deeppavlov]:
RuBERT, Russian, cased, 12-layer, 768-hidden, 12-heads, 180M parameters, trained on the Russian part of Wikipedia and news data101010http://docs.deeppavlov.ai/en/master/features/models/bert.html.
Conversational RuBERT, Russian, cased, 12-layer, 768-hidden, 12-heads, 180M parameters, trained on OpenSubtitles, Dirty, Pikabu, and Social Media segment of Taiga corpus101010http://docs.deeppavlov.ai/en/master/features/models/bert.html.
During the fine-tuning procedure, we set dropout probability at
, number of epochs at, initial learning rate at , and batch size at .
To compare different models, we calculated standard metrics such as accuracy and . Besides, we calculated the metrics necessary for comparison with the participants of the competition: and , which take into account only positive and negative classes. All the reported results were obtained by averaging over five runs. To distinguish two pre-trained BERT models, special label (C) is used for Conversational RuBERT.
4.1 Results of News Quotes Dataset
Table 3 describes results of the models on the ROMIP-2013 news quotes dataset.
As it was mentioned before, the participants of the evaluation applied traditional machine learning methods (SVM, Naive Bayes classifier, etc.) and knowledge-based methods with lexicons and rules. The knowledge-based methods achieved the best results. This was explained by thematic diversity of news quotes, when the test collection could contain sentiment words and expressions absent in the training collection.
It can be seen in the current evaluation, that the task was difficult even for some models with embeddings (SVM, CNN, LSTM, BiLSTM). Among traditional neural network approaches, BiLSTM obtained the best results.
The use of BERT drastically improves the results. Better results are achieved by conversational RuBERT models. The best configuration is BERT-pair-NLI, when additional MASK token is assigned to the whole sentence and the sentence inference task was set.
4.2 Results on Twitter Datasets
Tables 4 and 5 describe results of the models on two Twitter datasets of SentiRuEval-2015. The specific feature of this evaluation was a long 6 months period of time between downloading the training and test collections. In this period Ukrainian topics of tweets about telecom operators and banks led to great differences between the training and test collections.
These differences between collections showed up in very low obtained results on the bank 2015 dataset [loukachevitch2015entity]. The problem was also complicated for the current SVM+FastText, CNN, LSTM and BiLSTM models. Only BERT-based methods could significantly improved the results. Conversational RuBERT in the NLI setting was the best method again.
It is interesting to note that one participant of the SentiRuEval-2015 uploaded manual annotation of the test Telecom dataset and obtained the results described in Table 4 as Manual [loukachevitch2015entity]. It can be seen that the best BERT results are very close to the manual labeling.
Tables 6 and 7 describe results of the models on two Twitter datasets of SentiRuEval-2016. In contrast to previous evaluations, baseline results of the 2016 competition (the best results achieved by participants) are better than the SVM+FastText and CNN models. This is due to the fact that the participants applied neural network architectures with embeddings and combined the SVM method with existing Russian sentiment lexicons [trofimovich2016comparison, loukachevitch2016rubtsova].
5 Analysis of Difficult Examples
The authors of previous Russian sentiment evaluations described examples, which were difficult for most participants of the shared tasks [chetviorkin2013evaluating, loukachevitch2015entity, loukachevitch2016rubtsova]. We gathered these examples and obtained the collection of 21 difficult samples. Now we can compare the performance of the models on this collection.
The difficult examples are translated from Russian and can be subdivided into several groups.
The first type of difficulties concerns the problem of the absence of a sentiment word or word with positive or negative connotations in the training collection, which was a serious problem for previous approaches. From this group one example was again erroneously classified by all current models:
”Sberbank imposes credit cards”. (Ex.1)
The following sentence from this group was successfully processed by all models:
”In the capital there was a daring robbery of Sberbank”. (Ex.2)
The second groups comprises examples with complicated word combinations that include words of different sentiments and/or sentiment operators. From these examples, the following example was problematic for all models:
”Secretary of the Presidium of the General Council of United Russia, State Duma Deputy Chairman Sergei Neverov said on Saturday that the party is not afraid of a split due to the appearance different ideological platforms in it”. (Ex.3)
In the above-mentioned sentence there are two negative words and negation, which inverts negative sentiment to positive: ”not afraid of a split”. But the following example was processed correctly by most BERT-based models:
”VTB-24 reduced losses in the second quarter”. (Ex.4)
The third group includes tweets with irony. The following example was differently treated by the models:
”Sberbank – the largest network of non-working ATMs in Russia”. (Ex.5)
The fourth group includes tweets that mention two telecom operators with different sentiment attitudes. In most cases it was difficult for models to distinguish correct sentiment towards each company.
”I always said to you that the best operator is Beeline. Megaphone does not respect you”. (Ex.6 - Beeline, Ex.7 - Megaphone)
Table 8 describes the results of the models on difficult examples. Due to limited space, acronyms of corresponding BERT architectures from previous tables were used. Here denote negative, neutral and positive sentiments respectively. Correct predictions are in bold. The last row is share of correct answers for each model. The best results are achieved by BERT-pair-NLI model with pre-trained Conversational RuBERT.
6 Related Work
The most latest and largest Russian sentiment dataset is RuSentiment [rogers2018rusentiment]
, which contains more than 30000 posts from VKontakte (VK), the most popular social network in Russia. Each post is labeled with one of five classes. The authors evaluated several traditional machine learning methods (logistic regression, linear SVM, Gradient Boosting) and neural networks. The best result (71.7measure) was achieved by the neural network with four full-connected layers and FastText embeddings trained on VKontakte posts. In [yuadaptation] the authors applied to the RuSentiment dataset multilingual BERT and RuBERT, trained on Russian text collections and obtained measure 87.73 by RuBERT.
Another popular dataset for Russian sentiment analysis is a tweet collection with automatic annotations based on emoticons (RuTweetCorp) [rubtsova2015constructing]. This corpus contains more than 200 thousand Twitter messages posted in 2013-2014 annotated as positive and negative.
In [rubtsova2018reducing], SVM with Word2Vec embeddings were applied the RuTweetCorp dataset. The authors of [svetlov2019sentiment] tested LSTM+CNN and BiGRU models on RuSentiment and RuTweetCorp datasets. Zvonarev and Bilyi [zvonarev2019comparison]
compared logistic regression, XGBoost classifier and Convolutional Neural Network on RuTweetCorp and obtained the best results with CNN.
The authors of [loukachevitch2018extracting] created the RuSentRel corpus consisted of analytical articles devoted to international relations. The corpus is annotated with sentiment attitudes towards mentioned named entities. Rusnachenko et al. [rusnachenko2019distant] study extraction of sentiment attitudes using CNN and distant supervision approach on the RuSentRel corpus.
In this study, we tested standard neural network architectures (CNN, LSTM, BiLSTM) and recently appeared BERT models on previous Russian sentiment evaluation datasets. We applied not only vanilla BERT classification approach, but reformulation of the classification task and question-answering (QA) and natural-language inference (NLI) tasks. We also compared two variants of Russian BERT and showed that for all sentiment tasks in this study the conversational variant of Russian BERT is better.
The best results were mostly achieved by BERT-NLI model. In one of the tasks this model practically achieved the human level of sentiment analysis.
The source code111111https://github.com/antongolubev5/Targeted-SA-for-Russian-Datasets and all sentiment datasets121212https://github.com/LAIR-RCC/Russian-Sentiment-Analysis-Evaluation-Datasets used in this work are publicly available.
The reported study was funded by RFBR according to the research project № 20-07-01059.