Hate-Speech and Offensive Language Detection in R oman U rdu (2020)

Abstract: The task of automatic hate-speech and offensive language detection in social media content is of utmost importance due to its implications in unprejudiced society concerning race, gender, or religion. Existing research in this area, however, is mainly focused on the English language, limiting the applicability to particular demographics. Despite its prevalence, Roman Urdu (RU) lacks language resources, annotated datasets, and language models for this task. In this study, we: (1) Present a lexicon of hateful words in RU, (2) Develop an annotated dataset called RUHSOLD consisting of 10,012 tweets in RU with both coarse-grained and fine-grained labels of hate-speech and offensive language, (3) Explore the feasibility of transfer learning of five existing embedding models to RU, (4) Propose a novel deep learning architecture called CNN-gram for hate-speech and offensive language detection and compare its performance with seven current baseline approaches on RUHSOLD dataset, and (5) Train domain-specific embeddings on more than 4.7 million tweets and make them publicly available. We conclude that transfer learning is more beneficial as compared to training embedding from scratch and that the proposed model exhibits greater robustness as compared to the baselines.

## introduction in the last decade, online social media platforms have become extremely popular, with users growing exponentially. these platforms provide users with the freedom to express their opinions and ability to interact with people of diverse groups. on one hand, this has resulted in exchanges of ideas and fostered relationships, while on the other, it is exploited to spread, incite, promote, or justify hatred, violence, and discrimination against users based on their gender, religion, race, affiliation with certain groups, and views related to certain events or subjects (e.g., politics) through hateful, offensive, derogatory, or obscene language. if such content is left unaddressed, it has known to lead to acts of violence and conflicts on a broader scale, resulting in problems for the protection of human rights, the rule of law, and freedom of speech, which are essentials for the development of an unprejudiced democratic society. most of the social media platforms address this issue by employing techniques such as reporting and manual review by humans, which is limited by the reviewer's speed, ability to understand the evolution of slang, jargon, and familiarity with multilingual content. apart from these issues, this process generally takes 24 hours, and by that time, the intended damage has already taken place. moreover, the manual process also poses problems related to the subjective notions of what constitutes hate-speech and offensive language, which might result in misuse of this process to silence minorities and to suppress criticism of official policies, political opposition, or religious beliefs. thus, an automated system to detect hate speech and offensive language is inevitable. in the last few years a string of events in pakistan, such as the lynching of a student due to online anti-religious propaganda against him foot_0 , smearing campaigns against famous political leaders and social media personalities, women being regularly targeted and harassed for sharing their viewpoints online, and the targeting of religious minorities to hurt their religious sentiment has prompted the government to make legislation against online hatespeech such as "national action plan" and "the prevention of electronic crime bill". such measures speak volumes for the problems related to online hate-speech faced in the country and the need for automated systems to help counter such content. the majority of the initial research on hate-speech and offensive language detection is mainly focused on the english language. although english is the official language of pakistan, urdu is treated as the national language. people tend to write urdu using latin scripts and code-switch between two languages in the same conversation (i.e., alternative use of ru and english languages within the same speech, clause/sentence or constituent/element) @xcite . this unique and informal dialect of communication is known as roman urdu (ru). it is a significantly more challenging language to model as compared to formal languages (i.e. languages that follow proper grammatical structure and standard dictionary) due to factors such as colloquial verbiage, improper grammar, spelling variations, self-made abbreviations, and code-switching (shakeel and karim, 2020). it is known that the nature of hatespeech content changes with demographics, thus, language resources, labeled datasets, and models for multiple languages are crucial to facilitate the research in this area @xcite . however, despite its prevalence, ru is under-resourced in this context. to this end, we make following contributions. rest of the paper is organized as follows. section 2 presents a discussion on the background of the problem. in section 3, details of the ruhsold dataset, it's annotation process, and definition of labels is discussed. section 4 presents the experimental design and details of baseline models. the proposed model is introduced in section 5 while we present the results and discussion in section 6. finally, we give concluding remarks in section 7. ## background research in automatic hate-speech detection has been evolving rapidly over the last five years. much of the existing research consists of diverse yet related tasks. for instance @xcite ; @xcite focus on detection of racism and sexism on twitter, @xcite work on differentiating offensive language from hatespeech on twitter, and de gibert et al. (2018) focused on hateful and non-hateful speech in a white supremacy forum. such a diverse set of terminologies has given a rise to problems such as duplication of research, absence of interrelationships, and the lack of re-usability across different strands of the hate-speech and offensive language detection tasks @xcite . to address this issue @xcite studies these terminologies to find interrelationship between them and provide a selection of labels that eliminate ambiguities of perceivable overlap between them. in an effort to develop resources, datasets, and models for hate-speech and offensive language detection in multiple languages, a shared task called hate-speech and offensive content identification (hasoc) in indo-european languages is organized under forum for information retrieval evaluation (fire) @xcite . this task focuses on hindi, german and english languages. in the last couple of years, several datasets have been made public in languages such as german @xcite , polish @xcite , portuguese @xcite , indonesian (ibrohim and budi, 2019), hindi @xcite , etc. however, despite its prevalence, there is no publicly available dataset for ru to the best of our knowledge. with regards to language models for hate-speech and offensive language detection, @xcite have used features such as pos tags, tf-idf vectors, emotion lexicon, and n-grams with multiple classifiers such as logistic regression, naive bayes, svm, decision tree, and random forest. such approaches rely on local information and are therefore unable to capture context and long-term dependencies in texts where hate-speech is subtle and cannot be judged without taking the entire span of the text into account. with the advent of larger datasets, researchers have shifted to data-hungry deep learning based approaches which are better at learning semantics, contexts, and long-term dependencies @xcite . @xcite performed a comparative study for machine learning and deep learning models and concluded that deep learning models are more accurate. they also highlighted the fact that different features are important for each hate-speech label, all of which cannot be captured by a single model. thus, ensemble methods have been used by studies such as park and fung (2017), who have used a hybrid-convolutional neural network (cnn) which combines word and character level @xcite , who have used an ensemble of long short-term memory (lstm) classifiers with majority voting and confidence based aggregation, and @xcite , who used an ensemble of cnn and lstm based classifiers to capture both salient local information and long term contexts. however, ensembles are carefully selected task-specific combinations which might not generalize well and are computationally expensive. thus a single model with a greater robustness and generalization is desirable. the rising success of transfer learning in other deep learning domains such as computer vision and the success of transformer models in many natural language processing (nlp) domains has led to its adoption by many of the researchers who took part in the recent hasoc track at fire 2019. these models have outperformed other modeling techniques in five out of eight sub-tasks for different languages. their success can mainly be attributed to either using ensemble models or performing transfer learning using a pre-trained multilingual transformer embedding model called bert @xcite . keeping these developments in view, we also examine the transfer learning capa-bilities of five existing embedding models. ## roman urdu hate-speech and offensive language detection (ruhsold) dataset in the literature, researchers create hate-speech datasets by extracting hateful content from online resources by means of a collection of languagespecific lexicons of hateful words @xcite @xcite . despite hatebase.org having the largest collection of multilingual hateful words, it lacks such lexicon base for ru. to this end, we have constructed our own lexicon of hateful words (by searching for such keywords online and interviewing people). this lexicon consists of abusive and derogatory terms along with slurs or terms pertaining to religious hate and sexist language. using this lexicon along with a separate collection of ru common words, we search and collect 20, 000 tweets and perform a manual preliminary analysis to find new slang, abuses, and identify frequently occurring common terms. the choice to add common ru words is made in order to extract random inoffensive tweets and the tweets that are offensive but do not contain any offensive words e.g., tweet: aap apni behan. beti.. maan ... aur bivi ka march karwa do phir translation: then do a march of you sister, daughter, mom and wife. the tweet is offensive as it targets close relations and tries to demean them but does not contain any hateful/offensive terms/lexicon. we discard words or terms for which the number of extractable tweets are too few. using this updated lexicon we search and collect 50, 000 new tweets. from this updated tweet base, around 10, 000 tweets are randomly sampled for annotations. to avoid issues related to user distribution bias as highlighted by @xcite , we restrict a maximum of 120 tweets per user. to create a gold-standard, the data is manually labeled by three independent annotators and is called roman urdu hate-speech and offensive language detection (ruhsold) dataset. during the annotation process, all conflicts are resolved by a majority vote among three annotators. tweets on which a consensus cannot be reached or that are reckoned to provide insufficient information for labeling are discarded and replaced by new randomly sampled tweets from the data collection. we develop the gold-standard for two sub-tasks. first sub-task is based on binary labels of hate-offensive content and normal content (i.e., inoffensive language). these labels are self-explanatory. we refer to this sub-task as "coarse-grained classification". second sub-task defines hate-offensive content with four labels at a granular level. these labels are the most relevant for the demographic of users who converse in ru and are defined in related literature. we refer to this sub-task as "fine-grained classification". the objective behind creating two gold-standards is to enable the researchers to evaluate the hatespeech detection approaches on both easier (coarsegrained) and challenging (fine-grained) scenarios. all labels and their definitions are summarized as follows: abusive/offensive: profanity, strongly impolite, rude or vulgar language expressed with fighting or hurtful words in order to insult a targeted individual or group @xcite @xcite . sexism: language used to express hatred towards a targeted individual or group based on gender or sexual orientation @xcite @xcite . religious hate: language used to express hatred towards a targeted individual or group based on their religious beliefs or lack of any religious beliefs and the use of religion to incite violence or propagate hatred against a targeted individuals or group @xcite . e.g profane: the use of vulgar, foul or obscene lan- normal: this contains text that don't fall into the above categories. religious hate and sexism can be combined under the umbrella of the single "hate-speech" tag as defined in @xcite . however, in our case, this defeats the purpose of identifying hate-speech and offensive content at a granular level while at the same time differentiating between the subject matter of abusive content. thus we refrain from merging any labels. we split the data in train, test, and validation sets with 70,20,10 split ratio using stratification based on fine-grained labels. the use of stratified sampling is deemed necessary to preserve the same labels ratio across all splits. this way, train split contains 7, 209 tweets while test and validation splits have 2003, and 801 tweets respectively. these standard splits along with ru lexicon base is made publicly available to further the research in this direction 2 . ## experimental design in this section, we describe the details of the experiments designed to evaluate the performance of different embeddings, baseline models, and the proposed model for both tasks (i.e., coarse-grained and fine-grained classification). it is shown in literature that using pre-trained word embeddings for nlp tasks improves the predictive performance of the models @xcite . although, for many years, robust pretrained embeddings were mainly limited to the english language, in recent years, multilingual embeddings are also made publicly available. these embeddings include laser @xcite , elmo @xcite , bert @xcite , xlm-roberta @xcite , and fasttext @xcite . thus we first compare the out-of-the-box performance of these five pre-trained embeddings. we also fine-tune these embeddings on ruhsold dataset in order to gauge their capability of transfer learning to a different domain and language. we use tokenizers for all embedding models from hug-gingface library 3 while for bert, "base" version is used. to exhibit the contrast to transfer learning, the domain-specific embeddings called romurem are also trained. we use twitter api to collect 4, 770, 677 random and hate-speech tweets and use word2vec @xcite to train 200 dimensional embeddings. we set the window size to 5, minimum word count to 2, and the number of iterations in pre-training to 10. these embeddings are also made publicly available along with dataset. secondly, we compare the performance of seven baseline models through extensive experimentation. the comprehensive details of each model are described below. ## results and discussion in this section, we discuss the findings of our experiments. subsequent two subsections present the results on test split of ruhsold dataset for coarse-grained and fine-grained classification respectively. ## conclusion and future work in this work, we presented a dataset in roman urdu for the task of hate-speech detection in social media content, annotated with five fine-grained labels. we also make publicly available domain-specific embeddings trained on a parallel corpora of more than 4.7 million tweets. furthermore, an extensive experimentation with respect to multiple embeddings, their power of transfer learning, and comparison with existing baseline models is carried out. as a future research, semantically challenging cases at fine-grained level with respect to complexities of abusive/offensive (targeted) and profane (untargeted) language demand further investigation.