<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Word Embeddings in Sentiment Analysis</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Ruggero Petrolito</string-name>
          <email>ruggero.petrolito@gmail.com</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Felice Dell'Orletta</string-name>
          <email>felice.dellorletta@ilc.cnr.it</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Università di Pisa Istituto di Linguistica Computazionale “Antonio Zampolli” (ILC-CNR) ItaliaNLP Lab -</institution>
        </aff>
      </contrib-group>
      <abstract>
        <p>English. In the late years sentiment analysis and its applications have reached growing popularity. Concerning this field of research, in the very late years machine learning and word representation learning derived from distributional semantics field (i.e. word embeddings) have proven to be very successful in performing sentiment analysis tasks. In this paper we describe a set of experiments, with the aim of evaluating the impact of word embedding-based features in sentiment analysis tasks.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1 Introduction</title>
      <p>In the late years sentiment analysis has reached
great popularity among NLP tasks. As reported
by Mäntylä et al. (2016) the number of papers on
this subject has increased significantly in the first
two decades of 21st century, as well as the extent
of its applications. A wide variety of technologies
has been used to assess sentiment analysis tasks
during this period. In the latter years, machine
learning techniques proved to be very effective; in
particular, in recent years systems based on deep
learning techniques represent the state of the art.
In this field, word embeddings have been widely
used as a way of representing words in sentiment
analysis tasks, and proved to be very effective.</p>
      <p>
        A relevant mirror of the state of the art in
sentiment analysis field can be found in the SemEval
workshops. In the 2015 edition
        <xref ref-type="bibr" rid="ref12">(Rosenthal et al.,
2015)</xref>
        , most participants used machine learning
techniques; in many of the subtasks, the top
ranking systems used deep learning methods and word
embeddings, like the system submitted by Severyn
and Moschitti (2015), which was ranked 1st in
subtask A and 2nd in subtask B. In 2016 edition
        <xref ref-type="bibr" rid="ref10">(Nakov et al., 2016)</xref>
        , deep learning based
techniques, such as convolutional neural networks and
recurrent neural networks, were the most popular
approach. In 2017 edition
        <xref ref-type="bibr" rid="ref13">(Rosenthal et al., 2017)</xref>
        ,
machine learning methods were very popular,
especially support vector machines and deep neural
networks like convolutional neural networks and
long short-term neural networks.
      </p>
      <p>
        Concerning Italian language, EVALITA
conference well represents the state of the art in the
natural language processing field. In 2016
edition
        <xref ref-type="bibr" rid="ref2">(Barbieri et al., 2016)</xref>
        , the top ranking
systems used machine learning and deep learning
techniques (Castellucci et al. (2016), Attardi et
al. (2016), Di Rosa and Durante (2016)).
      </p>
      <p>The purpose of this study is to explore ways of
using word embeddings to build meaningful
representations of documents in sentiment analysis
tasks performed on Italian tweets.
2</p>
    </sec>
    <sec id="sec-2">
      <title>Our Contribution</title>
      <p>In this paper we aimed to evaluate the effect of
exploiting word embeddings in sentiment analysis
tasks. In particular, we explore the effect of five
factors on the performance of a sentiment
analysis classification system, to answer five research
questions:
1. What is the effect of the size of the corpus
used to train the embeddings?
2. Which text domain allows us to train
better embeddings (in-domain vs out-of-domain
data)?
3. Which type of learning method produces
better embeddings (word vs character-based
word embeddings)?
4. Which method to combine the word vectors
produces a better document vector
representation?
5. What are the most important words (in terms
of part-of-speech) to produce a better
document vector representation?</p>
      <p>
        To answer such questions, we performed
several classification experiments testing our system
on the three sentiment analysis tasks proposed in
the 2016 EVALITA SENTIPOLC campaign
        <xref ref-type="bibr" rid="ref2">(Barbieri et al., 2016)</xref>
        : Subjectivity Classification,
      </p>
      <sec id="sec-2-1">
        <title>Polarity Classification and Irony Detection. In</title>
        <p>the first of these tasks, the highest accuracy was
achieved by the system of Castellucci et al. (2016).
Concerning the 2nd task, the most accurate system
was the one submitted by Attardi et al. (2016).
Regarding the 3rd task, the highest accuracy value
was reached by the system of Di Rosa and
Durante (2016). Among these systems, Castellucci et
al. (2016) and Attardi et al. (2016) use deep
learning techniques (convolutional neural networks),
while Di Rosa and Durante (2016) use an
ensemble of many supervised learning classifiers.
3</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Datasets</title>
      <p>We tested our system on the three sentiment
