Y oung S heldon at S em E val-2021 Task 5: Fine-tuning Pre-trained Language Models for Toxic Spans Detection using Token classification Objective (2021)

Abstract: In this paper, we describe our system used for SemEval 2021 Task 5: Toxic Spans Detection. Our proposed system approaches the problem as a token classification task. We trained our model to find toxic words and concatenate their spans to predict the toxic spans within a sentence. We fine-tuned Pre-trained Language Models (PLMs) for identifying the toxic words. For fine-tuning, we stacked the classification layer on top of the PLM features of each word to classify if it is toxic or not. PLMs are pre-trained using different objectives and their performance may differ on downstream tasks. We, therefore, compare the performance of BERT, ELECTRA, RoBERTa, XLM-RoBERTa, T5, XLNet, and MPNet for identifying toxic spans within a sentence. Our best performing system used RoBERTa. It performed well, achieving an F1 score of 0.6841 and secured a rank of 16 on the official leaderboard.

## introduction internet and social networking sites have brought people together by providing a simple yet effective method of communication. over the years people used it to exchange positive ideas but recently, there has been a rise in toxic content and hate speech over the internet @xcite . most datasets @xcite dealing with the problem of toxic, offensive, or hateful content aim to classify the entire text belonging to a particular class. they do not identify the parts of the text that make it toxic. manual filtering of toxic data is tough and can cause mental and emotional stress to annotators @xcite ). an automatic system with the ability to identify toxic text and highlighting toxic spans can be useful for the moderators. it will help save time and prevent stress caused by reading long texts. semeval 2021 task 5: toxic spans detection @xcite draws attention to the problem of identifying toxic spans present in a sentence. our proposed system makes use of a word-level classifier for detecting the offensive words present in a sentence. the offsets of the toxic words can then be concatenated to find the toxic spans. we made use of pre-trained language models (plms) for building our classifier. we experimented with bert @xcite , electra @xcite , roberta @xcite , xlnet @xcite , mpnet @xcite , t5 @xcite , and xlm-roberta @xcite to compare their performance on the task of toxic spans detection. owing to the increase in the number of pre-trained language models choosing the correct model is an important decision as these models contain millions of parameters and are expensive to train. so, we present a comprehensive analysis of the performance of different models, which can serve as a baseline for future work. our best performing system was fine-tuned using roberta and attained an f1 score of 0.6841. it was ranked 16 on the official leader board. we used different plms for fine-tuning and found exceedingly small variations in their performance. further analyzing our model's performance on the test set we observed that it is essential for the model to not only detect toxic spans but also decide if it needs to predict toxic spans for that sample or not. our code is available online foot_0 for method replicability. ## background identification of toxic/offensive content is an important task in natural language processing. it is essential for the moderation of harmful content over social media sites that might hurt the sentiments of individuals, groups, or communities at large. much work has been done on the identification of offensive content. offenseval 19, 20 @xcite provide a comprehensive analysis of methods useful for the identification of offensive content. semeval 2020 task 8: memotion analysis @xcite presented with a dataset of internet memes with one sub-task to detect and quantify offensive content. work done in (brassard-gourdeau and khoury, 2019) explores different aspects of sentiment detection and their correlation to toxicity. @xcite covers the effect of context on toxicity. (d'sa et al., 2020) uses bert and fasttext for toxicity detection. @xcite covers several attacks to by-pass toxic content filters and methods to make the filters robust to such attacks. recent state-of-theart systems @xcite @xcite performed well in identifying offensive content. work done in @xcite shows that although recent systems perform well on given datasets, very slight changes made by adversaries may fool the models. adding words like "love" to offensive tweets may make it less offensive. identifying toxic content is an important nlp task. it is useful in moderating online content over the web having millions of users. most problems deal with labeling the entire content as toxic/nontoxic. none of the previous work has tried to identify spans within a text that makes it toxic. semeval-2021 task 5: toxic spans detection aims to bring attention to this problem via the task defined as: given a dataset d of sentences, the objective of the task is to learn a classification function that can predict the toxic spans t present in the given sentence. the content of the provided dataset d was in english. dataset statistics: the dataset for the task consisted of character offsets for toxic spans present for each text sample. the span consisted of single words as well as a collection of words. from ## results and analysis we further analyzed the performance of our model on the test set. we evaluated the performance of our model on samples containing any number of toxic words vs no toxic words. in the case of samples that had no toxic words in a sample, our model could not perform well. only 6.09% of samples with no toxic words were classified correctly. the dataset statistics for the test set show that samples with no toxic words constitute 19.7 % of the test set. the training and development set had only 6.12% and 6.23% samples without any toxic words. we also found the top 15 most common words which were predicted as toxic from samples containing no toxic words in the test set. the words are given in we can observe that ## conclusion in this paper, we describe our approach for se-meval 2021 task 5: toxic spans detection. we propose a word-level classifier for identifying the toxic words in a sentence. we experimented with different plms to provide a comprehensive analysis of their performance for identifying toxic spans. we performed well, getting a rank of 16 on the leader board. our analysis shows that a word-level classifier performs extremely well for sentences that contain at least one toxic word. however, it cannot identify cases with no toxic spans efficiently. in the future, we would like to work on solving this problem by using a classifier to simply predict if the sentence is toxic/non-toxic along with span detection.