Respectful or Toxic? Using Zero-Shot Learning with Language Models to Detect Hate Speech (2023)

Abstract: Hate speech detection faces two significant challenges: 1) the limited availability of labeled data and 2) the high variability of hate speech across different contexts and languages. Prompting brings a ray of hope to these challenges. It allows injecting a model with task-specific knowledge without relying on labeled data. This paper explores zero-shot learning with prompting for hate speech detection. We investigate how well zero-shot learning can detect hate speech in 3 languages with limited labeled data. We experiment with various large language models and verbalizers on 8 benchmark datasets. Our findings highlight the impact of prompt selection on the results. They also suggest that prompting, specifically with recent large language models, can achieve performance comparable to and surpass fine-tuned models, making it a promising alternative for under-resourced languages. Our findings highlight the potential of prompting for hate speech detection and show how both the prompt and the model have a significant impact on achieving more accurate predictions in this task.

## introduction the rising prevalence of online hate speech and its harmful effects have made hate speech detection a central task in natural language processing (nlp). despite progress, the prevalent supervised learning approaches encounter significant challenges: many languages or contexts have little or no labeled data @xcite . hate speech is also subjective and context-dependent, as it is influenced by factors such as demographics, social norms, and cultural backgrounds @xcite . to overcome these challenges, approaches like zero-shot learning (zsl) and prompting of large language models (llms) have emerged. 1 both use a template to process the original text and the class labels as verbalizers. this approach leverages the llm's knowledge to predict the likelihood of the (class) verbalizers in the template. these verbalizers guide the model's understanding of a specific task. for binary hate speech detection, the template might be "<text>. this text @xmath0, @xmath1. for the input, "i hate you. this text is", the llm should associate a higher likelihood with the verbalizer completion "hateful". by picking the more likely completion, this approach requires no training data. it has shown promising results in various nlp applications @xcite @xcite .however, to date, its effectiveness for hate speech detection remains largely unexplored. we comprehensively evaluate zsl with prompting for hate speech detection to better understand its capabilities. the choice of appropriate verbalizers is a key factor in the effectiveness of prompting @xcite . to this end, we systematically compare various verbalizers across multiple models. we evaluate the performance of conventional transformer models and more recent instruction fine-tuned llms on 8 benchmark datasets to assess their robustness. furthermore, we test our approach on two languages with limited labeled data (italian and spanish). our results show that zsl with prompting matches or surpasses the performance of fine-tuned models, particularly in instruction fine-tuned models. contributions 1) we investigate the effectiveness of zsl with prompting for hate speech detection 2) we conduct a systematic exploration and comparison of various verbalizers across 5 models 3) we extend our investigation to two languages with limited labeled data. our code is publicly available at https://github.com/milanlproc/ prompting_hate_speech . ## datasets we compare our results on 8 benchmark datasets using binary classification. see ## prompting for zero-shot hate speech classification we use zsl with prompting to evaluate the models' ability to detect hate speech. first, we test various encoder models to select the best verbalizers. we then test those verbalizers on recent instruction fine-tuned llms and compare to encoder models. encoder-based language models for our experiments, we use the following prompt template: "<@xmath2. we then check the llm likelihood of hateful and nonhateful verbalizers and select the most probable completion as final prediction. we test all 25 possible pairs from the following lists. for hate: harmful, abusive, offensive, hateful, toxic, and for non-hate respectful, kind, polite, neutral, positive. we compare three different language models: bert @xcite , roberta @xcite , and deberta @xcite . we use openprompt @xcite , a standard framework for prompt learning over pre-trained language models. ## results on multi-lingual datasets we also investigated the effectiveness of zsl with prompting in a multilingual context, which is often more challenging due to the scarcity or unavailability of data. we present the outcomes achieved by multilingual models: multilingual xlm-r @xcite as encoder model and mt0 and flan-t5 as instruction fined-tuned models. the prompt has been written in english following the same templates presented in section 3 and using the best-performing verbalizer pair respectful-toxic. we use the experimental settings adopted in @xcite , comparing our method with their fine-tuned xlm-r model. thus, the dataset comprises english (en), spanish (es), and italian (it). the hateval (basile et al., 2019) shared task dataset on hate speech against immigrants and women on twitter is adopted for english and spanish. for italian, two different corpora proposed for evalita shared tasks @xcite are considered: the automatic misogyny identification challenge (ami) @xcite for hate speech towards women, and the hate speech detection shared task on facebook and twitter (haspeede) @xcite for hate speech towards immigrants. the results are shown in zsl models, as expected, did not outperform the fine-tuned xlm-r. however, the results obtained from the zsl models are still considered adequate. spanish, in particular, achieves comparable results with flan-t5 to the fine-tuned xlm-r. flan-t5 achieves better results in english because it is not affected by overfitting issues that arise during training @xcite . these findings suggest that prompting with instruction fine-tuned llms is a promising method for hate speech detection in both mono and multilingual settings, without language-specific fine-tuning. ## related work hate speech classification received increased attention in recent years. supervised learning methods are the most common @xcite . among these methods, fine-tuning transformer-based llms emerged as the dominant paradigm @xcite @xcite @xcite . however, they face significant challenges, like the limited availability of labeled data, especially in languages other than english @xcite , and the subjective nature of hate speech, which varies based on cultural background, personal experiences, and individual beliefs. llms have led to innovative techniques like prompting @xcite that use zero-shot and few-shot learning paradigms without needing labeled data. recent works have explored these new techniques for hate speech detection. @xcite use the prompts "is the following text sexist? answer yes or no" and "classify the following texts into racist, sexist, or neither" to detect hate speech, with gpt-3 showing that llms have a role to play in hate speech detection. @xcite explore toxicity in llms using comparable prompts to self-diagnose toxicity during the decoding. they use the realtoxicityprompts dataset @xcite . @xcite develop nli-based zero-shot hate speech detection approaches using prompts as a hypothesis as proposed by @xcite . their results outperform fine-tuned models. our work zsl for hate speech classification differs from previous approaches as follows. (1) we provide a comprehensive evaluation of zsl with prompting on multiple benchmark datasets, offering new insights into the effectiveness of this technique. (2) we explore the impact of the selection of verbalizers and models for the task, and (3) we compare the performance of encoder models with the recent llms based on instruction fine-tuning. ## conclusion this paper presents a comprehensive evaluation of zsl with prompting for hate speech classification. we have compared both encoder and instruction fine-tuned llms. our experiments across different benchmark data sets showed that zsl with prompting is a promising option to address the challenges presented in supervised learning systems. however, it also highlights the importance of carefully selecting the model and appropriate verbalizers, as they can significantly affect performance. our results also show that recent llms based on instruction fine-tuning play an essential role in hate speech detection. further exploration of prompt formulation could lead to their continued growth in this area. additionally, our multilingual experiments show that our proposed methods can be applied to other languages with comparable results. future research could investigate the bias presence @xcite and robustness @xcite of zsl prompting for hate speech detection models, also in multilingual settings.