An Exploration of Zero-Shot Natural Language Inference-Based Hate Speech Detection (2023)

Abstract: Conventional techniques for detecting online hate speech rely on the availability of a sufficient number of annotated instances, which can be costly and time consuming. For this reason, zero-shot or few-shot detection can offer an attractive alternative. In this paper, we explore a zero-shot detection approach based on natural language inference (NLI) models. Since the performance of the models in this approach depends heavily on the choice of a hypothesis, our goal is to determine which factors affect the quality of detection. We conducted a set of experiments with three NLI models and four hate speech datasets. We demonstrate that a zero-shot NLI-based approach is competitive with approaches that require supervised learning, yet they are highly sensitive to the choice of hypothesis. In addition, our experiments indicate that the results for a set of hypotheses on different model-data pairs are positively correlated, and that the correlation is higher for different datasets when using the same model than it is for different models when using the same dataset. These results suggest that if we find a hypothesis that works well for a specific model and domain or for a specific type of hate speech, we can use that hypothesis with the same model also within a different domain. While, another model might require different suitable hypotheses in order to demonstrate high performance.

## introduction the growing use of social media platforms that allow users to remain anonymous during online discussions has led to an increase in the amount of hateful content online. this has posed a challenge in detecting hate speech for government organizations, social media platforms, and the research community. effective hate speech detection models that are robust and reliable can provide valuable insights to moderators in their efforts to combat the prevalence of hate speech in online discussions, as well as encourage productive online discourse @xcite . in this paper, we use the term hate speech as an umbrella term for different types of insulting content, such as offensive language, abusive language, and other types of harmful content. since supervised learning methods are associated with difficulties such as the need for large computing power and extensive amounts of labeled data, zero-shot learning using pre-trained language models can be an attractive alternative. zero-shot detection is a technique that allows a model to classify texts based on their content, even if the model has not been trained for that particular task @xcite . the main advantage of the zero-shot approach is its versatility. a model pre-trained on general data can be used to detect hate speech across multiple platforms @xcite and domains (different targets and types of hate speech) without having to retrain it. this reduces training costs and allows for greater flexibility in responding to changes in social media platforms, user behavior, and types of hate speech. however, since the model is not specifically trained for the task of detecting hate speech, the approach might demonstrate inferior results to the supervised models. in this paper, we investigate whether an nli-based zero-shot approach is competitive to supervised learning methods and explore its robustness for different models, datasets and targets of hate speech. zero-shot in hate speech detection. ke-li et al. (2021) used gpt-3 @xcite to identify sexist and racist text passages with zero-shot, one-shot, and few-shot learning. they achieved an accuracy as high as 85% for few-shot learning and assumed that large language models with further development could eventually be used to detect hate speech. @xcite demonstrated that text classification tasks can be approached as natural language inference (nli), resulting in high accuracy for zero-shot classification. based on @xcite , goldzycher and schneider (2022) developed strategies that aim at improving nli-based zero-shot hate speech detection systems and showed that such approaches are able to outperform fine-tuned language models (acc. 79.4 for nli zero-shot for the best performing hypothesis against acc. 76.6 for a fine-tuned model). however, nli approaches require a hypothesis -a statement that is evaluated for its logical relationship with the target sentence. the performance of such approaches largely depends on the chosen hypothesis, and evaluation of the quality of each hypothesis may not be feasible. another uncertainty lies in the formulation of supporting hypotheses. an inadequately formulated supporting hypothesis can have a detrimental impact on the model performance @xcite . our goal is to evaluate an nli-based approach for various models and datasets, in order i) to find out how the choice of a hypothesis affects the quality of the model, ii) to find out how the results change for a given hypothesis when the model or domain is changed, and iii) to determine which factors affect the accuracy of nli-based zero-shot classification. ## method and models in order to determine whether an input text contains hate speech, we need a hypothesis that expresses that claim. in nli tasks, the hypothesis is a statement (e.g., "this text is racist") that needs to be either supported or contradicted by a given premise. it is typically formulated as a sentence that makes a claim or draws a conclusion based on the information presented in the premise. all experiments were conducted in a standard setup for nli-based zero-shot classification. we feed the hypothesis with an example to a pretrained nli model and get the probability of entailment for the target sentence and hypothesis. we ignore the logits for neutral and perform a softmax over the logits of contradiction and entailment. we use the coarse-grained (binary) hate speech classes: hate speech versus non-hate speech. if the probability for entailment is equal or higher than 0.5 we consider that it is hate speech. we report the results in terms of f1-score (macro-averaged). we conduct our experiments using the following well-established models, which are available via the huggingface transformers library @xcite ): ## datasets we evaluated the models described in section 3 on four datasets constructed from different online platforms, covering different topics, types and targets of hate speech. we used the binary hate speech classes: hate speech versus non-hate speech. the statistics of the datasets used are shown in frenk @xcite . the frenk dataset includes comments from facebook on lgbt and migrants topics in english. the dataset was manually annotated for fine-grained types of socially unacceptable discourse (e.g., violence, offensiveness, threat). messages were assigned to a particular class if at least four out of eight annotators agreed on the class. the test set consists of 2,095 examples. hatecheck @xcite ) is an english, synthetic, evaluation-only dataset annotated for binary hate speech classification. for generating the test set, templates were prepared that contained one blank space to be filled with a discriminated group: women, gay people, transgender people, black people, muslims, immigrants, and disabled people. the templates for non-hateful content share linguistic features with hateful expressions and could be mistaken for hate speech by a classifier. in total, the dataset consists of 3,728 examples. cad @xcite . the contextual abuse dataset (cad) consists of 25,000 annotated reddit entries. all entries were first independently annotated by two annotators. annotators worked through entire reddit conversations, making annotations for each entry with full knowledge of the previous content in the thread. the test set consists of 5,307 examples. olid @xcite . the offensive language identification dataset (olid) consists of 14,100 tweets in english, annotated through crowdsourcing. during annotation, each example was initially labeled by two annotators. in the case of disagreement, a third annotation was requested, and then a majority vote was taken. the test set consists of 860 entries. ## experiments and results in this section, we present the key findings and analysis derived from our research. we first report performance of the models on a general set of hypotheses. then we reduce the number of hypotheses and use only those that describe a certain type or target of hate speech. ## conclusion and future work the first set of experiments showed that despite the fact that an nli-based approach can compete with supervised methods, this approach is sensitive to the choice of hypothesis and even limited paraphrasing can change f1-scores substantially. our experiments indicate that the results using particular (sets of) hypotheses for different modeldata pairs are positively correlated, and that correlation for a particular model and different datasets is higher than the correlation for a dataset and different models. this suggests that if we find a hypothesis that works well for a specific model and dataset or a specific type of hate speech, we can use the same hypothesis for the same model but a different dataset. however, if the model is changed, it is better to search for an alternative hypothesis. in future work, we plan to experiment with automatic hypothesis engineering. we want to answer the following questions: can we automatically find a better hypothesis than the initial one and will the hypothesis optimized for one data-model pair work well for other models, other domains and other data-model pairs.