HLE - UPC at S em E val-2021 Task 5: Multi-Depth D istil BERT for Toxic Spans Detection (2021)

Abstract: This paper presents our submission to SemEval-2021 Task 5: Toxic Spans Detection. The purpose of this task is to detect the spans that make a text toxic, which is a complex labour for several reasons. Firstly, because of the intrinsic subjectivity of toxicity, and secondly, due to toxicity not always coming from single words like insults or offends, but sometimes from whole expressions formed by words that may not be toxic individually. Following this idea of focusing on both single words and multi-word expressions, we study the impact of using a multi-depth DistilBERT model, which uses embeddings from different layers to estimate the final per-token toxicity. Our quantitative results show that using information from multiple depths boosts the performance of the model. Finally, we also analyze our best model qualitatively.

## introduction semeval-2021 task 5: toxic spans detection @xcite consists in detecting which spans make a text toxic. this is quite relevant for nowadays lifestyle in which, aggravated by the covid-19 pandemic, online conversations have become key to communicate with our family, friends and job mates, or socialize through social networks and streaming chats. being able to moderate all this digital content is crucial in order to promote healthy online conversations and discussions. to tackle this problem, in hle-upc we have used a bert-based model with a fully-connected layer on top to perform named-entity recognition and classification (nerc), with the goal of tagging each word as either toxic or not. moreover, we have studied and proved that the use of information from different-depth layers enriches the final classification. our contributions to toxic spans detection are: the source code for our model and pipeline is available at https://github.com/rafelps/ hle-upc-semeval-2021-toxicspansdetection . ## related work toxicity the task in which we are participating is not the first one to focus on text toxicity. without going any farther, in last year's edition of semeval we can find task 12, also known as offenseval 2020 @xcite , in which the goal was to identify offensive language in multilingual social media data. in the previous year's competition, semeval 2019, task 6 @xcite was also tackling the identification and categorization of offensive language in social media. some of the models that solved these tasks involve convolutional neural networks (cnn) @xcite , long short term memory networks (lstm) (pham-hong and chokshi, 2020) or attention based models @xcite branched from the bert family @xcite . nerc all the mentioned models approach the task as sequence classification, this is, encoding a whole sentence and providing a unique prediction for it. toxic spans detection, however, goes a step further by asking participants to detect toxic spans, the exact characters or words that make a text toxic. for this reason, instead of modelling the task as sentiment analysis or document/comment classification, it seems more natural to approach it as token classification, generating an output for each token. more specifically, this task could be seen as a named entity recognition and classification (nerc) task, in which the goal would be to output the most probable sequence of labels (toxic or not) given an input sentence. in the field of nerc, we also find some interesting models. the state-of-the-art today are attentionbased models, usually stemming from transformers such as bert @xcite , which can be easily converted into a token classifier by adding a simple linear layer on top of the per-token output. however, we can also find some other attentionbased models using cnns @xcite or even recurrent architectures such as @xcite al. (2019 ## results all the results presented in this section have been calculated using the official metric, the f1-score on the predicted toxic offsets. for detailed information please refer to @xcite . ## conclusion in this work, we have presented a solution for the semeval-2021 task 5: toxic spans detection competition, which is a challenging task due to the subjectivity of toxicity and the requirement of context knowledge. during the development of our solution, a multidepth distilbert model, we have proved the power of pre-trained models and transfer learning to a downstream task with limited data, at the same time that we have demonstrated the benefits of combining the outputs of multiple bert models' layers for token classification. with an f1-score of 68.54% the presented model ranks 14 out of 91 participating teams in the competition and, although it presents some racial bias that could be corrected, from the qualitative results we conclude that it has a very good performance, hence being able to be used in real-life applications.