AS tar T wice at S em E val-2021 Task 5: Toxic Span Detection Using R o BERT a- CRF , Domain Specific Pre-Training and Self-Training (2021)

Abstract: This paper describes our contribution to SemEval-2021 Task 5: Toxic Spans Detection. Our solution is built upon RoBERTa language model and Conditional Random Fields (CRF). We pre-trained RoBERTa on Civil Comments dataset, enabling it to create better contextual representation for this task. We also employed the semi-supervised learning technique of self-training, which allowed us to extend our training dataset. In addition to these, we also identified some pre-processing steps that significantly improved our F1 score. Our proposed system achieved a rank of 41 with an F1 score of 66.16%.

## introduction in recent years there has been an exponential increase in the use of social network platforms. with rising abusive language and hate on such platforms, it is more important than ever to maintain online conversations constructive and inclusive. this problem can be tackled by filtering toxic comments/posts. the massive volume of data generated at a fast pace makes manually filtering each comment complicated and time-consuming. this process can be automated by modelling it as a supervised classification problem. a similar task was proposed in semeval-2019 task 6: identifying and categorizing offensive language in social media (offenseval) @xcite . most of the top-ranked teams in this task used transformer language models @xcite @xcite or an ensemble of cnn and rnn @xcite to classify the sentences. the problem with the above approach is that it doesn't give moderators much knowledge about the reason for a sentence's toxicity. highlighting toxic spans can help human moderators who frequently deal with long comments and prefer attribution rather than just an unexplained toxicity score. semeval 2021 task 5: toxic span detection @xcite gave a chance to propose nlp systems to solve this problem. the task is concerned with developing systems that can recognise spans that contribute to the text's toxicity. this task had a few challenges. since the samples were from an online commenting platform, they were grammatically incorrect and consisted of many out of vocabulary words. the noisy and ambiguous structure of comments significantly hampers the performance of general nlp models. the training dataset had a little less than 8000 samples. thus, there was a need to select systems that can produce meaningful results, even with a limited number of training samples. undoubtedly, the hardest part is to identify spans that can account for the toxicity of the sample. the span could be as small as a single token and as large as the sample itself. the linguistic variations in the usage of words and phrases make such attribution even more difficult. we formulated the task as a sequence tagging problem and used roberta @xcite , a pre-trained transformer-based @xcite language model as our base model. we further pre-trained roberta on the civil comments dataset as a masked language model @xcite to create a domain-specific model. we employed a conditional random field (crf) layer @xcite for predicting the most probabilistic sequence of labels for each input sequence. we also applied a few pre-processing steps, which lead to significant performance improvements. lastly, we leveraged the semi-supervised learning technique of self-training @xcite @xcite ) by training our model on the manually annotated dataset and using it to further extend the training set by generating toxic spans for other unannotated datasets. we have made our system's implementation available through github 1 . the rest of the paper is organised as follows. section 2 explains our model implementation in detail. section 3 and 4 presents our experimental setup and achieved results, respectively. in section 4, we perform error analysis, followed by conclusions in the last section. ## results one interesting observation that can be drawn from ## error analysis figure 3 shows the variation of the f1 score across different toxic span lengths on the test dataset. our model achieved a very high f1 score when one (span length 1-9, mean f1 score: 83.17%) or two (span length 10-17, mean f1 score: 74.44%) words are marked as toxic in a text sample. as the number of characters marked as toxic increases, the f1 score falls drastically, reaching as low as 24.82% when more than 58 characters are marked as toxic. there are two main reasons for this. first, it is easier for the model to capture short-term dependencies than long-term dependencies. second, only 10% of the training data has a span length of more than 25 characters making the model less equipped to capture such toxic spans. to investigate our model's most problematic cases, we analysed the samples for which our model gave a zero f1 score. there were 447 such samples, of which 349 samples did not have any toxic span in the ground truth. this is also reflected in figure 3 , as the mean f1 score of all the samples with zero span length is 11.42%. further analysis revealed that our model tends to mark those tokens as toxic, which were frequently found to be toxic elsewhere. a few samples with empty toxic spans had doubtful gold annotations. however, in other samples, our model failed to capture the sentence's context precisely and predicts tokens that were not used in a toxic sense. ## conclusion this paper described our system developed for semeval-2021 task 5: toxic span detection. we built our solution on the roberta language model and conditional random fields (crf). though roberta alone can achieve great results, we highlighted the benefits of using external datasets and the performance improvements it can help us achieve. we pre-trained roberta on the civil comments dataset to impart domain-specific knowledge to it. we also employed the semisupervised learning technique of self-training to extend our training dataset. in addition to these, we also discovered some pre-processing steps that significantly improved our f1 score. experimenting with different tagging schemes, we found out that the bio scheme works the best with crf. in future, we plan to experiment with other language models such as t5 @xcite , xl-net @xcite and deberta @xcite . the system could also benefit from the addition of syntactic and semantic features at the word and sentence level.