Challenges in Detoxifying Language Models

Johannes Welbl, Amelia Glaese, Jonathan Uesato, Sumanth Dathathri, John Mellor, Lisa Anne Hendricks, Kirsty Anderson, Pushmeet Kohli, Ben Coppin, Po-Sen Huang

Abstract: Large Language Models (LLMs) often generate toxic content, necessitating detoxification strategies. However, current automated methods, such as training data filtering and test-time steering, frequently rely on biased classifiers. This paper investigates the trade-offs of these methods, demonstrating that aggressive detoxification significantly increases false-positive rates for marginalized identity terms and degrades model performance on text related to protected groups and non-standard dialects.

Introduction

As Large Language Models (LLMs) scale in capability, they also become increasingly prone to generating harmful content, including hate speech and profanity. To mitigate these risks, researchers typically employ automatic toxicity classifiers, such as Jigsaw’s Perspective API, to filter training data or steer model outputs. While these tools effectively lower toxicity scores, they act as a "double-edged sword." This research, presented at EMNLP 2021, explores how automated detoxification introduces significant social biases and degrades the model's ability to represent marginalized communities.

The Detoxification Dilemma

The core issue lies in "identity bias" within the classifiers themselves. These tools often flag neutral or positive sentences containing identity terms (e.g., "gay," "Muslim") as toxic. When these biased metrics are used to "fix" LLMs, they risk amplifying social prejudices and reducing the linguistic coverage of the very groups they are meant to protect.

Figure 1: Examples of toxicity mitigation showing how benign mentions of identity can be falsely flagged as toxic compared to actual harmful content.

Methodology

The researchers evaluated three primary detoxification strategies on a 1.4-billion parameter TransformerXL model:

  1. Training Set Filtering: Removing documents with high toxicity scores from the C4 training dataset.
  2. Decoder/Test-Time Filtering: Generating multiple candidate sentences and selecting the one with the lowest toxicity score using a secondary BERT-based classifier.
  3. Plug-and-Play Language Models (PPLM): Steering the LLM’s internal states away from toxic directions during generation using a small attribute classifier.

Performance was measured against human evaluation, where 49 annotators rated toxicity, grammaticality, and style, alongside standard benchmarks like REALTOXICITYPROMPTS (RTP), BOLD (for topic coverage), and TWITTERAAE (for dialect coverage).

Key Insights and Results

The False Positive Trap

Aggressive detoxification leads to a high rate of false positives. In the most heavily filtered models, over 30% of generations flagged as "toxic" were benign sentences containing identity terms. As models become "cleaner" by machine standards, the correlation between machine-assigned and human-assigned toxicity scores drops significantly.

The Loss Gap and Dialect Erasure

Detoxification increases the model's "loss" (a measure of prediction error), but this increase is not uniform. The model becomes disproportionately "less literate" regarding text about marginalized groups. Furthermore, because toxicity classifiers often misidentify African-American English (AAE) as toxic, detoxified models show a much larger performance drop on AAE text compared to standard English, effectively erasing cultural dialects from the model's functional vocabulary.

Figure 5: Loss gaps across gender, ethnicity, and demographic dialect, illustrating how detoxification disproportionately increases prediction error for marginalized groups.

Quality Trade-offs

While combining all three detoxification methods successfully reduced the probability of toxicity from 0.87 to 0.08, it came at a significant cost to general language quality. For instance, accuracy on the LAMBADA task dropped from 50.1% to 34.9% in the training-filtered model.

Conclusion

The study highlights that current detoxification methods are often a form of "metric gaming" that sacrifices linguistic diversity and equity for lower toxicity scores. The authors argue for a research shift toward more nuanced metrics that separate identity from toxicity. Future safety efforts must focus on monitoring "loss gaps" across demographic groups to ensure that making models safer does not come at the cost of making them exclusionary.

Summary updated

BibTeX
@inproceedings{welbl2021challenges,
  author = {Johannes Welbl and Amelia Glaese and Jonathan Uesato and Sumanth Dathathri and John Mellor and Lisa Anne Hendricks and Kirsty Anderson and Pushmeet Kohli and Ben Coppin and Po-Sen Huang},
  title = {{Challenges in Detoxifying Language Models}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2021},
  doi = {10.18653/v1/2021.findings-emnlp.210},
}
Figure