SRPOL DIALOGUE SYSTEMS at S em E val-2021 Task 5: Automatic Generation of Training Data for Toxic Spans Detection (2021)

Abstract: This paper presents a system used for SemEval-2021 Task 5: Toxic Spans Detection. Our system is an ensemble of BERT-based models for binary word classification, trained on a dataset extended by toxic comments modified and generated by two language models. For the toxic word classification, the prediction threshold value was optimized separately for every comment, in order to maximize the expected F1 value.

## introduction freedom of speech is one of the most important human rights. however, because the definition of protected speech is not precise enough, it can be easily misinterpreted and misused. the problem is magnified in cyberspace, where anonymity and asynchronous communication contribute to toxic disinhibition. as a result, the internet has become space where hatred, harsh criticism, rude language and threats may grow. currently, identification of such harmful content may depend mostly upon classification models that detect abusive comments or documents. however, semeval-2021 task 5: toxic spans detection proposes detecting fragments of text that make it toxic, with the aim of supporting manual moderation of oftentimes lengthy comments. a successful solution to this problem would be a crucial step towards more constructive and inclusive online discussions. the task focuses on english, which is the most common language used on the internet, as of january 2020 @xcite . in this paper we present the model we used for toxic span detection, the method we used to find optimal prediction threshold values, and two methods for producing new training examples with toxic spans annotation: a total of 91 teams made an official submission on the test set with the best submission achieving f1 score of 0.7083. our approach was ranked as 11th with 0.6865 f1 score (for details see section a of the appendix). the interest in automatic identification of abusive language has increased among researchers due to the importance of public discussion in the internet and its public impact. to our mind, the domain overlaps with other nlp tasks, such as sentiment analysis or comment classification. in an earlier piece of work, @xcite studied harassment detection on web 2.0 datasets (i.e. kongregate, slashdot and myspace) using tfidf n-gram features and svm models. in other research, @xcite analysed profanity detection in a community-based news site yahoo! buzz with svm and levenshtein distance. in later studies, @xcite tried to understand personal attacks in english wikipedia discussion comments using logistic regression and multilayer perceptron classifiers on character and word ngrams. in the last years there were several contests focusing on various aspects of offensive language. one of them included hate speech @xcite and misogyny identification @xcite for italian data. another workshop concerning a similar topic was multilingual detection of hate speech against immigrants and women in twitter at @xcite . recently, research has focused mostly on deep learning classification of cyber hate using "accept"/"non-offensive" or "reject"/"offensive" classes, e.g. @xcite . however, more and more papers concern explainability components and reasons. for example, organizers of semeval-2019 task 6, @xcite required identification of the offensive content type and the target of the offensive post. in another study, carried out by @xcite , aside from simple performance metrics, more complex bias and explainability factors were used to evaluate various deep neural networks models (cnn-gru, birnns and bert). a similar idea -to clarify rationales for hate speechcomes in semeval-2021 task 5: toxic spans detection @xcite . our solutions to this challenge are presented in this paper. ## data there are several abusive language detection datasets available (such as @xcite ). however, their purpose is toxicity detection of the whole text, so they do not contain information about the exact spans that make a text toxic. for such a task, the semeval-2021 toxic spans detection dataset was created. it consists of 10,629 english texts and their relative lists of toxic spans' indices (7,939 train, 690 trial, and 2,000 test texts with their respective spans). examples from the dataset are presented in the semeval-2021 task 5 annotated data turned out to be a challenging material to work on in some respects. it results mainly from somewhat inconsistent annotation which is visible in several dimensions, see appendix b. ## experimental setup the officially released datasets (both train and trial) contained altogether 8,629 texts. from those datasets we generated nine random train/dev/test splits, with the ratio 80/10/10%. from the train sets in each of the splits new data was generated using both methods described in 4.1: resampling data outside the span, and data augmentation. for resampling data, we used the bert based model (uncased) model with berttokenizerfast tokenizer or roberta base model with robertafa-sttokenizer. the upper limit of changes in the text was equal to 10. we trained the token classification model using only the train set, as well as the train set together with one or two sets of generated data. we used binary cross-entropy loss function and early stopping technique, ending the training after 3 consecutive epochs without the decrease of loss function on the dev set. the other hyperparameters used in the training were: batch size: 8, dropout rate: 0.5, learning rate: 1e-05, and max token sequence length: 340. we wanted to compare models trained on dataset with diverse sizes and, due to resampling, a lot of similar examples. to keep the evaluations for the early stopping in short and uniform intervals across all models we set a fixed number of steps per epoch: 800. all the nine models obtained from given crossvalidation splits were used for ensemble models. the best results were obtained via intersection and majority voting over models trained on crossvalidation splits. the final stage was postprocessing the spans. whitespaces and punctuation characters that were the only characters separating two parts of toxic spans were included in the toxic span, while all the other whitespaces and punctuation characters located at the ends of spans were removed. ## results the results of the models submitted to semeval-2021 competition are presented in we checked the results of token classifier trained with data obtain with the other tokenizers available, see the results of the models trained on augmented datasets, either with or without optimization of the prediction threshold, are presented in ## conclusions in many classification tasks we can observe a divergence of the objective function (e.g. f1 score), optimized loss function (e.g. cross-entropy) and applied prediction thresholds. our results demonstrate that even when the distribution of golden classes is crudely approximated by the assumption of independent and underperforming underlying model, the f1-optimized threshold values perform better than commonly used and accuracy-optimized threshold of 0.5 in the setting with noisy and automatically augmented training data. the implemented method of data augmentations, based on resampling non-toxic words proved to be effective by increasing the f1 score of token classifier.