HARALD : Augmenting Hate Speech Data Sets with Real Data (2022)

Abstract: The successful completion of the hate speech detection task hinges upon the availability of rich and variable labeled data, which is hard to obtain. In this work, we present a new approach for data augmentation that uses as input real unlabelled data, which is carefully selected from online platforms where invited hate speech is abundant. We show that by harvesting and processing this data (in an automatic manner), one can augment existing manually-labeled datasets to improve the classification performance of hate speech classification models. We observed an improvement in F1-score ranging from 2.7% and up to 9.5%, depending on the task (in- or cross-domain) and the model used.

## introduction hate speech detection (offensive, abusive, toxic) is of interest to academic researchers in a variety of domains, including computer science @xcite and sociology @xcite . it is also of interest to online social platforms that wish to maintain certain standards of discourse or are obliged to do so by law in some countries. hate speech is commonly defined as "any communication that disparages a target group of people based on some characteristics such as race, color, ethnicity, gender, sexual orientation, nationality, religion, or other characteristic" @xcite . detecting hate speech may be difficult because the manifestation of speech as hate speech depends on a non-trivial interaction between various circumstances such as the topic, the context, the timing, outside events, and the identity of the speaker and recipient @xcite . the typical way hate speech detection is approached is as a supervised-learning classification task, where lexical features and other features (e.g. word-embedding) are used to train a classifier @xcite @xcite . to that end, access to labeled corpora is essential. since hate speech has many facets and there are few (or none) universal "gold-standard" datasets, authors usually collect and label their data. the size of collected corpora varies considerably ranging from around 100 labeled comments @xcite to several thousand @xcite . collecting and annotating hate-speech data is challenging and extremely time-consuming for two main reasons. first, there are much fewer hateful than benign comments present in randomly sampled data. second, to manually annotate a data set, either expert annotators or crowd-sourcing services, such as amazon mechanical turk, are employed. while crowd-sourcing has obvious advantages for this task, the annotation quality of non-expert annotators was demonstrated to be poorer than that of experts @xcite . there were several attempts to deal with these problems. @xcite proposed to select the text to be annotated by looking for topics that are likely to contain a higher degree of hate speech. they collected 136,052 tweets, about 10% were annotated (16,914 tweets), and about a third of them were labeled as hate speech. while this increased the proportion of hate speech posts, it focuses the resulting data set on specific topics and thus hinders the generalizability to other domains @xcite . another possible solution to the aforementioned two challenges may be found in data augmentation; this avenue is intensively developed for example, in computer vision but "relatively under-explored" in nlp, where the generation of effective augmented examples is "less obvious" @xcite . ## our contribution and method this paper presents a new data augmentation pipeline for offensive/hate speech data called har-ald, which stands for hate augmentation with real data. unlike common data augmentation methods that generate synthetic data (using gans or other generative models) harald outputs an endless stream of relevant real data written by a huge number of authors, rich with various stylistic, grammatical, and semantic forms. our method hinges upon the existence of online platforms where people are explicitly asked to be abusive. one such platform is the subreddit r/roastme/, in which users upload a picture and ask their peers to "roast them", with the intention to develop a thicker skin by withstanding the abusive speech (the logo of the subreddit is "the thicker the skin, the better the roast "). see the appendix for an excerpt from roastme. to validate harald's usefulness, we conducted the following experiment, inspired by the cross-domain evaluation of @xcite . we harvested from r/roastme/ a total of 3700 messages and assigned each message a hate score, the output of the last gelu layer of a pre-trained bert model for hate speech detection @xcite . we then sorted the messages and took the top 1,000 as the positive class of the roastme (rm) dataset. we then selected six well-known datasets of hate/offensive speech to fine-tune the bert-base-uncased model @xcite on each of the datasets separately (see section 4 for details on the datasets). we tested the cross-domain performance of each of the six models on the other five datasets. we then repeated this experiment, but now we added another fine-tune step with the rm dataset. we also conducted an in-domain (crossvalidation) test. all detail in section 5. we observed an improvement in macro f1-score ranging from 2.7% and up to 9.5%, depending on the task (in or cross domain) and on the model that was used (see ## related work data augmentation methods have been explored to address the imbalance of datasets challenge in supervised classification tasks. noise injection or attribute modification techniques were commonly applied to generate synthetic data for image and sound classification tasks @xcite @xcite . however, such techniques do not extend to text due to the categorical nature of words and the sequential nature of text. there are very few works that explored data augmentation in hate speech detection. @xcite , and similarly @xcite , explored various data augmentation techniques for hate speech: substituting words, swapping word positions, and neural generation using rnn @xcite . each of these methods has its limitations. it is challenging to find suitable semantically similar words in the fast-evolving social media platforms; swapping words' positions may harm the coherence of the sentence. the authors of @xcite ) propose a gan methodology, hategan, to augment two data sets. they train lstm and cnn models on the augmented datasets and show a 5% improvement in f1 score. they also show that hategan outperforms @xcite . in @xcite , real non-toxic text was harvested similarly to us, but for the task of mitigating unintended biases in text classification. one has to note, though, that most online text is non-toxic, so automatically harvesting toxic or non-toxic text is by no means equivalent tasks. our work differs from these works in several key aspects. (1) harald produces real rather than synthetic data, the distribution of which is different than the dataset to be augmented. previous work generates synthetic data from the existing dataset and makes a point that the data has the same distribution as the data to be augmented. (2) we train sota hate speech classification models, bert, while weaker models such as lstm or cnn were used in previous work. (3) harald improves at a more challenging task -cross-domain prediction. we surmise that the fact that rm has a different distribution than the original dataset plays a key factor in improving the prediction results. (4) we evaluate harald in six different datasets, while previous work used a maximum of three. finally, let us discuss the subreddit r/roastme. roastme presents an intriguing case of how alternative norms can emerge in online communities, allowing behaviors that are otherwise condemned as inappropriate to be reframed as acceptable. in this community, users post photos of themselves with the explicit expectation of being mocked or ridiculed by others. roastme is not alone, with similar subreddits such as r/toastme, and r/judgemeplease. the norms and values of the roastme community were studied, for example, in @xcite . in @xcite , roastme was used for the task of style transfer, rephrasing slurs as compliments and vice versa. ## data we turn to describe the rm dataset and the other six datasets that we augmented using rm in order to evaluate the performance of harald. all datasets appear in the project's github page @xcite . the roastme (rm) dataset. that paper overall supports our thesis (to quote, "r/roastme, a comedy-focused subreddit of the parent site reddit.com, wherein members post photos of themselves to be ridiculed by other members; the site generally encourages harsh and offensive forms of humor in these interpersonal exchanges"). we harvested 3700 comments from the roastme using the praw api. we removed comments with less than three words, and cleaned them from links, emojis, stop words, and punctuation marks, leaving us with 3,500 comments. we then used the hate-bert from @xcite , further fine-tuned on the kaggle dataset (see below), to assign each rm comment a hate score (output of last gelu layer). we sorted the comments in descending order and took the top 1,000 as the positive class of the rm dataset. the roastme dataset also contains a negative class to keep the train and test balanced after augmentation. we sampled 3,500 non-offensive reddit comments from the @xcite dataset (see below), ranked them using the same bert model, and took the 1,000 least hateful. for the cross-domain experiment, we used the following five datasets, also used in @xcite , plus the dataset of @xcite . the datasets were cleaned in the same manner as rm. the five datasets are imbalanced to different degrees. to control for the effect of dataset imbalance on the results of the cross-domain test, we downsampled the negative class to match the positive class. due to computational limitations, we also down-sampled the positive class in the larger sets. the kaggle dataset @xcite ) contains 312,737 wikipedia comments, 22,468 of them offensive, labeled with five hate-speech labels (e.g. toxic, abusive, etc). we treat a comment as hate speech (the positive class) if at least one of the five labels is true. we randomly sampled 5,000 comments from each class to form our kaggle dataset. the founta dataset @xcite ) contains 99,799 tweets, 27,037 labeled as abusive, 4,948 as hateful, 14,024 as spam and the rest (53,790) as normal. we sampled 5,000 offensive comments (labeled either abusive or hateful) and 5,000 benign ones. the data itself is available at @xcite . the razavi dataset (razavi et al., 2010b) contains 1,525 messages, 1,038 non-offensive and 482 "flame", that is offensive texts. we down-sampled the non-offensive class to match the size of the offensive class, giving a total of 964 comments. the data itself is available at @xcite . the waseem dataset @xcite ) contains 16,907 tweets, 1,970 labelled with racism, 3,379 with sexism and all the rest (11,559) nonoffensive. the online data @xcite ) contains only tweet ids and labels. we used twitter's api to recover the text of 795 offensive tweets (sexism and racism) and 3,699 nonoffensive tweets. we then down-sampled the nonoffensive class to match the size of the offensive class, giving us a total of 1590 tweets. the kumar dataset @xcite consists of 15,000 facebook posts and comments, out of them 3,419 tagged as overtly aggressive, 5,296 as covertly aggressive, and 6,285 as non-aggressive. we randomly sampled 5,000 aggressive (overtly and covertly), and 5,000 non-aggressive comments. the authors communicated the data privately after filling out an online application form. the offensive reddit dataset @xcite consists of 5,020 conversations in which offensive comments are tagged. we sampled 3,230 offensive comments. for the negative class, we sampled 3,230 comments from the political classification task @xcite and comments that we harvested from subreddits about fitness and food. ## evaluation we evaluated the quality of our pipeline by augmenting the six hate/abusive speech datasets described in section 4. due to limited computational resources (we had one g-force rtx 3090 gpu), we could not train bert on the entire dataset. therefore we broke the large datasets into four random parts (each includes about 1500-2000 comments). the figures appearing in the table are the average over these four-folds. in each fold, we used 80% of the data for training and 20% for validation. in the two small datasets, waseem and razavi, we used the entire dataset, repeating four times train (80%) and validation (20%), each time on a randomly sampled 80% of the dataset. experiment 2 is identical to experiment 1, but this time the starting point is the basic pre-trained hatebert model from @xcite finetuned with each of the datasets. the results of experiment 2 are in we also tested the in-domain prediction task in both experiments using 4-fold cross-validation. the results are the diagonal of tables 1 and 2 . experiments 3 and 4 are identical to 1 and 2, respectively. the only difference is that now all datasets d i and d j were imbalanced to a 30-70 ratio (30% hate speech) to facilitate a more realistic scenario where the positive class is in the minority. for lack of space, we only give the summary of the results, all differences in tables 1,2 between f1 scores after and before augmentation, except one case (in experiment 4), were verified using a paired t-test and came out significant. ## discussion in this work we have shown that invited abusive speech, which is written humorously, is useful for data augmentation. our work suggests that humans can produce actual hate speech even without the appropriate psychological conditioning of the brain (such as anger, hate, antagonism, etc). this may hint at some universal properties of hate speech that do not depend entirely on certain emotional states of the mind. we leave this last thought as a gate to further multidisciplinary psycholinguistic research, which may shed more light on the phenomenon of hate speech and how to identify it better using automatic tools. in trying to get a deeper insight into how exactly did rm help in the cross-domain test, we identified two meta-classes of datasets: randomly sampled datasets with boosting of abusive comments (for example @xcite and datasets that were selected by topics or key words that were assumed to be assoicated with hate and offensive speech @xcite . we found that the first group was characterized more by a direct and clear offensive style, while the second group was by a more indirect and fuzzier offensive style. the highest rate of improvement due to rm augmentation was when we trained on a dataset from the second group and tested on a dataset from the first group (improving both in false positive rate and false negative). for example, training on kumar and testing on kaggle, we observed an improvement of 25% following rm augmentation. we surmise that the improvement is because rm contains, by its nature, clear and direct offensive comments that complement that missing part in the original dataset. when trained and tested on datasets from the first group, rm mainly contributed to reducing fn-rate, perhaps because it "bridged" the gap between two distributions with its rich and diverse content. finally, another angle that our work did not attend to is that of unintended biases @xcite . if one agrees that unintended biases impair generalizability, then our cross-domain improvement results put forth the premise that augmenting with roastme decreased such biases. this point deserves separate in-depth exploration.