ToxiGen: A Large-Scale Machine-Generated Dataset for Adversarial and Implicit Hate Speech Detection

Thomas Hartvigsen, Saadia Gabriel, Hamid Palangi, Maarten Sap, Dipankar Ray, Ece Kamar

Introduction

Automated hate speech detection is a critical component of online safety, yet current state-of-the-art classifiers remain remarkably brittle. These models frequently struggle with two primary challenges: spurious correlations and implicit toxicity. Spurious correlations occur when models learn to flag identity-related keywords (e.g., "Muslim" or "Black") as inherently toxic because those groups are disproportionately targeted in training data. This leads to high false-positive rates for benign statements. Conversely, implicit toxicity—hate speech that avoids slurs and profanity in favor of subtle stereotypes or microaggressions—often bypasses filters entirely.

To address these gaps, researchers developed ToxiGen, a massive dataset of 274,000 machine-generated statements designed to move hate speech detection beyond simple keyword matching.

Methodology: ALICE and Demonstration-Based Prompting

The researchers leveraged the capabilities of GPT-3 to generate a balanced, large-scale corpus using two main techniques. First, they employed demonstration-based prompting, providing the model with human-curated examples of both benign and toxic statements across 13 minority groups to steer generation toward high-quality, nuanced content.

Second, they introduced ALICE (Adversarial Language Imitation with Constrained Exemplars). ALICE is an adversarial "classifier-in-the-loop" decoding algorithm that pits a toxicity classifier against the generator during beam search. By rewarding the generator for producing text that "fools" the classifier—either by making toxic content appear benign (false negatives) or benign content appear toxic (false positives)—ALICE identifies the specific linguistic blind spots of current safety filters.

The ALICE decoding process, incorporating an adversary classifier to steer generation.

The ToxiGen Dataset

The resulting ToxiGen dataset contains 274,186 statements covering 13 minority identity groups. The dataset is uniquely characterized by its scale, balance, and high degree of implicitness. Notably, 98.2% of the statements contain no profanity or slurs, forcing models to analyze the sentiment and framing of a sentence rather than relying on a "naughty word" list.

Examples of benign and toxic statements generated with ALICE, illustrating how they can fool standard classifiers.

By ensuring that identity group mentions appear equally in benign and toxic contexts, ToxiGen helps break the spurious correlations that plague existing models. Human validation confirmed the reliability of this pipeline, with annotators verifying that 94.5% of the machine-generated toxic examples indeed constituted hate speech.

Results and Performance

Fine-tuning existing classifiers, such as HateBERT, on ToxiGen yielded significant performance gains. When tested on human-written implicit hate benchmarks (ImplicitHateCorpus, SocialBiasFrames, and DynaHate), models trained on ToxiGen showed improvements ranging from 7% to 19%.

The adversarial ALICE method proved particularly effective at exposing model weaknesses; ALICE-generated toxic statements fooled the HateBERT classifier 26.4% of the time, compared to 16.8% for standard generation. Furthermore, the machine-generated text was highly convincing; in human evaluations, 90% of the sentences were mistaken for human-written text, suggesting that AI-generated toxicity is now as subtle and varied as human speech.

Conclusion and Future Work

ToxiGen demonstrates that the inherent biases of Large Language Models can be repurposed as a powerful tool for safety research. By creating a "training gym" of adversarial and implicit examples, researchers can build more robust and fair classifiers. While the current dataset focuses on 13 groups within a U.S. socio-cultural context, future work aims to expand this to global contexts and intersectional identities. Additionally, the researchers acknowledge the dual-use risk of adversarial generation methods like ALICE, emphasizing the need for continued defensive innovation as LLMs evolve.

Summary updated

BibTeX
@inproceedings{hartvigsen2022toxigen,
  author = {Thomas Hartvigsen and Saadia Gabriel and Hamid Palangi and Maarten Sap and Dipankar Ray and Ece Kamar},
  title = {{ToxiGen: A Large-Scale Machine-Generated Dataset for Adversarial and Implicit Hate Speech Detection}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2022},
  doi = {10.18653/v1/2022.acl-long.234},
}
Figure