Challenges of language model detoxificationChallenges in Detoxifying Language Models
The authors evaluate detoxification methods such as training filtering, decoding filtering, and PPLM, and state that they can substantially reduce automatic toxicity scores, but amplify bias against marginalized groups and raise LM loss.
- Deploying language models requires reducing their probability of generating toxic text, but existing approaches mostly rely on automatic toxicity metrics such as Perspective API. The authors are concerned with whether these metrics are reliable, and whether detoxification harms language model quality and amplifies social bias.
- The authors train a 1.4B TransformerXL on C4 and compare training-set filtering, decoding-time filtering, PPLM, and their combinations; they also evaluate toxicity using RealToxicityPrompts automatic metrics and human annotation, and check quality and bias using loss, LAMBADA, BOLD, and TwitterAAE.
- The authors report that the combined method can push the RTP automatic toxicity metric close to 0, but [email protected] lowers LAMBADA accuracy from 50.1% to 34.9%; after strong interventions, high automatic scores diverge more from human judgments, and the loss gap is larger for female, ethnic minority, and AAE text.
- The authors point out that the definition of toxicity is subjective and context-dependent, that automatic metrics may no longer correspond to human toxicity after strong detoxification, and that a small loss gap does not mean low bias. The experiments cover only English LMs, one 1.4B model family, and specific datasets; the paper does not report confidence intervals for human annotations or repeated training.
- Evaluated models
- standard (C4)[email protected][email protected][email protected]
- Benchmarks
- RealToxicityPromptsC4WikiText-103LAMBADABOLDTwitterAAECivilComments
- Metrics
- Expected Maximum ToxicityProbability of Toxicityevaluation lossLAMBADA accuracyhuman toxicity scoreloss gap
After evaluating multiple language model toxicity mitigation strategies, researchers find that basic interventions, although effective at optimizing automatic toxicity metrics on the RealToxicityPrompts dataset, come at the cost of reducing model coverage of text involving marginalized groups and their dialects. The paper also analyzes the impact of toxicity mitigation on model bias and quality, and finds that after strong toxicity reduction interventions, human raters often do not agree with the higher automatic toxicity scores, on this basis criticizing the practice of relying on automatic toxicity evaluation to measure language model safety.
Paper analysis
What problem does this paper attempt to solve?
The authors study whether LM detoxification is misled by automatic toxicity metrics, and the side effects of detoxification on quality and coverage of marginalized groups.
Core question: how to evaluate and reduce the tendency of language models to generate toxic text, while avoiding being misled by automatic toxicity metrics and amplifying social bias.
- Problem setting: The authors point out that LMs in real-world deployment may generate hate speech, insults, profanity, and threats, so toxicity needs to be measured and reduced; existing work typically uses classifiers such as Perspective API for automatic evaluation.
- Shortcomings of existing methods: The authors argue that automatic toxicity classifiers themselves suffer from subjectivity, out-of-domain use, and identity-term bias; optimizing only these scores may not reflect toxicity as perceived by humans.
- Core observation: The authors state that simple detoxification methods can push automatic scores on RealToxicityPrompts very low, but after strong interventions, high automatic scores and human annotations are more often inconsistent.
- What the paper proposes: The paper systematically compares training-set filtering, decoding-time filtering, PPLM, and combinations, and simultaneously evaluates automatic toxicity, human toxicity, LM loss, text quality, topic coverage, and dialect coverage.
- Threat model: This is not an attack or defense paper; the paper does not posit an attacker. The victim system is a TransformerXL-based English LM, and the risk targets are the toxic text generated by the model and the damage to its ability to model text from marginalized groups.
What related research exists?
Related work covers LM toxicity evaluation, detoxification methods, toxicity classifier bias, and safety of generated text.
LM toxicity evaluation
- Wallace et al. (2019)—used synthetic prompts to trigger racist continuations from GPT-2.
- Gehman et al. (2020)—proposed RealToxicityPrompts, evaluated LM toxicity under non-synthetic prompts using Perspective API scores, and compared multiple mitigation methods; this paper adopts their metrics and discusses them critically.
Detoxification methods
- Gehman et al. (2020), Gururangan et al. (2020)—reduce toxicity by fine-tuning pretrained LMs.
- Dathathri et al. (2020), Krause et al. (2021)—guide generation with an external toxicity classifier; Schick et al. (2021)—use LM self-diagnosis for detoxification.
- Xu et al. (2021)—directly filter outputs at test time; the paper states that, like this paper, they find that detoxification may amplify social bias.
Toxicity classifier bias
- Dixon et al. (2018), Park et al. (2018)—found that text related to identity terms is easily misjudged as toxic.
- Sap et al. (2019a), Davidson et al. (2019)—found that classifiers perform differently across dialects, for example African-American English is assigned higher toxicity scores.
- Zhou et al. (2021)—discusses the challenges of automatic debiasing; this paper adopts their distinction between topic bias and dialect bias.
Other research on safety of generated text
- Xu et al. (2020)—studies safety in open-domain dialogue.
- Nogueira dos Santos et al. (2018), Laugier et al. (2021)—rewrite offensive text into non-offensive variants.
Baselines and benchmarks: The paper directly compares with the GPT-2 and GPT-2 + PPLM results reported by Gehman et al. (2020); the main benchmark is RealToxicityPrompts, and bias evaluation uses BOLD and TwitterAAE. The authors position this paper as extending the bias findings of Xu et al. (2021) to more models, demographic groups, and datasets, and measuring topic bias using Wikipedia metadata rather than keyword matching.
How does the paper address this problem?
The authors conduct combination experiments with three types of detoxification methods and cross-evaluate using automatic metrics, human annotation, loss, and bias datasets.
The overall approach is to train the same family of LMs, apply different detoxification interventions to them, and then simultaneously check automatic toxicity, human judgment, language modeling quality, and social bias. The core framework is built around the contrast between RealToxicityPrompts automatic evaluation and human annotation evaluation.
Models and training setup
- Base model: TransformerXL, 24 layers, 16 heads, dmodel = 2048, dff = 8192, 1.4B parameters, trained on C4; C4 validation set loss-per-token is 2.40.
- Training details: 32,000 SentencePiece subwords; 128 Google Cloud TPUv3 cores, Adam, batch size 256, 3 × 10^5 steps total, about 5 days.
- Sampling setup: All sampling uses nucleus sampling, top-p = 0.9.
Three types of detoxification interventions
- Training set filtering (train-filter@X): Filter C4 by Perspective API score, with thresholds 0.2, 0.1, 0.05; after filtering, 311M (85%), 209M (57%), and 78M (22%) documents remain, respectively.
- Decoding/test-time filtering (test-filter): Filter outputs with a separate BERT toxicity classifier to avoid sharing a source with the Perspective API evaluation; generate at most K = 4 samples, stop when a continuation with BERT score below τreject = 0.01 is found, otherwise return the one with the lowest score.
- PPLM: Train a linear toxicity discriminator on the base LM hidden representations, guiding generation to simultaneously reduce predicted toxicity and the KL divergence from the original LM; this discriminator has test F1 of 0.78, hyperparameters in Table 5.
Automatic toxicity evaluation
- Benchmark and task: RealToxicityPrompts contains 100K English web prompts, divided into toxic and non-toxic; evaluate 20-token continuations, and also do an unprompted setting.
- Metrics: Expected Maximum Toxicity is the average of the maximum Perspective API score among 25 continuations; Probability of Toxicity is the frequency with which at least one of 25 continuations has a score > 0.5.
- Protocol correction: The authors point out that 20 tokens may provide insufficient context and that hard truncation can produce partial words; Appendix Table 6 switches to at most 100 tokens and truncates to the last sentence, yielding similar conclusions.
Human annotation and bias evaluation
- Human toxicity: Prepare 300 RTP samples for each setting, with each sample rated by at least 3 of 49 annotators; labels are mapped as NOT TOXIC = 0.0, TOXIC and VERY TOXIC = 1.0, NOT SURE is discarded, and weighting is by upsampling.
- Quality annotation: Annotators also evaluate whether continuations are grammatical, comprehensible, consistent, with labels YES, SOMEWHAT, NO.
- Bias evaluation: Use the gender and ethnicity domains of BOLD to evaluate topic coverage, and the AAE and WAE subsets of TwitterAAE to evaluate dialect coverage; the main comparison is the loss gap of detoxified models relative to the standard LM.
What experiments did the paper conduct?
Experiments show that combined detoxification can lower automatic scores, but human disagreement, LM loss, and the loss gap between groups rise simultaneously.
Experimental setup
- Models tested: standard 1.4B, [email protected], [email protected], [email protected], standard 417M; Table 1 also lists GPT-2 and GPT-2 + PPLM from Gehman et al. (2020) as existing results.
- Datasets: RealToxicityPrompts 100K prompts and 100K unprompted sentences; PPLM uses only 10K prompted and 10K unprompted continuations due to computational budget.
- Baselines: standard (C4); the GPT-2 and GPT-2 + PPLM numbers in Table 1 are taken from Gehman et al. (2020).
- Metrics: Expected Maximum Toxicity, Probability of Toxicity, evaluation loss, LAMBADA accuracy, average human toxicity score, BOLD/TwitterAAE loss gap.
- Evaluation method: Automatic scores come from Perspective API; test-filter uses a BERT fine-tuned on CivilComments with 96.8% validation accuracy; human annotation has at least 3 people per sample.
- Sample sizes: 300 samples per setting for RTP human evaluation; 100 samples per model × dialect setting for TwitterAAE human evaluation; the paper does not report the number of repeated training runs.
Main results
According to Table 1, Probability of Toxicity is as follows; full values for Expected Maximum Toxicity are in the original table.
Swipe horizontally to read the table
Method Unprompted Toxic Non-Toxic GPT-2† 0.33 0.88 0.48 GPT-2 + PPLM† 0.05 0.49 0.17 standard (C4) 0.16 0.87 0.44 [email protected] 0.04 0.41 0.17 standard + test-filter 0.01 0.31 0.05 [email protected] + test-filter 0.01 0.08 0.01 PPLM + [email protected] + test-filter 0.00 0.08 0.01 - Authors' interpretation: The authors state that the three methods and their combinations can effectively optimize automatic toxicity metrics, and that the combined method yields the largest reduction.
- Relative to existing results: The authors state that relative to the previous best results reported by Gehman et al. (2020), the toxic prompt and non-toxic prompt settings are reduced by 6× and 17×, respectively, and the unprompted setting drops from 0.05 to 0.00.
- Caveats: The PPLM row uses 10K samples, while other rows use 100K samples; † rows are numbers taken from Gehman et al. (2020).
Relationship between human evaluation and automatic scores
- Overall agreement: Figure 2 shows that the average human toxicity score of each method is broadly monotonically related to the average Perspective API score; the authors take this to mean that detoxification methods also reduce toxicity under human judgment.
- Annotation agreement: Krippendorff's alpha is 0.49 for the standard LM and 0.48 across all LM annotations; the authors call this fair overall agreement and note it is close to the levels of Ross et al. (2016) and Wulczyn et al. (2017).
- False positives after strong interventions: Figure 4, for samples with Perspective API score > 0.75, shows that the stronger the intervention or the more combinations, the lower the average human score relative to the automatic score; the authors state that after strong detoxification, most samples predicted as potentially toxic are false positives.
LM quality and detection ability
- Training filtering raises loss: According to Table 2, standard 1.4B has a C4 loss of 2.37, and [email protected] has 2.66; the authors state that stronger filtering brings larger negative effects.
- LAMBADA drop: According to Table 7, accuracy drops from 50.1% for standard 1.4B to 34.9% for [email protected]; standard 417M is 41.9%.
- Small differences in text quality: According to Table 10, different interventions differ from the standard LM by no more than 1%, 4%, and 1% on comprehensible, consistent, and grammatical, respectively.
- Toxicity detection ability: The F1 of the PPLM toxicity classifier trained on [email protected] representations drops from 0.78 to 0.73; the authors believe this may affect self-debiasing strategies.
Amplification of social bias
- Topic coverage: Figure 5a/5b shows that training filtering raises loss on all BOLD subsets, but the loss gap is larger for female actors and marginalized ethnic text; the standard LM's loss for female and male actors is 3.414 and 3.412, respectively.
- Dialect coverage: Figure 5c shows that the loss gap for AAE is larger than for WAE; the standard LM's loss on AAE versus WAE is already 5.53 versus 4.77, and the authors state that detoxification further amplifies this gap.
- Uneven detoxification effects across dialects: According to Table 3, after [email protected] the Probability of Toxicity is 0.22 for AAE prompts and 0.14 for WAE; Table 4's average human toxicity scores are 0.02±0.03 for AAE and 0.04±0.04 for WAE, and the authors state that under human evaluation the toxicity levels of the two dialects are similar.
Other ablations and analyses
- Longer continuations: Table 6 uses up to 100 tokens and truncates at complete sentences; the automatic evaluation conclusions are similar to Table 1.
- Correlation bucketing: Table 9 shows that for [email protected] in the Perspective API 0.75–1 range, the Spearman correlation is 0.13 for toxic prompts and -0.33 for non-toxic prompts.
- Identity-term false positives: Among samples generated by [email protected] with score > 0.5, 30.2% mention gay; the corresponding proportion for the standard LM is 4.1% (Appendix G.1).
- Authors' spot check: One author checked 50 random continuations and judged 32% to be false positives, 34% unclear, and 34% toxic (Appendix G.1, n=50).
- Limits of likelihood metrics: Observation 1 gives an upper bound on the loss-per-token increase of test-time filtering; Table 11 shows that the loss gaps across Best-of-K groups are 0.09–0.13, and the authors state that a small loss gap cannot indicate low bias.
What are some points that can be further explored?
The authors explicitly list challenges including the definition of toxicity, the validity of automatic metrics, the burden of human annotation, and the side effect of bias.
Limitations and future directions noted by the authors
- Toxicity definitions are subjective and context-dependent: §3 and §9 point out that toxicity judgments depend on the annotator, cultural background, and inferred context; the authors believe future work needs to continue developing definitions and clarify how to apply them fairly across contexts.
- Toxicity covers only one kind of LM harm: §3 points out that other harms such as stereotyping and statistical bias are outside the scope of this paper.
- Results should not be over-generalized: §3 recommends caution in generalizing the absolute and relative effectiveness of specific techniques; §10 also points out that this paper considers only English LMs and recommends caution in extending to non-English LMs.
- Further optimizing automatic scores may not be beneficial: §9 points out that after strong interventions automatic metrics are already very low, and it is unclear whether further optimization would reduce toxicity under human judgment or only exacerbate side effects.
- Human annotation is burdensome and the protocol is ambiguous: §9 points out that collecting human ratings may cause negative psychological effects on annotators; Appendix E.3 lists ambiguities such as insufficient context, sarcasm, and quoting toxic text.
- Loss gap is an imperfect metric: §8.3 and §9 point out that a large loss gap can indicate high bias, but a small loss gap does not automatically mean low bias; the authors believe future work should develop better metrics for quantifying LM bias.
Scope of experimental coverage
- Models tested: The authors train and evaluate standard 1.4B, three train-filter variants, and standard 417M themselves; the GPT-2 and GPT-2 + PPLM numbers are taken from Gehman et al. (2020).
- Intervention coverage: The experiments cover training-set filtering, test-time filtering, PPLM, and their combinations; other detoxification methods are not included in the experiments.
- Evaluation coverage: Automatic evaluation uses RealToxicityPrompts; quality evaluation uses C4, WikiText-103, and LAMBADA; bias evaluation uses the gender/ethnicity domains of BOLD and the AAE/WAE subsets of TwitterAAE.
- Human evaluation scale: 300 samples per setting for RTP and 100 samples per setting for TwitterAAE; each sample has at least 3 annotators, and the paper does not report variance from repeated training or across random seeds.
- Language and group scope: The paper evaluates only English LMs; the bias experiments cover the gender, ethnicity, and dialect groups listed in the paper, and the authors hope future work will consider more unobserved and flexible categories.
Summarize the main content of the paper
The paper systematically evaluates LM detoxification; the authors state that automatic scores can be pushed down, but at costs to quality, human agreement, and bias.
This is an analysis paper on toxicity evaluation and mitigation for English language models; its focus is not on proposing new attacks, but on examining the costs of existing automatic metrics and simple detoxification methods.
- Problem: The authors argue that deploying LMs requires reducing toxic generation, but automatic toxicity scores such as Perspective API suffer from subjectivity, out-of-domain use, and identity-term bias, and relying on them alone may mislead conclusions.
- Method: The authors train a 1.4B TransformerXL on C4, compare training-set filtering, BERT decoding filtering, PPLM, and combinations, and cross-evaluate using RealToxicityPrompts automatic metrics, human annotation, loss, LAMBADA, BOLD, and TwitterAAE.
- Automatic metric results: According to Table 1, [email protected] + test-filter + PPLM has a Probability of Toxicity of 0.00 in the unprompted setting, and 0.08 and 0.01 on toxic and non-toxic prompts, respectively.
- Human evaluation results: The authors report that detoxification methods also reduce average toxicity under human judgment, but after strong interventions, samples with high Perspective API scores are more often judged by humans as false positives; the annotation agreement Krippendorff's alpha for the standard LM is 0.49.
- Quality and bias costs: [email protected] raises C4 loss from 2.37 to 2.66 and lowers LAMBADA accuracy from 50.1% to 34.9%; on BOLD and TwitterAAE, the loss gap is larger for female, ethnic minority, and AAE text.
- Authors' conclusion: The authors state that simple methods can effectively optimize automatic toxicity metrics, but this optimization comes with degraded LM quality and amplified social bias; future work needs toxicity definitions closer to human perception, better bias metrics, and cautious interpretation of automatic scores and loss gaps.
Related papers
- Unintended Harms of Value-Aligned LLMs: Psychological and Empirical InsightsAnalysis / interpretabilityACL 2025