analysis tasks proposed in 2016 EVALITA
SENTIPOLC campaign. These tasks and the
related datasets have been described by Barbieri et
al. (2016). We conducted our experiments on
the training set provided by the organizers of the
evaluation campaign, which is composed of 7921
tweets.</p>
      <p>
        We train our word embeddings on two corpora:
in-domain and out-domain. The in-domain dataset
is a collection of tweets that we collected for this
work, named Tweets. It is composed by almost 80
millions of tweets, resulting in around 1.2 billions
of tokens. The out-of-domain dataset is the Paisà
corpus, a collection of Italian web texts described
by Lyding et al.
        <xref ref-type="bibr" rid="ref7">(Lyding et al., 2013)</xref>
        .
      </p>
    </sec>
    <sec id="sec-4">
      <title>Experimental Setup</title>
      <p>For our experiments, we used a classifier based on
SVM using LIBLINEAR (Rong-En et al., 2013)
as machine learning library. As features, the
classifier uses only information extracted combining
the word-embeddings of the words of the analyzed
tweet.</p>
      <p>In all the experiments described in this paper,
our system addresses the classification tasks by
performing 5-fold cross-validation on the
training set provided for the SENTIPOLC 2016
evaluation campaign. The final score is the average
score. We evaluate each fold using the Average
F-score described by Barbieri et al. (2016).</p>
      <p>
        For what concerns the word embeddings, we
trained two types of word embedding
representations: i) the first one using the word2vec1 toolkit
        <xref ref-type="bibr" rid="ref9">(Mikolov et al., 2013)</xref>
        . This tool learns
lowerdimensional word embeddings, which are
represented by a set of latent (hidden) variables, and
each word is associated to a multidimensional
vector that represents a specific instantiation of these
variables; ii) the second one using fastText
        <xref ref-type="bibr" rid="ref4">(Bojanowski et al., 2016)</xref>
        , a library for efficient
learning of word representations and sentence
classification. This library allows to overcome the
problem of out-of-vocabulary words which affects the
methodology of word2vec. Generating
out-ofvocabulary word embeddings is a typical issue for
morphologically rich languages with large
vocabularies and many rare words. FastText overcomes
this limitation by representing each word as a bag
of character n-grams. A vector representation is
associated to each character n-gram and the word
is represented as the sum of these character n-gram
representations.
      </p>
      <p>In both cases, each word is represented by a 100
dimensions vector, computed using the CBOW
algorithm – that learns to predict the word in the
middle of a symmetric window based on the sum
of the vector representations of the words in the
window – and considering a context window of 5
words.
5</p>
    </sec>
    <sec id="sec-5">
      <title>Experiments and Results</title>
      <p>To answer the questions listed in Section 2, we
conducted a great amount of experiments, testing
many ways of representing the tweets by
exploiting in different manners the word embeddings of
1http://code.google.com/p/word2vec/
0:59
0:58
0:57
s 0:56
re 0:55
o
sc 0:54
-F 0:53
e
ag 0:52
ev 0:51
r
A 0:5
0:49
0:48
0:47
0
200
400</p>
      <p>600 800 1;000 1;200</p>
      <p>Millions of tokens
the words extracted from the tweets.</p>
      <p>To evaluate the impact (in terms of
classification accuracy) of the variations of each studied
parameter, we report the accuracy for each variation
of the parameter calculated as the average
accuracy across all the classification experiments that
we conducted by varying all the other parameters
(in a 5-fold cross-validation scenario).</p>
      <p>In all the experiments, we used only features
based on word embeddings.
5.1</p>
      <sec id="sec-5-1">
        <title>Size of the Embeddings Training Corpus</title>
        <p>To answer the question n. 1, we trained several
word embedding models on different partitions
of Tweets corpus of increasing sizes, using both
word2vec and fastText. Ten smaller partitions were
obtained starting with just ten millions of tokens
(for the smaller one) and adding other ten millions
for each new partition, reaching the amount of 100
millions. We created other four bigger partitions,
which contain respectively 240, 480, 720 and 960
millions of tokens; the size of the smaller of this
four partitions is comparable to the size of Paisà.</p>
        <p>Figure 1 reports the results. When we use
