RealToxicityPrompts: Evaluating Neural Toxic Degeneration in Language Models

Samuel Gehman, Suchin Gururangan, Maarten Sap, Yejin Choi, Noah A. Smith

Introduction

Large language models (LMs) are trained on massive web-scraped datasets, which often contain significant amounts of toxic content. While it is well-known that these models can produce offensive output when explicitly prompted with hate speech, a more insidious problem exists: toxic degeneration. This refers to the tendency of a model to start with a neutral or non-toxic prompt and eventually "drift" into generating toxic content.

Examples of toxic degeneration where neutral prompts lead to offensive model generations.

This paper introduces REALTOXICITYPROMPTS, a systematic benchmark of 100,000 naturally occurring prompts designed to quantify this risk and evaluate the effectiveness of various detoxification strategies.

The REALTOXICITYPROMPTS Benchmark

The researchers developed a dataset of 100,000 sentence-level prompts derived from the OpenWebText Corpus. Each prompt is assigned a toxicity score using the Perspective API, covering a stratified range from safe to highly offensive.

Analysis of the underlying training data reveals that toxicity is "baked in" to the models from the start. Approximately 2.1% of OpenWebText and 4.3% of OpenAI-WT are classified as toxic. Even curated datasets like the Toronto Books Corpus contain significant toxicity (9.1%), suggesting that standard pretraining data provides a fertile ground for learning offensive patterns.

Methodology

The study evaluates five Transformer-based models: GPT-1, GPT-2, GPT-3 (Da Vinci), CTRL, and CTRL-WIKI. Two primary evaluation modes were used:

  1. Unprompted Evaluation: Measuring toxicity in generations starting from a blank slate (null prompt).
  2. Prompted Evaluation: Testing model responses to the REALTOXICITYPROMPTS dataset to see how prompt toxicity influences output.

To mitigate these risks, the authors tested several detoxification strategies, including Domain-Adaptive Pretraining (DAPT) on non-toxic data, Attribute Conditioning (ATCON), vocabulary shifting, Plug and Play Language Models (PPLM), and simple word filtering.

Key Results and Insights

The findings suggest that models do not require toxic prompts to produce offensive content. All five models had a ~50% probability of generating toxic text at least once within 25 generations, even when provided with non-toxic prompts.

Expected maximum toxicity increases as a function of the number of generations, showing that even "safe" models eventually produce toxic content.

As shown in the figure above, the expected maximum toxicity rises sharply with the number of generations. For example, GPT-2 reaches a toxicity score of 0.65 within just 100 generations from a blank slate. Even models trained on supposedly cleaner data, such as CTRL-WIKI (trained on Wikipedia), still exhibit toxic behavior, likely due to the broader web context learned during pretraining.

Among the detoxification methods, DAPT and PPLM proved most effective. DAPT reduced the probability of toxic generation from non-toxic prompts for GPT-2 from 48% to 23%. However, no method was entirely successful; a "challenging" subset of 1,225 prompts was identified that triggered toxic responses from every out-of-the-box model tested.

Discussion and Limitations

While this work provides a crucial framework for measuring toxic degeneration, it faces several limitations. The reliance on the Perspective API introduces potential classifier bias, particularly regarding dialects like African American English. Furthermore, the toxicity estimates for pretraining data are likely conservative lower bounds.

Future research is needed to determine if models can truly "unlearn" toxic patterns or if current detoxification methods merely act as a temporary "muzzle." Extending this analysis to masked language models and exploring more robust steering mechanisms remain vital steps toward safer AI deployment.

Summary updated

BibTeX
@inproceedings{gehman2020realtoxicityprompts,
  author = {Samuel Gehman and Suchin Gururangan and Maarten Sap and Yejin Choi and Noah A. Smith},
  title = {{RealToxicityPrompts: Evaluating Neural Toxic Degeneration in Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2020},
  doi = {10.18653/v1/2020.findings-emnlp.301},
}
Figure