<!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>Irony Detection in the Portuguese Language using BERT</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Shengyi Jiang</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Chuwei Chen</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Nankai Lin</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Zhuolin Chen</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jinyi Chen</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Field Irony No Irony All</string-name>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Guangzhou Key Laboratory of Multilingual Intelligent Processing, Guangdong University of Foreign Studies</institution>
          ,
          <addr-line>Guangzhou</addr-line>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>School of Information Science and Technology, Guangdong University of Foreign Studies</institution>
          ,
          <country country="CN">China</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>In this article, we report the solution of the team BERT 4EVER for the Irony Detection in the Portuguese language task in IberLeF 2021, which aims to identify irony news articles or tweets in the Portuguese language spread via digital media. We propose the BERT (Bidirectional Encoder Representations from Transformers) model to tackle the problem. In addition, we adopt weight loss and ensemble learning to improve the generalization capability. Experimental results as well as the leading position of our team on the task leaderboard demonstrate the effectiveness of our method in the field of news.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>Introduction</title>
      <p>
        Irony refers to the use of words contrary to the original meaning to express the
meaning, which is a form of figurative language with strong emotional color. The irony
detection is a key-challenge in various tasks involving Natural Language Processing
(NLP). In the field of Opinion Mining, for instance, Luís Sarmento et al. [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] noted the
role of irony in minimizing the error when discriminating negative from positive
opinions.
written in Portuguese. The distribution of the dataset is shown in Table 1. Our team,
BERT 4EVER, also participates in this task and achieves the first rank in the field of
news. In this report, we will review our solution to this task, namely, the BERT model
aided by weight loss and ensemble learning.
2
      </p>
    </sec>
    <sec id="sec-2">
      <title>Related Work</title>
      <p>
        Most of the research studies in Irony Detection focus on English language [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ].
Christos Baziotis et al. [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] presented an ensemble of two different deep learning models: a
word- and a character-level deep LSTM for capturing the semantic and syntactic
information of tweets respectively, which ranked 1st for both subtasks in SemEval-2018
Task 3 “Irony detection in English tweets” [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ]. Barbieri et al. proposed a new
evaluation framework named TWEETEVAL consisting of seven heterogeneous
Twitterspecific classification tasks. In particular, they provided a strong set of baselines as
starting point and compared different language modeling pre-training strategies,
which established a relatively perfect evaluation system of English irony detection
[
        <xref ref-type="bibr" rid="ref5">5</xref>
        ].
      </p>
      <p>
        Recently, the NLP community also focuses on other languages for the need to
develop linguistic and computational resources, which has spawned a multitude of
irony detection competitions for other languages, such as Arabic [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ], Spanish [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], and
Italian [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ].
      </p>
      <p>Portuguese is a low-resource language, which limits the amount of research done
for this language. Freitas et al. proposed a set of patterns that might suggest
ironic/sarcastic statements by observing a corpus constituted by tweets [9]. In particular,
they developed special clues for irony detection, through the implementation and
evaluation of a set of patterns. Fabio Ricardo Araujo da Silva [10] proposed a
Convolutional Neural Network (CNN) adapted for automatically detecting irony/sarcasm in
Brazilian Portuguese, which was trained and tested by datasets from Twitter obtained
by the author and from thirds. For the reason that there is no website corpus in
Portuguese corpus (only the corpus from social network twitter), Gabriel Schubert Marten
et al. [11] developed a corpus in the Portuguese language to sarcasm and irony
detection task.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Method</title>
      <p>As shown in Figure 1, based on the BERT model, we train three kinds of models with
different strategies. In the prediction stage, we fuse the prediction results of the three
models for each field (news/twitter). These three strategies are as follows:
(1) We fine-turn the BERT model separately for the training set in each field.
(2) On the basis of (1), we adopt the Loss Weight strategy for the training set in
each field to solve data imbalance.</p>
      <p>(3) We combine the data from these two fields together and fine-tune the BERT
model, so as to make use of the information from the other field to assist classification
and improve the generalization ability of the model.
3.1</p>
      <p>BERT</p>
      <p>BERT (Bidirectional Encoder Representations for Transformers) is designed to
pretrain deep bidirectional representations from unlabeled text by jointly building models
both left and right context in all layers [12]. The BERT model structure is shown in
Figure 2.
where the value of  is e.</p>
      <p>Model Fusion</p>
      <p>It consists of two pretrain tasks, namely Mask Language Model (MLM) and