embeddings trained with word2vec on increasing
amounts of data, the average value of F-score
grows for all the three subtasks. The amount of
this growth is similar for the subtasks Subjectivity
Classification (0.016) and Polarity Classification
(0.019), while it’s smaller for the subtask Irony
Detection, which is the most challenging among
the three. In all cases the increase is significantly
faster in the first 80 to 100 millions of tokens,
particularly as regards the Irony Detection task:
in this case, the average F-score basically stops
growing after around 80 millions of tokens.</p>
        <p>When we use embeddings trained with fastText,
the outcome is the opposite: the average F-score
values decrease as bigger amounts of data are used
to train the embeddings. The decrease of the
values is faster when using the first hundreds of
millions of tokens.</p>
        <p>Lesson learned: these results suggest that,
regarding word-based word embeddings, as the
training corpus grows the accuracy rises, but it
becomes stable quickly. On the other hand, the
increase of the size of the training corpus
apparently doesn’t influence the accuracy values when
the embedding have been produced using fastText
(or it even causes a lowering of the accuracy
values).
5.2</p>
      </sec>
      <sec id="sec-5-2">
        <title>Domain of the Embeddings Training</title>
      </sec>
      <sec id="sec-5-3">
        <title>Corpus</title>
        <p>To answer the question n. 2, we ran a set of
experiments using the four models obtained using
word2vec and fastText on Paisà and Tweet
corpora. Table 1 reports the results of the
experiments. As we can see, the embeddings trained
with word2vec on the in-domain dataset (Tweets)
provide features that allow to achieve a higher
average accuracy compared to the features extracted
from the out-domain corpus. Differently, there
isn’t any variation in terms of accuracy when the
embeddings are trained with fastText.</p>
        <p>Lesson learned: the in-domain word
embeddings are very important in a semantic
classification scenario. Apparently, this is not true when
character-based word embedding are used.</p>
        <p>Subj.</p>
        <p>Pol.</p>
        <p>Iro.</p>
        <p>w2v
tw 0.5901
pa 0.572
ft
0.5198
0.5206
For what regards the question n. 3, the type of
embeddings learning model (words vs character
n-grams) influences considerably the performance
of the classifier. Using embeddings trained with
word2vec leads to F-score values that are
significantly higher in comparison to the accuracy
obtained using embeddings trained with fastText (see
Table 1).</p>
        <p>Lesson learned: this outcome suggests that
embeddings learned by methods that treat words as
atomic entities provide features that are more
useful in a semantic task such as sentiment
classification, in comparison with character-based
embeddings.</p>
      </sec>
      <sec id="sec-5-4">
        <title>5.4 Methods to Combine Word Embeddings</title>
        <p>To answer the question n. 4, we tested many
methods to combine the embeddings of the words of
each document into a document-level vector
representation.</p>
        <p>We experimented five combining methods:
Sum, Mean, Maximum-pooling,
Minimumpooling, Product. Each of this methods returns a
single vector ~t , such that each tn is obtained by
combining the nth components w1n; w2n : : : wmn
of the embedding of each tweet word. Figure 2
shows a graphical representation of this process.
tweet
w~1
w~2
w~3
...
w~n
~
t
w11
w21
w31
...
wn1
t1
w12
w22
w32
...
wn2
t2</p>
        <p>We tested these methods separately, and all of
them jointly as well. When using all methods,
the document representation is obtained
concatenating the vectors returned by each method.</p>
        <p>As we can see in Table 2, the Sum method
proved to be the best method for all the tasks,
when using embeddings obtained by word2vec.
The best results overall are obtained using the
concatenation of each of the vectors returned by the
used methods (row All in the Table). When using
embeddings trained with fastText, the best results
are obtained with mean for Subjectivity and
Polarity Classification, and with sum for Irony
Detection. In this case, the combination of all vector
leads to poor results.</p>
        <p>Lesson learned: these outcomes suggest that
the best combination methods are sum for word
vectors obtained by using word-based word
embeddings and mean for character-based ones.</p>
        <p>Meanwhile, the worst approach is the Product
combination. Interestingly, while the
concatenation of all the combined word-based word
embeddings is surely the best approach to produce the
document-level vector representation, this is not
true for the character-based ones.
To answer the question n. 5, we ran a set of
experiments using only a subset of the word embeddings
of each document to produce the document vector
representation. The word selection is guided by
the morpho-syntactic categories of the words. We
tested four categories: noun, verb, adjective,
adverb. The embeddings of the words belonging to
each of these categories were combined in a
posbased vector representation document. In
addition, we tested the document representation vector
obtained through the concatenation of the
different pos-based vectors (N, V, Adj, Adv) with and
without the all-word document vector All words,
which is the only one taking into account
emoticons and hash tags.</p>
        <p>Table 3 reports the results of the experiments. In
