<!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>Hate speech spreader detection using contextualized word embeddings</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Evgeny Finogeev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Mariam Kaprielova</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Artem Chashchin</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff4">4</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Kirill Grashchenkov</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff2">2</xref>
          <xref ref-type="aff" rid="aff4">4</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>George Gorbachev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Oleg Bakhteev</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
          <xref ref-type="aff" rid="aff3">3</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Antiplagiat</institution>
          ,
          <addr-line>Moscow</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Dorodnicyn Computing Center RAS</institution>
          ,
          <addr-line>Moscow</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff2">
          <label>2</label>
          <institution>Institute of Oceanology (IO RAS)</institution>
          ,
          <addr-line>Moscow</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff3">
          <label>3</label>
          <institution>Moscow Institute of Physics and Technology (MIPT)</institution>
          ,
          <addr-line>Moscow</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
        <aff id="aff4">
          <label>4</label>
          <institution>Skolkovo Institute of Science and Technology (Skoltech)</institution>
          ,
          <addr-line>Moscow</addr-line>
          ,
          <country country="RU">Russia</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2021</year>
      </pub-date>
      <abstract>
        <p>he paper presents a method of hate speech spreaders recognition developed for the task of “Profiling Hate Speech Spreaders on Twitter” at the PAN@CLEF Conference 2021. Hate speech is an increasing problem nowadays. Due to the spread of the internet and the rise of social media, people with hostile views towards certain groups post hateful messages on social media resources. In this paper, we present a model to detect hate speech spreaders based on their Twitter posts. We aggregate contextualized embeddings of single tweets to form a vector representation for every user and employ classification methods to find users spreading hate speech. We analyze diferent embedding models based on BERT architecture for the problem. The submitted model achieves 67% in terms of accuracy for the English part of the dataset and 83% for the Spanish part of the dataset.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;BERT</kwd>
        <kwd>contextualized word embeddings</kwd>
        <kwd>deep learning</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>
        Hate speech detection in social networks is a significant social issue nowadays. A large number
of works is devoted to hate speech detection in the social media domain [
        <xref ref-type="bibr" rid="ref1 ref2 ref3">1, 2, 3</xref>
        ]. There are
variety of methods of hate speech detection. Most of them consider the problem as a supervised
document classification task [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ]. The approaches can be divided into two categories: either based
on manual feature engineering [
        <xref ref-type="bibr" rid="ref2 ref3">2, 3</xref>
        ] and using classic methods or deep learning-based models
which employ neural networks to automatically learn abstract features from raw data [
        <xref ref-type="bibr" rid="ref4 ref5">4, 5</xref>
        ].
      </p>
      <p>
        Hate Speech Spreaders profiling task considers the problem of hate speech detection in social
networks [
        <xref ref-type="bibr" rid="ref6 ref7">6, 7</xref>
        ]: given a set of tweets written by a user, one should establish, whether the user
can potentially spread hate speech or not. The tweets are written in two languages: English
and Spanish. The training dataset contains 200 sets of tweets for each language. There are 100
sets for users that can spread hate speech and 100 sets for ordinary users. The performance
metric for this task is accuracy.
      </p>
      <p>
        The main challenge of the current task is that the analysed object is not a single tweet, but a
