MUDES : Multilingual Detection of Offensive Spans (2021)

Abstract: The interest in offensive content identification in social media has grown substantially in recent years. Previous work has dealt mostly with post level annotations. However, identifying offensive spans is useful in many ways. To help coping with this important challenge, we present MUDES, a multilingual system to detect offensive spans in texts. MUDES features pre-trained models, a Python API for developers, and a user-friendly web-based interface. A detailed description of MUDES’ components is presented in this paper.

## introduction offensive and impolite language are widespread in social media posts motivating a number of studies on automatically detecting the various types of offensive content (e.g. aggression @xcite , cyber-bullying @xcite , hate speech @xcite , etc.). most previous work has focused on classifying full instances (e.g. posts, comments, documents) (e.g. offensive vs. not offensive) while the identification of the particular spans that make a text offensive has been mostly neglected. identifying offensive spans in texts is the goal of the semeval-2021 task 5: toxic spans detection @xcite . the organisers of this task argue that highlighting toxic spans in texts helps assisting human moderators (e.g. news portals moderators) and that this can be a first step in semi-automated content moderation. finally, as we demonstrate in this paper, addressing offensive spans in texts will make the output of offensive language detection systems more interpretable thus allowing a more detailed linguistics analysis of predictions and improving the quality of such systems. with these important points in mind, we developed mudes: multilingual detection of offen-warning: this paper contains text excerpts and words that are offensive in nature. ## related work early approaches to offensive language identification relied on traditional machine learning classifiers @xcite and later on neural networks combined with word embeddings @xcite . transformer-based models like bert @xcite and elmo @xcite have been recently applied to offensive language detection achieving competitive scores @xcite in recent semeval competitions such as hateval @xcite offenseval @xcite . in terms of languages, the majority of studies on this topic deal with english (malmasi and zampieri, ## data the main dataset used to train the machine learning models presented in this paper is the dataset released within the scope of the aforementioned semeval-2021 task 5: toxic spans detection for english. the dataset contains posts (comments) from the publicly available civil comments dataset @xcite . the organisers have randomly selected 10,000 posts, out of a total of 1,2 million posts in the original dataset. the offensive spans have been annotated using a crowdannotation platform, employing three crowd-raters per post. by the time of writing this paper, only the trial set and the training set have been released and the gold labels for the test set have not yet been released. therefore, training of the machine learning models presented in mudes was done on the training set which we refer to as tsdtrain and the evaluation was conducted on the trial set which we refer to as tsdtrial set. in the general idea is to learn a robust model from this dataset and generalize to other english datasets which do not contain span annotation. another goal is to investigate the feasibility of annotation projection to other languages. other datasets in order to evaluate our framework in different domains and languages we used three publicly available offensive language identification datasets. as an off-domain english dataset, we choose the offensive language identification dataset (olid) @xcite , used in of-fenseval 2019 (semeval-2019 task 6) @xcite , containing over 14,000 posts from twitter. to evaluate our framework in different languages, we selected a danish (sigurbergsson and derczynski, 2020) and a greek @xcite dataset. these two datasets have been provided by the organisers of offenseval 2020 (semeval-2020 task 12) @xcite and were annotated using olid's annotation guidelines. the danish dataset contains over 3,000 posts from facebook and reddit while the greek dataset contains over 10,000 twitter posts, allowing us to evaluate our dataset in an off-domain, multilingual setting. as these three datasets have been annotated at the instance level, we followed an evaluation process explained in section 5. ## methodology the main motivation behind this methodology is the recent success that transformer models had in various nlp tasks @xcite including offensive language identification @xcite @xcite . most of these transformer-based approaches take the final hidden state of the first token ([cls]) from the transformer as the representation of the whole sequence and a simple softmax classifier is added to the top of the transformer model to predict the probability of a class label @xcite . however, as previously mentioned, these models classify whole comments or documents and do not identify the spans that make a text offensive. since the objective of this task is to identify offensive spans rather than classifying the whole comment, we followed a different architecture. as shown in figure 1 , the complete architecture contains two main parts; language modeling (lm) and token classification (tc). in the lm part, we used a pre-trained transformer model and retrained it on the tsdtrain dataset using masked language modeling (mlm). in the second part of the architecture, we used the saved model from the lm part and we perform a token classification. we added a token level classifier on top of the transformer model as shown in figure 1 . the token-level classifier is a linear layer that takes the last hidden state of the sequence as the input and produce a label for each token as the output. in this case each token can have two labels; offensive and not offensive. we have listed the training configurations in the appendix. we experimented with several popular transformer models like bert @xcite , xlnet @xcite , albert @xcite , roberta @xcite etc. from the pre-trained transformer models we selected, we grouped the large models and base models separately in order to release two english models. a large model; en-large which is more accurate, but has a low efficiency regarding space and time. the base model; en-base is efficient, but has a comparatively low accuracy than the en-large model. all the experiments have been executed for five times with different random seeds and we took the mode of the classes predicted by each random seed as the final result @xcite . multilingual models -the motivation behind the use of multilingual models comes from recent works @xcite @xcite which used transfer learning and cross-lingual embeddings. these studies show that cross-lingual transformers like xlm-r @xcite can be trained on an english dataset and have the model weights saved to detect offensive language in other languages outperforming monolingual models trained on the target language dataset. we used a similar methodology but for the token classification architecture instead. we used xlm-r cross-lingual transformer model @xcite as the transformer in figure 1 on tsdtrain and carried out evaluations on the danish and greek datasets. we release two multilingual models; multilingual-base based on xlm-r base model and multilingual-large based on xlm-r large model. ## evaluation and results we followed two different evaluation methods. in section 5.1 we present the methods used to evaluate offensive spans on the tsdtrial set. in section 5.2 we presented the methods used to evaluate the other three datasets which only contained post level annotations. ## conclusion this paper introduced mudes: multilingual detection of offensive spans. we evaluated mudes on the recently released semeval-2021 toxic spans detection dataset. our results show that mudes outperforms the strong baselines of the competition. furthermore, we show that once mudes is trained on english data using state of the art cross-lingual transformer models, it is capable of detecting offensive spans in other languages. with mudes, we release a python library, four pre-trained models and an user interface. we show that mudes is efficient to use in real time scenarios even in a non gpu environment. in future work, we would like to further evaluate mudes on other datasets. finally, we would like to implement a flexible multitask architecture capable of detecting offense at both span and post level.