the word-based word embedding scenario,
regarding the contribution of single morpho-syntactic
categories, noun shows the highest performance.
Overall, the highest score is yielded by the
combination of all the selected categories concatenated
with the combined vector of all the word
embeddings (All words rows in the table). For what
regards the character-based word embeddings, we
can see that the noun is the individually best
performing category only for the Subjectivity
Classification task, while the adjective and the verb
are the best performing category for the other two
tasks.</p>
        <p>Lesson learned: these results show that noun
class is the most important grammatical category
only in the word-based word embedding scenario;
meanwhile the concatenation of all the pos-based
vectors and the All words vector yields the best
accuracy in both scenarios.
6</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Conclusions</title>
      <p>In this work we study the impact of word
embedding-based features in the sentiment
analysis tasks. We performed several classification
experiments to investigate the effects on
classification performances of five dimensions related to
the word embeddings. We tested several different
ways of selecting and combining the embeddings
and we studied how the performance of a
sentiment classifier changes.</p>
      <p>Despite the lessons learned from this work,
several aspects remain to investigate, such as, for
example, the tuning of the parameters used to train
the embeddings, and new vector combining
strategies.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          <string-name>
            <given-names>Giuseppe</given-names>
            <surname>Attardi</surname>
          </string-name>
          , Daniele Sartiano, Chiara Alzetta and
          <string-name>
            <given-names>Federica</given-names>
            <surname>Semplici</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Convolutional Neural Networks for Sentiment Analysis on Italian Tweets</article-title>
          . CLiC-it/EVALITA.
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          <string-name>
            <given-names>Francesco</given-names>
            <surname>Barbieri</surname>
          </string-name>
          , Valerio Basile, Danilo Croce, Malvina Nissim, Nicole Novielli and
          <string-name>
            <given-names>Viviana</given-names>
            <surname>Patti</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Overview of the evalita 2016 sentiment polarity classification task</article-title>
          .
          <source>Proceedings of Third Italian Conference on Computational Linguistics</source>
          (CLiC-it
          <year>2016</year>
          ) &amp;
          <article-title>Fifth Evaluation Campaign of Natural Language Processing and Speech Tools for Italian</article-title>
          .
          <source>Final Workshop (EVALITA</source>
          <year>2016</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          <string-name>
            <given-names>Yoshua</given-names>
            <surname>Bengio</surname>
          </string-name>
          , Réjean Ducharme, Pascal Vincent and
          <string-name>
            <given-names>Christian</given-names>
            <surname>Jauvin</surname>
          </string-name>
          .
          <year>2003</year>
          .
          <article-title>A Neural Probabilistic Language Model</article-title>
          .
          <source>Journal of Machine Learning Research</source>
          <volume>3</volume>
          (
          <year>2003</year>
          )
          <fpage>1137</fpage>
          -
          <lpage>1155</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          <string-name>
            <given-names>Piotr</given-names>
            <surname>Bojanowski</surname>
          </string-name>
          , Edouard Grave, Armand Joulin and
          <string-name>
            <given-names>Tomas</given-names>
            <surname>Mikolov</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Efficient Estimation of Word Representations in Vector Space</article-title>
          .
          <source>CoRR abs/1607.04606</source>
          ,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          <string-name>
            <given-names>Giuseppe</given-names>
            <surname>Castellucci</surname>
          </string-name>
          , Danilo Croce and
          <string-name>
            <given-names>Roberto</given-names>
            <surname>Basili</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Context-aware Convolutional Neural Networks for Twitter Sentiment Analysis in Italian</article-title>
          . CLiC-it/EVALITA.
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          <string-name>
            <given-names>Emanuele</given-names>
            <surname>Di</surname>
          </string-name>
          Rosa and
          <string-name>
            <given-names>Alberto</given-names>
            <surname>Durante</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>Tweet2Check evaluation at Evalita Sentipolc 2016</article-title>
          . CLiC-it/EVALITA.
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          <string-name>
            <given-names>Verena</given-names>
            <surname>Lyding</surname>
          </string-name>
          , Egon Stemle, Claudia Borghetti, Marco Brunello, Sara Castagnoli, Felice
          <string-name>
            <surname>Dell'Orletta Henrik</surname>
            <given-names>Dittmann</given-names>
          </string-name>
          , Alessandro Lenci and
          <string-name>
            <given-names>Vito</given-names>
            <surname>Pirrelli</surname>
          </string-name>
          .
          <year>2013</year>
          .
          <article-title>PAISÀ Corpus of Italian Web Text</article-title>
          . Institute for Applied Linguistics, Eurac Research.
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          <string-name>
            <surname>Mika</surname>
            <given-names>V.</given-names>
          </string-name>
          <string-name>
            <surname>Mäntylä</surname>
            , Daniel Graziotin and
            <given-names>Miikka</given-names>
          </string-name>
          <string-name>
            <surname>Kuutila</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>The Evolution of Sentiment Analysis - A Review of Research Topics, Venues, and Top Cited Papers</article-title>
          . Computer Science Review, Volume
          <volume>27</volume>
          ,
          <year>February 2016</year>
          , Pages
          <fpage>16</fpage>
          -
          <lpage>32</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          <string-name>
            <given-names>Tomas</given-names>
            <surname>Mikolov</surname>
          </string-name>
          , Kai Chen, Greg Corrado and
          <string-name>
            <given-names>Jeffrey</given-names>
            <surname>Dean</surname>
          </string-name>
          .
          <year>2013</year>
          .
          <article-title>Efficient Estimation of Word Representations in Vector Space</article-title>
          .
          <source>CoRR abs/1301.3781</source>
          ,
          <year>2013</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          <string-name>
            <given-names>Preslav</given-names>
            <surname>Nakov</surname>
          </string-name>
          , Alan Ritter, Sara Rosenthal, Fabrizio Sebastiani and
          <string-name>
            <given-names>Veselin</given-names>
            <surname>Stoyanov</surname>
          </string-name>
          .
          <year>2016</year>
          .
          <article-title>SemEval2016 task 4: Sentiment analysis in Twitter</article-title>
          .
          <source>Proceedings of the 10th international workshop on semantic evaluation (semeval-2016).</source>
        </mixed-citation>
      </ref>
      <ref id="ref11">
        <mixed-citation>
          <string-name>
            <given-names>Fan</given-names>
            <surname>Rong-En</surname>
          </string-name>
          , Chang Kai-Wei, Hsieh Cho-Jui,
          <string-name>
            <given-names>Wang</given-names>
            <surname>Xiang-Ruind Lin</surname>
          </string-name>
          Chih-Jen.
          <year>2008</year>
          .
          <article-title>LIBLINEAR: A Library for Large Linear Classification</article-title>
          .
          <source>Journal of Machine Learning Research</source>
          ,
          <volume>9</volume>
          :
          <fpage>1871</fpage>
          -
          <lpage>1874</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref12">
        <mixed-citation>
          <string-name>
            <given-names>Sara</given-names>
            <surname>Rosenthal</surname>
          </string-name>
          , Preslav Nakov, Svetlana Kiritchenko, Saif Mohammad, Alan Ritter and
          <string-name>
            <given-names>Veselin</given-names>
            <surname>Stoyanov</surname>
          </string-name>
          .
          <year>2015</year>
          . Semeval-2015 task 10:
          <article-title>Sentiment analysis in twitter</article-title>
          .
          <source>Proceedings of the 9th international workshop on semantic evaluation (SemEval</source>
          <year>2015</year>
          ),
          <fpage>451</fpage>
          -
          <lpage>463</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref13">
        <mixed-citation>
          <string-name>
            <given-names>Sara</given-names>
            <surname>Rosenthal</surname>
          </string-name>
          , Noura Farra and
          <string-name>
            <given-names>Preslav</given-names>
            <surname>Nakov</surname>
          </string-name>
          .
          <year>2017</year>
          . SemEval
          <article-title>-2017 task 4: Sentiment analysis in Twitter</article-title>
          .
          <source>Proceedings of the 11th International Workshop on Semantic Evaluation (SemEval-2017)</source>
          ,
          <fpage>502</fpage>
          -
          <lpage>518</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref14">
        <mixed-citation>
          <string-name>
            <given-names>Aliaksei</given-names>
            <surname>Severyn</surname>
          </string-name>
          and
          <string-name>
            <given-names>Alessandro</given-names>
            <surname>Moschitti</surname>
          </string-name>
          .
          <year>2015</year>
          .
          <article-title>Unitn: Training deep convolutional neural network for twitter sentiment classification</article-title>
          .
          <source>Proceedings of the 9th international workshop on semantic evaluation (SemEval</source>
          <year>2015</year>
          ),
          <fpage>464</fpage>
          -
          <lpage>469</lpage>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>