<!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>
      <journal-title-group>
        <journal-title>Jaén, Spain
* Corresponding author.
$ cfernandezrosa@uoc.edu (C. F. Rosauro); mcuadros@vicomtech.org (M. Cuadros)
 https://github.com/cfernandezros/ (C. F. Rosauro)</journal-title>
      </journal-title-group>
    </journal-meta>
    <article-meta>
      <title-group>
        <article-title>Hate Speech Detection Against the Mexican Spanish LGBTQ+ Community Using BERT-based Transformers</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Carlos Fernández Rosauro</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Montse Cuadros</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Universitat Oberta de Catalunya</institution>
          ,
          <addr-line>Barcelona</addr-line>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2023</year>
      </pub-date>
      <volume>000</volume>
      <fpage>0</fpage>
      <lpage>0002</lpage>
      <abstract>
        <p>In this paper we present our approach to the HOMO-MEX task: Hate speech detection in Online Messages directed tOwards the MEXican spanish speaking LGBTQ+ population. We present our results for both Track 1: Hate speech detection track, in which the aim is to indicate whether a set of tweets exhibit LGBT+phobic content or not, and Track 2: Fine-grained hate speech detection track (Multi-labeled), in which the tweets labeled as LGBT+phobic need to be classified according to the type of LGBT+phobia they show. We utilized both classical machine learning and Transformer-based deep learning models focused on BERT-like architectures to tackle both tracks. The model that achieved the best results in terms of F1-Score (0.84 in Track 1) and macro-average F1-Score (0.68 in Track 2) was robertuito-base-uncased. With this model our team reached the 2nd position in both tracks.</p>
      </abstract>
      <kwd-group>
        <kwd>eol&gt;NLP</kwd>
        <kwd>Text Classification</kwd>
        <kwd>Hate Speech</kwd>
        <kwd>Deep Learning</kwd>
      </kwd-group>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>1. Introduction</title>
      <p>assigned multiple labels such as "L", "G", and "B" while another tweet might only receive
the label "O".</p>
      <p>
        We refer the reader to the overview article [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] of the HOMO-MEX 2023 competition for further
information. Our team has participated in both tasks, implementing baseline models and more
sophisticated systems based on BERT-like [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ] Transformers. Both tasks are related to text
classification tasks where mainly difer in that Track 1 is a multi-class problem and Track 2 is a
multi-label problem.
      </p>
      <p>This paper is organized as follows, section 2 presents the datasets available for the shared
task which have been used. Section 3 presents the basic system used for both tracks. Section 4
presents the experimentation performed in Track 1 and in Track 2. Finally, section 5 draw some
concluding remarks of our participation in the shared task.</p>
    </sec>
    <sec id="sec-2">
      <title>2. Dataset</title>
      <p>In the shared task, the oficial dataset for Track 1 regarding training data contains 7000 tweets
labelled as either LGBT+phobic (P), not LGBT+phobic (NP) or not LGBT+related (NA) sorted by
an index. Regarding Track 2, training dataset contains 862 LGBT+phobic tweets along with 5
columns that define the type of hate speech that the tweet contains in a binary-variable manner
(1 or 0). This way, Track 2 tweets can contain one or multiple of the following behaviours:
Lesbophobia (L), Gayphobia (G), Biphobia (B), Transphobia (T), and/or other LGBT+phobia (O).</p>
      <p>Track 1 training set is split into 80% for training and 20% for validation, while Track 2 training
set is split into 85% for training and 15% for validation . In both cases this was done by randomly
selecting the validation split using a preset seed. Table 1 shows the number of tweets per track
in train and validation sets and the average word tokens per tweet.</p>
    </sec>
    <sec id="sec-3">
      <title>3. Methodology</title>
      <p>For both tasks, the same methodology was followed: first, two classical methods were
implemented as a baseline and then, a series of BERT-based models were utilized to search for better
results.</p>
      <p>In the next subsection we present the Baseline models and the BERT-based models.</p>
      <sec id="sec-3-1">
        <title>3.1. Baseline Models</title>
        <p>Baseline models are both learnt on a TF-IDF matrix generated through the Tfidf Vectorizer class
from the sklearn library. On each task, the vectorizer is fitted on the training dataset and then
transformed on both the training and validation datasets. This training and validation TF-IDF
matrixes are then used to train and validate the baseline methods. Before the TF-IDF matrixes
are generated, the tweets follow a processing pipeline, which includes a Snowball Stemmer
from the NLTK library.</p>
        <p>
          • Multinomial Naive Bayes[
          <xref ref-type="bibr" rid="ref3">3</xref>
          ]. From the sklearn Python library, fitted on the input
        </p>
        <p>
          TF-IDF matrix and output labels with default parameters.
• Linear SVC[
          <xref ref-type="bibr" rid="ref4">4</xref>
          ]. From the sklearn Python library, fitted on the input TF-IDF matrix and
