Towards Safer Communities: Detecting Aggression and Offensive Language in Code-Mixed Tweets to Combat Cyberbullying (2023)

Abstract: Cyberbullying is a serious societal issue widespread on various channels and platforms, particularly social networking sites. Such platforms have proven to be exceptionally fertile grounds for such behavior. The dearth of high-quality training data for multilingual and low-resource scenarios, data that can accurately capture the nuances of social media conversations, often poses a roadblock to this task. This paper attempts to tackle cyberbullying, specifically its two most common manifestations - aggression and offensiveness. We present a novel, manually annotated dataset of a total of 10,000 English and Hindi-English code-mixed tweets, manually annotated for aggression detection and offensive language detection tasks. Our annotations are supported by inter-annotator agreement scores of 0.67 and 0.74 for the two tasks, indicating substantial agreement. We perform comprehensive fine-tuning of pre-trained language models (PTLMs) using this dataset to check its efficacy. Our challenging test sets show that the best models achieve macro F1-scores of 67.87 and 65.45 on the two tasks, respectively. Further, we perform cross-dataset transfer learning to benchmark our dataset against existing aggression and offensive language datasets. We also present a detailed quantitative and qualitative analysis of errors in prediction, and with this paper, we publicly release the novel dataset, code, and models.

## introduction social media is a group of internet-based applications that allows the creation and exchange of usergenerated content. lately, it has risen as one of the most popular ways in which people share opinions with each other @xcite . with rapid advances in web 3.0, social media is expected 1 https://github.com/surrey-nlp/ woah-aggression-detection/blob/main/data/ new10kdata/cyberbullying_10k.csv oag you wont march against kids being raped in country or the endless stream of migrants maybe cheaper energy no but you would march against @username pathetic fking pathetic! cag wait a few days sir, you are getting used to hearing harsh words. in future, when all the banks will be of adani or ambani, then you will also have to listen to abuses for withdrawing your deposits. #demonetisation nag well this is pure goosebumps, whenever i see him i feel so proud that he is our pm, a living legend for sure to evolve and emerge as an even more vital and potent means of communication. simultaneously, there has also been noticed a sharp uptick in bullying behavior -including but not limited to the use of snide remarks, abusive words, and personal attacks, going as far as rape threats @xcite on such platforms. in this context, by leveraging the technological advancements in machine learning and natural language processing, automatic detection of instances of cyberbullying on social media platforms such as twitter can help create a safer environment. here we investigate two forms of cyberbullying -aggression and offensiveness. aggression has been defined as any behavior enacted with the intention of harming another person who is motivated to avoid that harm @xcite . several studies have noted the proliferation of abusive language and an increase in aggressive content on social media @xcite off bhikaris like u, can u first afford watching movie in threatres? talk about that first. just coz internet is cheap does not mean u will do open defecation in social media. mdrchd bhaag bsdk not who doesn't enjoy the daily press briefings? they really ease the tension! we have to find some way to keep ourselves entertained our work deals with two different but correlated classification tasks. in the available literature, both have been investigated with the help of various machine learning and deep learning-based methods. below, we provide a detailed overview of the literature from both tasks in separate subsections. ## dataset creation we create a dataset containing a mix of english and hindi-english sentences, to ensure that sufficient data is available for our research. we used the official twitter api to obtain data from twitter. initially, we collected 15,000 tweets based on the search results for one of the 52 keywords (listed in we filtered out tweets that were in any language other than english or hindi (or containing a mix of both) using xlm roberta-base with a classification head on top @xcite . next, with the help of hingbert-lid code-mixed language identification model @xcite , we created subsets of tweets belonging to one of the two aforementioned categories. we preprocessed the tweets by masking all usernames to minimize the introduction of bias to the annotators. finally, after cleaning, we were left with 5,452 english monolingual and 4,548 hindi-english code-mixed tweets. ## approach in recent times, sequence classification via finetuning of pre-trained language models has become a standard approach for performing various nlp tasks. we take a similar approach and fine-tune some pre-trained language models for the two tasks, and report the results in the next section. we work with two general-purpose english models, one multilingual model, one model trained specifically on hindi-english code-mixed data, and one trained exclusively on twitter data. every tweet containing a sequence of words is tokenized into a sequence of sub-words using the model-specific tokenizer. this sequence of subword tokens is the input to the model that passes through the transformer's encoder layers. an encoder representation for each token in the sequence is the output from the transformer. we take the encoder representation of the [cls] token in the case of bert or the last encoder hidden states for other models. the output layer is a linear layer followed by the softmax function, which takes in the above representation. the model is trained by optimizing for a custom weighted cross-entropy loss value which we explain in detail in an upcoming subsection. experimental setup we fine-tune for the aforementioned two tasks the following pre-trained language models: bert @xcite and roberta @xcite which are trained on english data, xlm-r @xcite base which is trained over multilingual data containing both hindi and english, hingroberta @xcite , a multilingual language model specifically built for hindi-english code-mixed language as seen in the indian context, and bernice @xcite , a multilingual language model trained exclusively on twitter data. ## results we report the results obtained via fine-tuning pretrained language models in this section. for aggression, we observe that xlm-r base outperforms other pre-trained language models on our overall dataset, achieving the highest macro f1score of 67.87. on the english subset, we observe that roberta base performs better than other models with a macro f1-score of 66.63, whereas for the hindi-english code-mixed subset, hing-roberta gives the best macro f1-score of 66.94. for offensive language detection, we observe that hing-roberta outperforms other pre-trained language models on our overall dataset, achieving the highest macro f1-score of 65.45. on the english subset, we observe that roberta base outperforms other models with a macro f1-score of 63.46. for the hindi-english code-mixed subset, hing-roberta once again gives the best performance with a macro f1-score of 64.97. ## conclusion and future work this paper presents a novel dataset to model aggressiveness and offensiveness in text. we analyze this dataset using approaches such as fine-tuning pre-trained language models for the task of aggression detection and offensive language detection and report the results. our analysis also takes into account the code-mixing phenomenon observed on social media platforms as we report additional results for this task. since aggression and offense can be subtle, and their identification in the text can sometimes be subjective, it is important to note the limitations of such a study -which we discuss in the next section. we release any data (including any raw data, but only in the form of tweet ids and their respective labels for the two tasks), code, and models produced during this study publicly for further research by the community. we license this release under cc-by-sa 4.0. in the near future, we aim to annotate this data for tasks such as sarcasm detection -to develop a deeper understanding of how it is related to aggression and offensiveness. additionally, the motivation for collecting the same data instances marked with aggression and offense labels is for a multitask learning-based model also to be able to identify when 1) the tone of a text is aggressive without being offensive vs., 2) the text is offensive, despite it not being overtly aggressive. we also aim to collect more data and annotate it using weak supervision. finally, we also aim to expand on the theoretical underpinnings of sublime aggression and offense by attempting to identify these within other more tangential domains, viz., comedy.