Next Sentence Prediction (NSP) :(1) MLM is defined as masking some words in the
input sequence, and then predicting the masked words according to the context; (2)
NSP refers to predicting whether the second sentence is the follow-up (next sentence)
of the first sentence.
3.2 Weight Loss
We can see that in the field of news, there are more data that are not ironic, while in
the field of tweets, there are more data that are ironic. In this paper, we adopt a class
weight adjustment method [13] to tackle the problem of data with class imbalance.
Assuming that the given labels  = (!, ", . . . , #), the class weight $ of the  -th
label is calculated as follows.</p>
      <p>$ = %&amp;(</p>
      <p>$
∑$'(! $
)
(8)</p>
      <p>We train multiple models through multiple strategies. Each model predicts the test
data separately. For each sample , the predicted probability of the model is
! + " + ) ! + " + )
 = [ , ]</p>
      <p>3 3
in which $ is the “no irony” probability of -th BERT model, $ is the “irony”
probability of -th BERT model.
4</p>
    </sec>
    <sec id="sec-4">
      <title>Result</title>
      <p>Based on five-fold cross-validation, we reported the result of BERTs model with three
strategies and other machine learning algorithms. We used Transformers2 library and
Pytorch3 library as backend to construct BERT-based models and scikit-learn4 to
construct machine learning models. The BERT5 model we used was pre-trained by
Souza et. al [14]. When using other machine learning algorithms, we selected the text
features with TFIDF. We used Bacc (Balanced Accuracy) as the evaluation indicator
and the results were shown in Table 2. We could see that the performance of most
algorithms was excellent, and the BERT models with three strategies were more than
0.99 on the validation set.
2 https://github.com/huggingface/transformers
3 https://github.com/pytorch/pytorch
4 https://github.com/scikit-learn/scikit-learn
5 https://huggingface.co/neuralmind/bert-base-portuguese-cased</p>
      <p>Due to the limitation of the number of contest submissions, we submitted three
results, the results of the test set were shown in Table 3 and Table 4. In the field of
news, we respectively submitted the result of BERT (Strategy 1), the result of BERT
(Strategy 3), and the fusion result of three BERT models. It can be seen that when
multiple models were fused, the performance dropped instead. Among the three
strategies, the strategy 3 with the worst performance on the validation set had the best
performance on the test set. This was because the model used more data for training,
which increased the generalization capability of the model to some extent. The result
reached the best performance in this evaluation competition. However, in the field of
tweets, our models were overfitting to the training data. Although the fusion strategy
had brought a certain improvement, the result of our test set was still very low, the
Bacc value was only 0.4975.</p>
    </sec>
    <sec id="sec-5">
      <title>Conclusion</title>
      <p>In the Irony Detection in the Portuguese language task in IberLeF 2021, we train three
kinds of models with different strategies based on the BERT model. Experimental
results as well as the leading position of our team on the task leaderboard in the field
of news demonstrate the effectiveness of our method. However, in the field of tweets,
our models are overfitting to the training data. In the future, we will try to solve the
problem of overfitting in tweets field in order to achieve better results on the Irony
Detection in the Portuguese language task.</p>
    </sec>
    <sec id="sec-6">
      <title>Acknowledgements</title>
      <p>This work was supported by the Key Field Project for Universities of Guangdong
Province (No. 2019KZDZX1016), the National Natural Science Foundation of China
(No. 61572145) and the National Social Science Foundation of China (No.
17CTQ045). The authors would like to thank the anonymous reviewers for their
valuable comments and suggestions.
9. de Freitas, L. A., Vanin, A. A., Hogetop, D. N., Bochernitsan, M. N., and Vieira, R.:
Pathways for irony detection in tweets. In: Proceedings of the 29th Annual ACM
Symposium on Applied Computing, pp. 628-633 (2014).
10. DA SILVA, F. R. A.: Detecção de ironia e sarcasmo em língua portuguesa: Uma
abordagem utilizando deep learning. (2018).
11. Marten, G. S., and de Freitas, L. A.: The Construction of a Corpus for Detecting Irony and</p>
      <p>Sarcasm in Portuguese. Brazilian Journal of Development 7(5), 47973-47984 (2021).