output labels with a linear kernel and all other default parameters.
        </p>
      </sec>
      <sec id="sec-3-2">
        <title>3.2. BERT-based Models</title>
        <p>Transformer models are implemented by downloading the pre-trained base models from Hugging
Face and then fine-tunning them on the text data using Tensorflow, Keras and the Transformers
library.</p>
        <p>The text data is not processed as before in the case of these models but with their own built-in
tokenizers through the Transformers library. Additionally, in the case of RoBERTuito, the tweets
need to be pre-processed with the pysentimiento library.</p>
        <p>
          • bert-base-spanish-wwm-cased (BETO). BETO[
          <xref ref-type="bibr" rid="ref5">5</xref>
          ] is a Spanish version of the BERT-Base
model.
• robertuito-base-uncased. RoBERTuito[6] is a RoBERTa implementation for social media
text in Spanish trained on 500 million tweets.
• mdeberta-v3-base. mDeBERTaV3[7] is a multilingual implementation of the DeBERTa
architecture.
        </p>
      </sec>
    </sec>
    <sec id="sec-4">
      <title>4. Experimentation</title>
      <p>4.1. Track 1
In this task the goal is to train and validate each of the selected models to a multi-class problem
where the input data is the text data (tweets) from Track 1 and the output data are the assigned
labels.</p>
      <p>As explained in section 3, we have participated in this task with two baselines and three
BERT-based Transformer models.</p>
      <p>When working with the BERT-based models, the checkpoints are downloaded from their
repository at Hugging Face and then loaded as Tokenizers that are used to process both training
and validation tweets. The model is then instantiated using the
TFAutoModelForSequenceClassification class from the Transformers library using the same checkpoint and the parameters
and hyperparameters are tuned in order to get the best results. The
TFAutoModelForSequenceClassification class is adapted to a multi-class problem. We have tuned the number of epochs,
batch size, start and end learning rates on the polynomial scheduler and the dropout probability
as shown in Table 2.</p>
      <p>Then the model is compiled and fitted with Tensorflow and Keras. In the compilation step,
the AdamW[8] algorithm is always applied with a polynomial learning rate scheduler. After the
model is fitted to the training data, it is validated to the validation dataset using weighted-average
F1-Score, Precision and Recall and Accuracy.</p>
      <p>Regarding performance, it is worth mentioning that all Transformer models are fine-tuned in
Google Colab using NVIDIA Tesla T4 or V100 GPUs expect for the mDeBERTaV3 model, for
which an NVIDIA A100 is utilized.</p>
      <p>In the case of RoBERTuito, as we figured that this model displayed more tolerance than the
others to tuning techniques, we added a class weight dictionary {NP: 0.7, NR: 1, P: 1.3} for the
training phase to take care of the class imbalance situation that specially afects the model’s
ability to identify LGBT+phobic (P) tweets (minority class). This set of weights was manually
tweaked.</p>
      <p>As shown in table 3 weighted-average F1-Score, Precision and Recall and Accuracy were
used to benchmark the models implemented in Track 1. RoBERTuito achieved the best results
across all metrics, though neither this model nor any other Transformer-based model achieved a
significant improvement over the simple Linear SVC baseline trained on TF-IDF matrixes, which
doesn’t take into account word order or semantic similarity between tokens as
Transformerbased models do.
w.F1-Score
w.Precision</p>
      <p>w.Recall Accuracy
4.2. Track 2
In this track the goal is to train and validate each of the selected models to a multi-label problem
where the input data is the text data (tweets) from Track 2 and the output data are the multiple
assigned labels.</p>
      <p>Similar to Track 1, we have worked using the same procedure using Hugging Face models
and the Tokenizer class. In the same way, we use TFAutoModelForSequenceClassification
class using the parameters and hyperparameters showed in table 4 and adapt them to the
multi-label problem. Then the model is compiled and fitted with Tensorflow and Keras. In
the compilation step, the AdamW[8] algorithm is also applied with a polynomial learning rate
scheduler. Regarding this track, when the model is fitted to the training data, it is validated to
the validation dataset using macro-average F1-Score, Precision and Recall and Accuracy.</p>
      <p>As for Track 1, we have participated in this task with two baselines and three BERT-based
Transformer models. In the case of performance, we have also fine-tuned all Transformer
models in Google Colab with the same specifications followed in Track 1.</p>
      <p>As shown in table 5, macro-average F1-Score, Precision and Recall and Accuracy were utilized
to benchmark the models implemented in Track 2. RoBERTuito achieved the best result on
Accuracy and BETO achieved the best results on macro-average Precision and Recall. Again,
none of the Transformer-based models achieved a significant improvement over the simple
Linear SVC baseline.
0.20
0.44
0.51
0.48
0.20</p>
      <sec id="sec-4-1">
        <title>4.3. Discussion on Results</title>
        <p>We have seen how in both tasks a simple Linear SVC model almost achieved the same results
