[Paper Review] RealToxicityPrompts: Evaluating Neural Toxic Degeneration in Language Models
This paper introduces RealToxicityPrompts, a 100K-sample dataset of naturally occurring, sentence-level prompts derived from web text, each paired with PERSPECTIVE API toxicity scores. The study reveals that even non-toxic prompts can trigger highly toxic generations in pretrained language models like GPT-2, demonstrating persistent 'neural toxic degeneration.' While data- and compute-intensive methods (e.g., fine-tuning on non-toxic data) reduce but do not eliminate toxicity, the authors identify significant toxic content in pretraining corpora like OpenWebText and OpenAI WebText, underscoring the need for improved data curation in LM training.
Pretrained neural language models (LMs) are prone to generating racist, sexist, or otherwise toxic language which hinders their safe deployment. We investigate the extent to which pretrained LMs can be prompted to generate toxic language, and the effectiveness of controllable text generation algorithms at preventing such toxic degeneration. We create and release RealToxicityPrompts, a dataset of 100K naturally occurring, sentence-level prompts derived from a large corpus of English web text, paired with toxicity scores from a widely-used toxicity classifier. Using RealToxicityPrompts, we find that pretrained LMs can degenerate into toxic text even from seemingly innocuous prompts. We empirically assess several controllable generation methods, and find that while data- or compute-intensive methods (e.g., adaptive pretraining on non-toxic data) are more effective at steering away from toxicity than simpler solutions (e.g., banning "bad" words), no current method is failsafe against neural toxic degeneration. To pinpoint the potential cause of such persistent toxic degeneration, we analyze two web text corpora used to pretrain several LMs (including GPT-2; Radford et. al, 2019), and find a significant amount of offensive, factually unreliable, and otherwise toxic content. Our work provides a test bed for evaluating toxic generations by LMs and stresses the need for better data selection processes for pretraining.
Motivation & Objective
- To systematically evaluate the risk of toxic degeneration in pretrained language models.
- To identify whether seemingly non-toxic prompts can trigger highly toxic generations.
- To assess the effectiveness of controllable generation methods in preventing toxic outputs.
- To analyze the toxicity levels in major pretraining corpora like OpenWebText and OpenAI WebText.
- To highlight the urgent need for improved data selection and curation in language model pretraining.
Proposed method
- Constructed RealToxicityPrompts: 100K sentence-level prompts from English web text, manually selected to be non-toxic by PERSPECTIVE API.
- Assigned each prompt a toxicity score using the PERSPECTIVE API, labeling those with ≥0.5 as toxic.
- Evaluated multiple controllable generation methods (e.g., toxicity control tokens, swearword filters, fine-tuning on non-toxic data) on their ability to prevent toxic generations.
- Performed large-scale toxicity analysis on OpenWebText Corpus (OWTC) and OpenAI WebText (OPENAI-WT) using PERSPECTIVE API across multiple toxicity labels.
- Used Locality Sensitive Hashing (LSH) and Jaccard distance to estimate overlap between OWTC and OPENAI-WT.
- Analyzed subreddits and domains associated with toxic documents to trace provenance of offensive content.
Experimental results
Research questions
- RQ1Can pretrained language models generate highly toxic text even when prompted with non-toxic, naturally occurring sentence prefixes?
- RQ2How effective are various controllable generation techniques (e.g., filtering, fine-tuning) at preventing toxic degeneration?
- RQ3To what extent is toxic content present in widely used pretraining corpora such as OpenWebText and OpenAI WebText?
- RQ4Are banned or quarantined subreddits disproportionately represented in toxic web corpora used for LM pretraining?
- RQ5Does the presence of identity mentions or profanity in prompts correlate with increased likelihood of toxic generations in language models?
Key findings
- Even prompts labeled non-toxic by PERSPECTIVE API (TOXICITY < 0.5) triggered highly toxic generations in GPT-2 models, with 46% of generations from one prompt being classified as toxic.
- GPT-2 models showed a strong correlation between prompt toxicity and generation toxicity (r = 0.43, p < 0.001), and between prompt profanity and generated profanity (r = 0.169, p < 0.001).
- Minority identity mentions in prompts were more likely to be copied into generations than majority mentions (rmin. = 0.13 vs. rmaj. = 0.08, p < 0.001), indicating bias propagation.
- OpenWebText Corpus (OWTC) and OpenAI WebText (OPENAI-WT) contained substantial toxic content, with 5.5% of documents labeled as 'IDENTITY ATTACK' and 5.5% as 'THREAT' in OWTC.
- Banned or quarantined subreddits were significantly overrepresented in the toxic subset of OWTC, with 10% of toxic documents originating from such communities.
- Despite using advanced mitigation techniques, no method was failsafe—best-performing methods (e.g., fine-tuning on non-toxic data) still produced highly toxic generations under certain prompts.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.