collection of messages posted by a user. Even if the developed method detects a content without
hate speech in some of the user’s posts, the same user still can be classified as a potential hate
speech spreader. In this way, hate speech detection is similar to the previous fake news detection
task [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. The key idea for many approaches to such tasks is to aggregate information contained
in all the texts written by the author. We employ a neural network-based approach for such
aggregation.
      </p>
      <p>
        Recent studies show that approaches, based on embedding generation and their further
classification can be quite efective in hate speech detection. For example, in [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ] authors present
a solution involving hybrid embeddings based on TF-IDF for word-level feature extraction,
LSTM for sentence-level feature extraction and also naïve Bayes to extract topics from tweets.
Those embeddings are then used as an input for improved cuckoo search neural network. In [
        <xref ref-type="bibr" rid="ref10">10</xref>
        ]
authors proposed an approach which first used LSTM to perform word embeddings and then
CNN was used for hate speech classification. One of the most impressive deep learning-based
architectures to obtain semantic information stored in short texts is BERT [11]. The embeddings
obtained from BERT are used to classify whether a user can spread hate speech or not. In this
paper, we employ diferent BERT-based architectures to obtain embeddings for every tweet in
the collection. We also analyze model performance after fine-tuning on the external corpus of
tweets [12].
      </p>
    </sec>
    <sec id="sec-2">
      <title>2. Methodology</title>
      <p>The following section describes the proposed method of hate speech spreader detection.</p>
      <p>Similar to the previous year’s task [13], we consider the current task as a classification
problem, where the classified object is a collection of tweets.</p>
      <p>There is a given dataset D = (, ):
 = {1 , . . . , },</p>
      <p>∈ W+,  ∈ {1, . . . , },  ∈ {0, 1},
where W+ corresponds to all the possible strings written in the given language. The label  = 1
corresponds to users that are likely to spread hate speech,  = 0 corresponds to ordinary users.</p>
      <p>Formally, the task is to find the binary classifier that minimizes an empirical risk on the
dataset D:
 = arg min
∈F</p>
      <p>∑︁ [ () ̸= ],
,∈D
where F is a set of all considered classification models.</p>
      <p>For the proposed problem solution we employ a deep learning-based approach: each tweet is
vectorized using a deep learning model. After that, we aggregate the obtained vectors and use
the resulting averaged vector as a feature set for the classifier.</p>
      <p>The proposed method is illustrated in Figure 1. The method consists of 3 main components:
1. BERT model that extracts embedding vector e from every tweet  .

2. Aggregation operation that averages the information across all the tweets of the author:
e =</p>
      <p>1 ∑︁ e.</p>
      <p>=1
3. The resulting classifier that uses averaged tweet vector e as an input feature set.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Experiment Details</title>
      <p>To validate our models we conducted a computational experiment. Since we use a standard
BERT tokenizer, we did not use any special preprocessing for our method. For all the analyzed
models we used -fold cross-validation with  = 10. The results are presented in Table 1. The
test accuracy was evaluated using TIRA environment [14].</p>
      <p>
        Inspired by the author profiling task from the previous year [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ] we used a char -gram based
model as a baseline. We used principal component analysis [15] with component number  to
reduce the feature set and make the -gram feature space denser. The n-gram order  and the
component number  was selected using cross-validation.
      </p>
      <p>Since the dataset contains texts in two languages, we initially decided to use a pretrained
multilingual BERT model [11] for the vectorization. We analyzed its performance with two
classifiers: support vector machine [ 16] and logistic regression. For each classification algorithm,
the optimal parameters for cross-validation were selected using GridSearch. Based on the results
in Table 1, it is clear that this approach works well for Spanish, but shows poor performance
on English data. We decided to use Multilingual BERT for the processing of Spanish and use a
diferent model for English. In order to improve our quality in the English part of the dataset
we analyzed the following models:
• LaBSE [17], a multilingual model with BERT architecture. The main feature of this model
is that all the languages supported by LaBSE share a common hidden space that can
potentially improve our model generalization.
• BERT-Base, the pretrained model that was trained only on the English texts;
• BERT-base tuned on the external corpus of the tweets. The main idea of this approach is
to fine-tune the lexical and semantic properties of the model on the tweet corpus in order
to make the model more receptive to the specific Twitter lexicon.</p>
      <p>Note that since the training dataset has rather small information for BERT model tuning,
we did not consider the idea of fine-tuning straightforwardly on the current training dataset.
Therefore we only tuned the model on the external tweet collection in an unsupervised manner
it was originally trained. Some tokens in the sentences were masked, and the model tried to
predict them. The predicted tokens were fed into a softmax layer to get the output words. Such
procedure does not require additional labeling of external data and allows BERT to focus more
on the Twitter posts than the English and Spanish texts in general.</p>
      <p>LaBSE vectorization. Although the LaBSE model shares the common hidden space for all
the languages including Spanish and English, we did not find any quality improvement in
comparison to the basic architecture and other methods.</p>
      <p>BERT-base. The pretrained BERT-base model was trained only on English texts, so we suggest
that using it as a vectorizer for English tweets might improve accuracy. Our assumption that
BERT-base single-language model shows better performance than the multilingual model on an
English-only task is confirmed by cross-validation results. When using this model, we did not
make any changes to the architecture.</p>
      <p>BERT-based model fine-tuned on the external tweet corpus. Given that BERT model
base was trained on a large collection of English texts from Wikipedia , we assume that it needs
ifne-tuning on the data related to our problem, since tweets often use specific slang, syntax,
emoji etc. In order to improve the quality of vector representation we took a large corpus
of tweets [12], which contains 1,600,000 tweets in English, and fine-tuned the model on this
dataset in masked language model task regime. For all 1,600,000 tweets from the additional
dataset, we replaced links, hashtags and user mentions with tokens from the training dataset
(#URL#, #HASHTAG#, #USER# respectively). We also added these tokens to the BERT tokenizer
dictionary. The use of additional training improved the accuracy.</p>
      <p>As we can see, the resulting model shows a competitive performance in comparison to the
baseline model. The cross-validation accuracy has increased from 0.68 to 0.72 on English part of
the dataset and from 0.79 to 0.8 on its Spanish part. We got a rather significant improvement on
English data by tuning the model in an unsupervised manner on the external corpus of tweets.
We also observe a slight increase in performance on Spanish tweets.</p>
      <p>The submitted English model achieves 67% in terms of accuracy on the test set, while the
Spanish model shows the accuracy 83%.</p>
      <p>For further analysis, we made a t-SNE transformation [18] for each averaged user vector e
in two dimensional space and visualized them according to their class. The result is shown in
Figure 2,3 for English and Spanish, respectively.</p>
      <p>As we can see, the obtained projection poorly separates averaged user vectors, which indicates
that this method needs to be potentially improved.</p>
      <p>We also built an LDA topic model [19] for the English part of the dataset in order to analyze
the topic distributions across the tweets. For the topic model, we used 10 topics. The resulting
t-SNE projection is shown in Figure 3. We analyzed the words mostly corresponding to each
topic. Although we could not find a total interpretability of the obtained topics we noticed that
some of them correspond to the US politics (“Biden”, “Trump”, “President”, “Wall”, “American”
in the top words of the topic), US elections ( “Biden”, “Trump”, “Election”, “Voters”, “Democrats”,
“Republicans”, “Court” in the top words of the topic), COVID-19 (“Covid”, “19”, “Virus” in the
top words of the topic). This makes us believe that clustering tweets using some topic modeling
approach and employing information about topic distribution across the user tweets for the
decision about hate speech spreading.</p>
    </sec>
    <sec id="sec-4">
      <title>4. Conclusion</title>
      <p>The paper describes an approach to the problem of hate speech spreaders detection. We proposed
a model to detect hate speech spreaders using contextualized embeddings of single tweets. We
aggregate the obtained vectors and use their average vector as a feature set for the further
classification. We also provide an analysis of diferent vectorization models based on the BERT
architecture. The resulting model shows an accuracy of about 67% for the English test dataset
and 83% for the Spanish test dataset. The future work includes a detailed analysis of topic
distribution across the tweets and usage of this information in the final decision rule.</p>
    </sec>
    <sec id="sec-5">
      <title>Acknowledgments</title>
      <p>This research is funded by RFBR, grant 19-29-14100.
tional Conference on Pattern Recognition Applications and Methods - ICPRAM„ INSTICC,
SciTePress, 2020, pp. 453–460. doi:10.5220/0008954004530460.
[11] J. Devlin, M.-W. Chang, K. Lee, K. Toutanova, Bert: Pre-training of deep bidirectional
transformers for language understanding, arXiv preprint arXiv:1810.04805 (2018).
[12] A. Go, R. Bhayani, L. Huang, Twitter sentiment classification using distant supervision,</p>
      <p>CS224N project report, Stanford 1 (2009) 2009.
[13] O. Bakhteev, A. Ogaltsov, P. Ostroukhov, Fake news spreader detection using neural tweet
aggregation, in: CLEF, 2020.
[14] M. Potthast, T. Gollub, M. Wiegmann, B. Stein, TIRA Integrated Research Architecture,
in: N. Ferro, C. Peters (Eds.), Information Retrieval Evaluation in a Changing World, The
Information Retrieval Series, Springer, Berlin Heidelberg New York, 2019. doi:10.1007/
978-3-030-22948-1\_5.
[15] C. M. Bishop, Pattern recognition and machine learning, springer, 2006.
[16] C. Cortes, V. Vapnik, Support vector machine, Machine learning 20 (1995) 273–297.
[17] F. Feng, Y. Yang, D. Cer, N. Arivazhagan, W. Wang, Language-agnostic bert sentence
embedding, arXiv preprint arXiv:2007.01852 (2020).
[18] L. Van der Maaten, G. Hinton, Visualizing data using t-sne., Journal of machine learning
research 9 (2008).
[19] K. Vorontsov, O. Frei, M. Apishev, P. Romov, M. Dudarenko, Bigartm: Open source
library for regularized multimodal topic modeling of large collections, in: International
Conference on Analysis of Images, Social Networks and Texts, Springer, 2015, pp. 370–381.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>Z.</given-names>
            <surname>Zhang</surname>
          </string-name>
          , L. Luo,
          <article-title>Hate speech detection: A solved problem? the challenging case of long tail on twitter</article-title>
          ,
          <source>Semantic Web</source>
          <volume>10</volume>
          (
          <year>2019</year>
          )
          <fpage>925</fpage>
          -
          <lpage>945</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>P.</given-names>
            <surname>Burnap</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. L.</given-names>
            <surname>Williams</surname>
          </string-name>
          ,
          <article-title>Cyber hate speech on twitter: An application of machine classification and statistical modeling for policy and decision making</article-title>
          ,
          <source>Policy &amp; internet 7</source>
          (
          <year>2015</year>
          )
          <fpage>223</fpage>
          -
          <lpage>242</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>T.</given-names>
            <surname>Davidson</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Warmsley</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Macy</surname>
          </string-name>
          ,
          <string-name>
            <surname>I. Weber</surname>
          </string-name>
          ,
          <article-title>Automated hate speech detection and the problem of ofensive language</article-title>
          ,
          <source>in: Proceedings of the International AAAI Conference on Web and Social Media</source>
          , volume
          <volume>11</volume>
          ,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>B.</given-names>
            <surname>Gambäck</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U. K.</given-names>
            <surname>Sikdar</surname>
          </string-name>
          ,
          <article-title>Using convolutional neural networks to classify hate-speech</article-title>
          ,
          <source>in: Proceedings of the first workshop on abusive language online</source>
          ,
          <year>2017</year>
          , pp.
          <fpage>85</fpage>
          -
          <lpage>90</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>K.</given-names>
            <surname>Miok</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Škrlj</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Zaharie</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Robnik-Šikonja</surname>
          </string-name>
          ,
          <article-title>To ban or not to ban: Bayesian attention networks for reliable hate speech detection</article-title>
          ,
          <source>Cognitive Computation</source>
          (
          <year>2021</year>
          )
          <fpage>1</fpage>
          -
          <lpage>19</lpage>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>J.</given-names>
            <surname>Bevendorf</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Chulvi</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. L. D. L. P.</given-names>
            <surname>Sarracén</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Kestemont</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Manjavacas</surname>
          </string-name>
          , I. Markov,
          <string-name>
            <given-names>M.</given-names>
            <surname>Mayerl</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Potthast</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F.</given-names>
            <surname>Rangel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Rosso</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Stamatatos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Stein</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wiegmann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Wolska</surname>
          </string-name>
          , , E. Zangerle, Overview of PAN 2021:
          <article-title>Authorship Verification,Profiling Hate Speech Spreaders on Twitter,and Style Change Detection</article-title>
          ,
          <source>in: 12th International Conference of the CLEF Association (CLEF</source>
          <year>2021</year>
          ), Springer,
          <year>2021</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>F.</given-names>
            <surname>Rangel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G. L. D. L. P.</given-names>
            <surname>Sarracén</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Chulvi</surname>
          </string-name>
          , E. Fersini,
          <string-name>
            <given-names>P.</given-names>
            <surname>Rosso</surname>
          </string-name>
          ,
          <source>Profiling Hate Speech Spreaders on Twitter Task at PAN</source>
          <year>2021</year>
          ,
          <article-title>in: CLEF 2021 Labs and Workshops, Notebook Papers, CEUR-WS</article-title>
          .org,
          <year>2021</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>F.</given-names>
            <surname>Rangel</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Giachanou</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Ghanem</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Rosso</surname>
          </string-name>
          ,
          <article-title>Overview of the 8th author profiling task at pan 2020: Profiling fake news spreaders on twitter</article-title>
          ,
          <source>in: CLEF</source>
          ,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>F. E.</given-names>
            <surname>Ayo</surname>
          </string-name>
          ,
          <string-name>
            <given-names>O.</given-names>
            <surname>Folorunso</surname>
          </string-name>
          ,
          <string-name>
            <given-names>F. T.</given-names>
            <surname>Ibharalu</surname>
          </string-name>
          ,
          <string-name>
            <given-names>I. A.</given-names>
            <surname>Osinuga</surname>
          </string-name>
          ,
          <article-title>Hate speech detection in twitter using hybrid embeddings and improved cuckoo search-based neural networks</article-title>
          ,
          <source>International Journal of Intelligent Computing and Cybernetics</source>
          (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref10">
        <mixed-citation>
          [10]
          <string-name>
            <given-names>H.</given-names>
            <surname>Faris</surname>
          </string-name>
          .,
          <string-name>
            <surname>I. Aljarah.</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Habib</surname>
          </string-name>
          .,
          <string-name>
            <surname>P. Castillo.</surname>
          </string-name>
          ,
          <article-title>Hate speech detection using word embedding and deep learning in the arabic language context</article-title>
          ,
          <source>in: Proceedings of the 9th Interna-</source>
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>