as our best performer model RoBERTuito. We didn’t submit Linear SVC to the HOMO-MEX
competition so we can only conclude inside our experimental setup that simpler models such
as a Linear SVC will perform as good as Transformer models if properly tuned because in the
context of short social media texts, in this experimentation, language models don’t seem to
outperform in the classification problem. We can conclude then, that the existence (or lack
of) LGBT+phobic terms and their type are the most important features in the context of both
classification tasks, as the performance of such a simple statistical method over term frequencies
demonstrates.</p>
      </sec>
    </sec>
    <sec id="sec-5">
      <title>5. Conclusions</title>
      <p>We have presented our participation in the shared task Homo-Mex 2023. We have participated in
both tracks obtaining a second position according to oficial metrics reported by organizers. We
have presented a set of experiments using classic algorithms and BERT-like Transformer models.
The results obtained in both tasks exhibit similar performances for diferent methodologies.</p>
    </sec>
    <sec id="sec-6">
      <title>6. Acknowledgements</title>
      <p>This work was undertaken by the principal author in fulfilment of his Bachelor’s Final Project
at the Universitat Oberta de Catalunya.
[6] J. M. Pérez, D. A. Furman, L. Alonso Alemany, F. M. Luque, RoBERTuito: a pre-trained
language model for social media text in Spanish, in: Proceedings of the Thirteenth Language
Resources and Evaluation Conference, European Language Resources Association, Marseille,
France, 2022, pp. 7235–7243. URL: https://aclanthology.org/2022.lrec-1.785.
[7] P. He, J. Gao, W. Chen, Debertav3: Improving deberta using electra-style pre-training with
gradient-disentangled embedding sharing, 2023. arXiv:2111.09543.
[8] I. Loshchilov, F. Hutter, Decoupled weight decay regularization, 2019. arXiv:1711.05101.</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>G.</given-names>
            <surname>Bel-Enguix</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Gómez-Adorno</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Sierra</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Vásquez</surname>
          </string-name>
          , S.-T. Andersen,
          <string-name>
            <given-names>S.-L.</given-names>
            <surname>Ojeda-Trueba</surname>
          </string-name>
          ,
          <article-title>Overview of HOMO-MEX at Iberlef 2023: Paraphrase Detection in Spanish Shared Task</article-title>
          ,
          <source>Procesamiento del Lenguaje Natural</source>
          <volume>71</volume>
          (
          <year>2023</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>J.</given-names>
            <surname>Devlin</surname>
          </string-name>
          , M.-
          <string-name>
            <given-names>W.</given-names>
            <surname>Chang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Lee</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Toutanova</surname>
          </string-name>
          , BERT:
          <article-title>Pre-training of deep bidirectional transformers for language understanding</article-title>
          ,
          <source>in: Proceedings of the 2019 Conference of the North American Chapter of the Association for Computational Linguistics: Human Language Technologies</source>
          , Volume
          <volume>1</volume>
          (Long and Short Papers),
          <source>Association for Computational Linguistics</source>
          , Minneapolis, Minnesota,
          <year>2019</year>
          , pp.
          <fpage>4171</fpage>
          -
          <lpage>4186</lpage>
          . URL: https://aclanthology.org/ N19-1423. doi:
          <volume>10</volume>
          .18653/v1/
          <fpage>N19</fpage>
          -1423.
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>C.</given-names>
            <surname>Manning</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Raghavan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Schuetze</surname>
          </string-name>
          , Introduction to information retrieval, Cambridge University Press,
          <year>2008</year>
          , pp.
          <fpage>234</fpage>
          -
          <lpage>265</lpage>
          . URL: https://nlp.stanford.edu/IR-book/html/htmledition/ naive-bayes
          <article-title>-text-classification-1</article-title>
          .html.
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>C.</given-names>
            <surname>Manning</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Raghavan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Schuetze</surname>
          </string-name>
          , Introduction to information retrieval, Cambridge University Press,
          <year>2008</year>
          , pp.
          <fpage>319</fpage>
          -
          <lpage>325</lpage>
          . URL: https://nlp.stanford.edu/IR-book/html/htmledition/ support
          <article-title>-vector-machines-the-linearly-separable-case-1</article-title>
          .html.
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Cañete</surname>
          </string-name>
          , G. Chaperon,
          <string-name>
            <given-names>R.</given-names>
            <surname>Fuentes</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.-H.</given-names>
            <surname>Ho</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Kang</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Pérez</surname>
          </string-name>
          ,
          <article-title>Spanish pre-trained bert model and evaluation data</article-title>
          ,
          <source>in: PML4DC at ICLR</source>
          <year>2020</year>
          ,
          <year>2020</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>