The Role of Context in Detecting the Target of Hate Speech (2022)

Abstract: Online hate speech detection is an inherently challenging task that has recently received much attention from the natural language processing community. Despite a substantial increase in performance, considerable challenges remain and include encoding contextual information into automated hate speech detection systems. In this paper, we focus on detecting the target of hate speech in Dutch social media: whether a hateful Facebook comment is directed against migrants or not (i.e., against someone else). We manually annotate the relevant conversational context and investigate the effect of different aspects of context on performance when adding it to a Dutch transformer-based pre-trained language model, BERTje. We show that performance of the model can be significantly improved by integrating relevant contextual information.

## introduction hate speech detection models play an important role in online content moderation and promotion of healthy online debates @xcite . this has motivated a considerable interest in the task within a variety of disciplines, including social sciences and the natural language processing (nlp) community. recent advances in the field of nlp, which include the use of deep learning and ensemble architectures, have led to the development of automated hate speech detection approaches with an increased performance @xcite @xcite . however, the task remains challenging from multiple perspectives, e.g., the use of figurative language and crossdomain scalability, amongst others @xcite @xcite . these challenges constrain the performance and generalizability of hate speech detection models, and include the problem of integrating contextual information, that is, improving hate speech detection models by making them context aware @xcite @xcite . modeling contextual information is indisputably important for developing robust hate speech detection systems @xcite @xcite . for instance, the comment 'go back home' is clearly hate speech if it is posted under a news article about refugees and asylum seekers. however, previous work on detecting both the type and target of online hate speech has mostly focused on message content alone, without accounting for the context of the target comments @xcite . this is partially related to the lack of contextual information in the vast majority of datasets annotated for hate speech, which implies that hate speech detection models cannot exploit the conversational context when they are trained on existing datasets @xcite . more recent studies have specifically looked into the effect of context on hate speech detection. for instance, @xcite experimented with various strategies for integrating contextual information into bilstm and bert models, where context is limited to the preceding ('parent') comment in the wikipedia conversations dataset. the authors report that though context significantly affects annotation process by both amplifying or mitigating the perceived toxicity of posts, they found no evidence that adding context leads to a large or consistent improvement in performance of the examined models. @xcite highlighted similar challenges: while showing that context affects annotation process (fewer tweets were annotated as abusive when context was provided to annotators), they report that when experimenting with different models (bert, bilstm, svm) and a context window ranging from one to all preceding tweets, contextual information did not lead to a better classifier performance. @xcite introduced the contextual abuse dataset composed of reddit messages, where previous or several previous messages were considered as the context and "every annotation has a label for whether contextual information was needed to make the annotation". the authors report that 25-32% of content was labelled as context-dependent, and these messages are more challenging for detection, leaving integrating context for future work. in this paper, we address hate speech target detection in hateful dutch facebook comments: whether the target of hateful content is the social group of interest, that is, migrants or someone else (see section 2). while in previous work the preceding comment(s) in the discussion thread or the text of the post was used as context @xcite @xcite @xcite , we manually annotate the relevant context, that is, we look specifically at the part of the prior conversation that provides the context, and use that annotation to demonstrate its utility in hate speech target prediction by adding relevant contextual information to a dutch transformer-based pre-trained language model, bertje @xcite . hate speech is deeply contextual, and while most previous work ignores the conversational context, and more recent work, which looked into it based on previous comments or post, comes away concluding that such surface-level information is not helpful in prediction, this study shows and quantifies the impact that can be brought by relevant context on classifier performance when detecting the target of online hate speech. ## data we used the lilah dataset, as in @xcite . the dataset is composed of facebook posts by mainstream media outlets in dutch (i.e., news articles that were published by the media outlets and are (re-)published or shared as facebook posts) and readers' comments on these posts in a comment section, which were manually annotated by three trained annotators for fine-grained types and targets of hate speech (see below in this section) with a 'moderate' agreement. the annotations were performed in-context, that is, annotators first read entire comment threads and then labeled each comment. we randomly selected a subset of the dataset composed of 35 posts and around 6,000 comments discussing the migrants topic and annotated this data for context dependency: if context influences the annotators' decision to assign a label to a comment, that is, if assigning hatefulness to a comment depends on understanding its context, or if the target of hate speech is not sufficiently clear without the context, the annotator marked the target comment as context-sensitive and indicated the id of the post or the id of the previous comment (not necessarily directly preceding) in the discussion thread that serves as the corresponding context. for example, the comment 'i would have served pork steaks' (ik zou varkenslapjes geserveerd hebben) is hate speech directed against migrants if we take into account that the article is about a muslim woman who was served alcohol at a show and was upset since this was against her religion. in this case, the annotator would mark the comment as contextdependent and indicate the id of the post under which the comment was made. we merged the fine-grained types of hate speech present in the data (e.g., violence, offensiveness, threat) into a single hate speech category, removing comments that belong to the non-hate speech class, which is the commonly used set-up for the hate speech target detection task @xcite , and used the binary target classes within the hateful messages. that is, we distinguish between migrants as the target of hate speech and merge all other fine-grained target classes into the 'other' category in order to have a sufficient amount of training and test examples per class. in more detail, the 'other' category consists of hate speech directed against (1) the article's author or the media spreading the article; we used training and test partitions splitting the dataset by post boundaries in order to avoid withinpost bias, that is, all comments belonging to the same thread are in the same split. the splitting was done so that the distribution of 'migrants' and 'other' classes is as balanced as possible (roughly 40%-60%, respectively), while the proportion of 80% training and 20% test messages is preserved. the statistics of the dataset used in terms of the number of posts and comments in the training and test sets, as well as the percentage of contextdependent messages per class is provided in ## experiments and results we use the monolingual dutch transformer-based pre-trained language model, bertje @xcite , from the hugging face transformers library foot_0 , which showed near state-of-the-art results in previous work on dutch hate speech detection, e.g., @xcite . the model was pre-trained using the same architecture and parameters as the original 768-dimensional bert model @xcite on a dataset of 2.4 billion tokens. we set the maximum sequence length parameter to 512 in order to account for the context, the other parameters have default values, and fine-tune the model for a single epoch. following the approach proposed in @xcite , we concatenate the context and the text of the target comment separated by bertje's [sep] token, as in the next sentence prediction task in bertje's pre-training stage, and fine-tune the model on this data. we use only the content of the target comment as the baseline and examine the following ways for adding contextual information: (1) adding the text of the post on which the comment was made (comment & post); (2) adding the preceding comment (if any) in the discussion thread @xcite ; (3) adding the preceding comment and the post @xcite ; and (4) adding the relevant annotated context @xcite . since bertje is sensitive to random seeds, we report the results in terms of precision, recall and f1-score (macro) averaged over five runs, and standard deviations in the obtained results are in line with previous findings in the sense that adding the content of a preceding comment does not facilitate classifier performance @xcite @xcite . however, we observe a moderate improvement by adding the content of the post (2 f1 points) and a significant improvement (according to mcnemar's significance test @xcite with α < 0.05) caused by pointing at the actual context in the discussion thread (6 f1 points). the results partially reflect the annotation process, described in section 2, where most of the hateful messages contain the relevant context in the post text. to further examine the importance of contextual information, we conducted an additional experiment using only the relevant context (while discarding the content of the target message), obtaining the following results: @xmath0.60 (±0.009), @xmath1.60 (±0.007), @xmath2.60 (±0.009) (average over 5 runs). considering that the majority baseline @xmath3.32, @xmath4.50, and @xmath5.39, this experiment confirms that context contains useful information and can be used in isolation to predict the label of the target message. while for the 'migrants' class integrating the context lead to an improvement for the contextdependent messages (81% instead of 67% were identified correctly after adding the context), and no improvement was observed for the contextindependent messages (65% vs. 71% without the context), for the 'other' class, the main source of improvement is the context-independent messages (84% instead of 72% were identified correctly), while the number of correctly-identified contextdependent messages within this category dropped from 48% to 42%. zooming in on the fine-grained classes within the 'other' category, we note that the results are improved for all the classes, except for the hate speech directed towards article's author or media spreading the news, where only two more messages were misclassified after adding the contextual information. the confusion matrices for this experiment, presented in figure 1 , demonstrate that integrating the context improves the results both in terms of false positives and false negatives, providing additional evidence that context plays an important role in detecting the target of online hateful comments. ## conclusions despite recent advances, there are multiple challenges that remain and limit the development of ro-bust real-world hate speech detection systems. one of such challenges, addressed in this work, is to explicitly account for relevant conversational context when developing context-aware hate speech detection approaches. while prior work has shown that the easy-toobtain contextual information such as previous comment or post does not provide a large or consistent improvement, we demonstrated that if the model can zoom in on the relevant context, the performance increases significantly. a limitation of this work is that we use handlabeled contextual information, and thus report an upper bound of improvement in performance. nonetheless, we believe that this study is an important step towards developing more robust and context-aware automated hate speech detection approaches. given the great potential for encoding contextual information and its significant effect on detecting the target of hate speech presented in this work, the directions for future work include detecting relevant context for a target comment automatically and exploring its effect on performance, as well as investigating the impact of context on detecting fine-grained types and targets of online hate speech.