Abstract
Standard evaluation of hate speech detection models using aggregate metrics often masks significant linguistic blind spots. We introduce HateCheck, a diagnostic suite of 29 functional tests designed to evaluate model performance across specific hateful and non-hateful contexts. Our evaluation of state-of-the-art models reveals systematic failures in handling reclaimed slurs, negation, and counter-speech, highlighting a reliance on keyword-based shortcuts rather than contextual understanding.
Introduction
The evaluation of Natural Language Processing (NLP) models for sensitive tasks like hate speech detection typically relies on measuring performance (e.g., F1 scores) on held-out test sets. However, this approach is fundamentally limited. Existing datasets often suffer from systematic biases, such as over-representing specific topics or reflecting annotator prejudices. Consequently, models may achieve high scores by learning "shortcuts"—simplistic rules like "label any sentence containing a specific group identifier as hate"—without genuinely understanding linguistic context. This leads to brittle models that are over-sensitive and fail to generalize to real-world scenarios.
Methodology: Functional Testing for Hate Speech
To address these limitations, we propose HateCheck, a framework inspired by software engineering's functional (or black-box) testing. Rather than inspecting internal model weights, HateCheck evaluates how models respond to specific linguistic "functionalities."
Functionality Selection and Test Generation
We identified 29 distinct model functionalities, grouped into 11 classes, through a literature review and interviews with 21 experts from NGOs specializing in online hate. These classes cover explicit derogation, threatening language, slur usage, profanity, and complex linguistic constructs like negation and phrasing.
The suite consists of 3,728 test cases, including both "hateful" examples and "contrastive non-hate" examples—sentences that appear similar to hate speech but lack hateful intent (e.g., "I love [IDENTITY]" vs. "I hate [IDENTITY]"). These cases were validated by 10 trained annotators, achieving a Fleiss’ Kappa of 0.93, indicating near-perfect agreement.
Evaluated Models
We tested four systems:
- Two BERT-base models fine-tuned on datasets from Davidson et al. (2017) and Founta et al. (2018).
- Perspective API (Google Jigsaw).
- SiftNinja (Two Hat).
Key Results and Insights
The results demonstrate a significant performance gap between hateful and non-hateful test cases across all models.
The "Keyword Trap" and Context Blindness
Models exhibit a heavy reliance on specific keywords, leading to high false-positive rates. For instance, BERT models frequently misclassify non-hateful sentences containing reclaimed slurs (e.g., "I'm the freshest ngga in the room"). Furthermore, models struggle with "contrastive non-hate," failing significantly on negated hate ("No [IDENTITY] deserves to die") and counter-speech* ("Statements like '[IDENTITY] are scum' are deeply hurtful"). BERT models were less than 50% accurate on 8 out of 11 non-hate functional tests.
Target Bias and Adversarial Vulnerability
Performance is not uniform across protected groups. One BERT model misclassified hate directed at women twice as often as hate directed at other groups, suggesting training data biases. Additionally, models are highly vulnerable to simple spelling variations. Techniques like "leet speak," adding extra spaces, or omitting characters (e.g., "I h a t e you") often bypass detection entirely.
Conclusion and Future Work
HateCheck reveals that even state-of-the-art models lack the nuance required for robust hate speech detection. While Perspective API was the strongest performer (76.6% total accuracy), it still struggled with reclaimed slurs and counter-speech.
Passage of HateCheck tests does not guarantee a model is flawless; rather, it indicates the absence of specific known weaknesses. Future work will focus on expanding HateCheck to other languages, addressing intersectional hate, and using these test cases for "inoculation" through data augmentation to improve model robustness.
Summary updated