12. Devlin, J., Chang, M. W., Lee K., and Toutanova K.: BERT: Pre-training of Deep
Bidirectional Transformers for Language Understanding, In: Proceedings of NAACLHLT 2019,
pp. 4171-4186. (2019).
13. Wang, L., Lin X., and Lin, N.: Research on pseudo-label technology for multi-label
classification. In: 16th International Conference on Document Analysis and Recognition,
(2021).
14. Souza, F., Nogueira, R., and Lotufo, R.: BERTimbau: Pretrained BERT Models for
Brazilian Portuguese. In: Brazilian Conference on Intelligent Systems, pp. 403-417. (2020).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <surname>Sarmento</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Carvalho</surname>
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Silva M. J.</surname>
          </string-name>
          , et al.:
          <article-title>Automatic creation of a reference corpus for political opinion mining in user-generated content</article-title>
          .
          <source>In: Proceedings of the 1st international CIKM workshop on Topic-sentiment analysis for mass opinion</source>
          , pp.
          <fpage>29</fpage>
          -
          <lpage>36</lpage>
          (
          <year>2009</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <surname>Corrêa</surname>
          </string-name>
          , U. B.,
          <string-name>
            <surname>dos Santos</surname>
            ,
            <given-names>L. P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Coelho</surname>
          </string-name>
          , L.,
          <string-name>
            <surname>de Freitas</surname>
            ,
            <given-names>L. A.</given-names>
          </string-name>
          :
          <article-title>Overview of the IDPT Task on Irony Detection in Portuguese at IberLEF 2021</article-title>
          .
          <article-title>Procesamiento del Lenguaje Natural</article-title>
          , vol.
          <volume>67</volume>
          , (
          <year>2021</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <surname>Joshi</surname>
            ,
            <given-names>A.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Bhattacharyya</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Carman</surname>
            ,
            <given-names>M. J.:</given-names>
          </string-name>
          <article-title>Automatic sarcasm detection: A survey</article-title>
          .
          <source>ACM Computing Surveys (CSUR) 50(5)</source>
          ,
          <fpage>1</fpage>
          -
          <lpage>22</lpage>
          (
          <year>2017</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <surname>Baziotis</surname>
            ,
            <given-names>C.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Athanasiou</surname>
            ,
            <given-names>N.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Papalampidi</surname>
            ,
            <given-names>P.</given-names>
          </string-name>
          , et al.:
          <article-title>NTUA-SLP at SemEval-2018 Task 3 Tracking Ironic Tweets using Ensembles of Word and Character Level Attentive RNNs</article-title>
          .
          <source>CORR</source>
          (
          <year>2018</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <surname>Barbieri</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Camacho-Collados</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Neves</surname>
            ,
            <given-names>L.</given-names>
          </string-name>
          , et al.:
          <article-title>TweetEval: Unified Benchmark and Comparative Evaluation for Tweet Classification</article-title>
          .
          <source>CORR</source>
          (
          <year>2020</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6.
          <string-name>
            <surname>Ghanem</surname>
            ,
            <given-names>B.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Karoui</surname>
            ,
            <given-names>J.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Benamara</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          , et al.:
          <article-title>IDAT AT FIRE2019 Overview of the Track on Irony Detection in Arabic Tweets</article-title>
          .
          <source>In: Proceedings of the 11th Forum for Information Retrieval Evaluation</source>
          , pp.
          <fpage>10</fpage>
          -
          <lpage>13</lpage>
          (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <surname>Ortega-Bueno</surname>
            ,
            <given-names>R.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Rangel</surname>
            ,
            <given-names>F.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Hernández</surname>
            ,
            <given-names>F. D.</given-names>
          </string-name>
          , et al.:
          <article-title>Overview of the task on irony detection in Spanish variants</article-title>
          .
          <source>In: Proceedings of the Iberian languages evaluation forum (IberLEF</source>
          <year>2019</year>
          ),
          <article-title>co-located with 34th conference of the Spanish Society for natural language processing (SEPLN 2019), CEUR</article-title>
          , vol.
          <volume>2421</volume>
          , pp.
          <fpage>229</fpage>
          -
          <lpage>256</lpage>
          (
          <year>2019</year>
          ).
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <surname>Cignarella</surname>
            ,
            <given-names>A. T.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Frenda</surname>
            ,
            <given-names>S.</given-names>
          </string-name>
          ,
          <string-name>
            <surname>Basile</surname>
            ,
            <given-names>V.</given-names>
          </string-name>
          , et al.:
          <article-title>Overview of the evalita 2018 task on irony detection in italian tweets (ironita)</article-title>
          .
          <source>In: Sixth Evaluation Campaign of Natural Language Processing and Speech Tools for Italian (EVALITA</source>
          <year>2018</year>
          ), CEUR, vol.
          <volume>2263</volume>
          , pp.
          <fpage>1</fpage>
          -
          <lpage>6</lpage>
          (
          <year>2018</year>
          ).
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>