Measuring and Mitigating Toxicity in Large Language Models: A Comprehensive Replication Study
Mokshit Surana, Archit Rathod, Akshaj Kurra Satishkumar · 2026
Read Measuring and Mitigating Toxicity in Large Language Models: A Comprehensive Replication Study by Mokshit Surana, Archit Rathod, Akshaj Kurra Satishkumar (2026) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2605-14087.txt.
Introduction
Surana, Rathod and Satishkumar replicate and measure toxicity mitigation in large language models. Web-trained models soak up toxic patterns, so even harmless prompts can trigger harmful outputs, a risk for real deployments. The study tests DExperts, a decoding-time method that steers generation without retraining the model. Work runs in three systematic phases, starting with baseline toxicity scores from RealToxicityPrompts on standard GPT-2 models, then testing DExperts against explicit toxicity.
Catalog record
| CREATOR | Mokshit Surana, Archit Rathod, Akshaj Kurra Satishkumar |
|---|---|
| YEAR | 2026 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 46619 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2605.14087
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Measuring and Mitigating Toxicity in Large Language Models: A Comprehensive Replication Study Mokshit Surana, Archit Rathod, Akshaj Kurra Satishkumar Abstract . Large Language Models (LLMs), when trained on web-scale corpora, inherently absorb toxic patterns from their training data. This leads to “toxic degeneration” where even innocuous prompts can trigger harmful outputs. This phenomenon poses significant risks for real-world deployments. Thus, necessitating effective mitigation strategies that should maintain model utility while ensuring safety. In this comprehensive replication study, we evaluate the efficacy of DExperts (Decoding-time Experts), which is an inference-time mitigation technique that steers generation without requiring model retraining. We structured our research into three systematic phases: (1) establishing baseline toxicity measurements using RealToxicityPrompts on standard GPT-2 models; then (2) implementing and evaluating DExperts to mitigate explicit toxicity; and finally (3) stress-testing the method against implicit hate speech using the adversarial ToxiGen dataset. Our empirical results confirm that while DExperts achieves near-perfect safety rates (100%) on explicit toxicity benchmarks, it exhibits brittleness against adversarial, implicit hate speech, with safety rates dropping to 98.5%. Furthermore, we quantify a critical trade-off. The method introduces a ∼ \sim 10x latency penalty (from 0.2s to 2.0s per generation), posing challenges for real-time deployment scenarios. This study contributes to the growing body of work on AI safety by highlighting the robustness gap between explicit and implicit toxicity mitigation. We emphasize the need for more sophisticated approaches that generalize across diverse hate speech patterns without prohibitive computational costs. Declaration of AI Usage: No AI tools were used in the generation of this report. 1. Introduction 1.1. Motivation and Problem Statement Large Language Models (LLMs) such as GPT-2, GPT-3, and their successors have demonstrated remarkable capabilities in natural language understanding and generation tasks ( brown2020language ; radford2019language ) . These models, trained on vast datasets scraped from the internet, exhibit unprecedented fluency and coherence across diverse domains. However, this same web-scale training paradigm introduces a critical vulnerability. The models absorb and reproduce the biases, hate speech, stereotypes, and toxic patterns prevalent in their training corpora ( gehman2020realtoxicityprompts ; bender2021dangers ) . This phenomenon, termed toxic degeneration , manifests when models generate harmful content even from seemingly innocuous or neutral prompts. Recent research has demonstrated that this problem extends beyond explicit toxicity to more sophisticated forms. Zeng et al. ( zeng2025metaphorical ) showed that even state-of-the-art models like GPT-4o frequently misinterpret metaphorical implicit hate speech, where harmful stereotypes are disguised as seemingly innocuous expressions through rhetorical devices. For instance, a benign prompt such as “The men started to” might complete as “…fight and kill each other,” or worse, escalate to explicit hate speech targeting specific demographic groups. Such behaviors pose substantial risks for deploying LLMs in user-facing applications, including chatbots, content generation tools, and automated writing assistants. These applications, when exposed to toxic outputs, can cause real harm to users and communities. The challenge extends beyond mere detection. Traditional content moderation approaches, such as keyword-based filtering and blocklists, suffer from fundamental limitations: they are context-blind (e.g., blocking “kill” prevents discussing “killing cancer cells” in medical contexts), easily circumvented through lexical variations, and significantly reduce model utility by over-censoring legitimate content. More sophisticated approaches, involving model retraining or fine-tuning on curated datasets, incur prohibitive computational costs. This often requires millions of GPU hours and a substantial environmental impact, while still not guaranteeing safety against adversarial inputs ( liu2021dexperts ) . 1.2. Research Gap and Novelty While existing research has established that LLMs can generate toxic content ( gehman2020realtoxicityprompts ) and proposed various mitigation strategies ( liu2021dexperts ; welbl2021challenges ) , a critical gap persists in understanding how these mitigation techniques perform against diverse forms of toxicity. Specifically, most safety evaluations focus on explicit toxicity . We noticed overt slurs, threats, and profanity that are relatively straightforward to detect. However, real-world hate speech frequently manifests as implicit toxicity : subtle stereotypes, coded language, microaggressions, and statements framed as “polite” opinions that perpetuate harmful biases while evading simple detection mechanisms. Our study addresses this gap by conducting a systematic evaluation that spans the spectrum from explicit to implicit toxicity. Our novel contribution lies in the comprehensive stress-testing of DExperts against adversarially generated implicit hate speech, revealing fundamental robustness limitations not captured by standard benchmarks. We quantify the “robustness gap” as the performance degradation when transitioning from explicit to implicit toxicity detection and mitigation. 1.3. Research Questions Our investigation is guided by three primary research questions: (1) RQ1 (Baseline Measurement): To what extent does a standard, unmitigated pretrained LLM (GPT-2) generate toxic content from non-toxic prompts? What is the distribution and severity of toxic outputs? (2) RQ2 (Mitigation Efficacy and Trade-offs): Can inference-time control methods (specifically DExperts) significantly reduce toxicity without compromising generation quality? What are the computational costs associated with this mitigation? (3) RQ3 (Robustness and Generalization): Does the mitigation technique generalize effectively to implicit, adversarial hate speech? What is the robustness gap between explicit and implicit toxicity mitigation? 1.4. Contributions This work makes the following key contributions: • Comprehensive Baseline Analysis: We provide detailed quantitative analysis of baseline GPT-2 toxicity, revealing that approximately 4.2% of generations from non-toxic prompts fall into the “danger zone” (toxicity score > 0.5). • Mitigation Validation: We successfully replicate and validate the DExperts method, confirming 100% safety rates on standard RealToxicityPrompts benchmarks, representing a complete elimination of the baseline failure rate. • Robustness Gap Identification: We identify and quantify a significant robustness gap: while DExperts performs perfectly on explicit toxicity, safety rates drop to 98.5% on implicit, adversarial hate speech from ToxiGen, indicating brittleness in generalization. • Cost-Benefit Analysis: We provide detailed measurements of the computational overhead introduced by DExperts, documenting a 10x increase in inference latency (from 0.2s to 2.0s per generation), which has important implications for real-time deployment scenarios. • Methodology Framework: We establish a systematic three-phase evaluation framework (Baseline, Mitigation, Adversarial) that can serve as a template for future work in toxicity mitigation research. 2. Related Work and Literature Review 2.1. Toxicity in Language Models The problem of bias and toxicity in language models has been extensively documented in recent surveys. Gallegos et al. ( gallegos2024bias ) provide a comprehensive taxonomy of bias evaluation and mitigation techniques, categorizing approaches by intervention stage: pre-processing (modifying inputs), in-training (modifying optimization), intra-processing (modifying inference behavior), and post-processing (modifying outputs). This framework helps contextualize the various mitigation strategies we discuss in this section. The problem of toxic content generation in neural language models has been extensively documented. Gehman et al. ( gehman2020realtoxicityprompts ) introduced the RealToxicityPrompts dataset and demonstrated that even large-scale models like GPT-3 exhibit toxic degeneration, generating unsafe content with non-negligible probability even from seemingly innocuous prompts. Their work established the Expected Maximum Toxicity metric and showed that larger models do not necessarily generate less toxic content, challenging assumptions about scale improving safety. Bender et al. ( bender2021dangers ) provided a broader critique of large language models, documenting their tendency to perpetuate stereotypes and biases from training data. They highlighted environmental costs and the risks of deploying models trained on unfiltered internet text. Sheng et al. ( sheng2019woman ) demonstrated systematic gender bias in language generation, showing models tend to associate certain demographics with negative attributes. These foundational works establish the pervasiveness of the toxicity