Detoxification for LLM: From Dataset Itself
Not on the map. Why?
Abstract (arXiv)
Existing detoxification methods for large language models mainly focus on post-training stage or inference time, while few tackle the source of toxicity, namely, the dataset itself. Such training-based or controllable decoding approaches cannot completely suppress the model's inherent toxicity, whereas detoxifying the pretraining dataset can fundamentally reduce the toxicity that the model learns during training. Hence, we attempt to detoxify directly on raw corpora with SoCD (Soft Contrastive Decoding), which guides an LLM to localize and rewrite toxic spans in raw data while preserving semantics, in our proposed HSPD (Hierarchical Semantic-Preserving Detoxification) pipeline, yielding a detoxified corpus that can drop-in replace the original for fine-tuning or other training. On GPT2-XL, HSPD attains state-of-the-art detoxification, reducing Toxicity Probability (TP) from 0.42 to 0.18 and Expected Maximum Toxicity (EMT) from 0.43 to 0.20. We further validate consistent best-in-class results on LLaMA2-7B, OPT-6.7B, and Falcon-7B. These findings show that semantics-preserving, corpus-level rewriting with HSPD effectively suppresses downstream toxicity while retaining data utility and allowing seamless source-level mitigation, thereby reducing the cost of later model behavior adjustment. (Code is available at: https://github.com/ntsw2001/data_detox_for_llm)
Key facts. No citing papers in the map yet (data through 7 Oct 2026). Builds on 32 of its 46 references that are in the map. First posted on arXiv 21 Apr 2026.
Builds on
32 of 46 references.
References · 32
- 2018BERT: Pre-training of Deep Bidirectional Transformers for Language Understandingcited by 40,204
- 2020Language Models are Few-Shot Learnerscited by 32,199
- 2020Measuring Massive Multitask Language Understandingcited by 7,768
- 2022OPT: Open Pre-trained Transformer Language Modelscited by 3,464
- 2019The Curious Case of Neural Text Degenerationcited by 2,881
- 2020Don't Stop Pretraining: Adapt Language Models to Domains and Taskscited by 1,548
- 2020RealToxicityPrompts: Evaluating Neural Toxic Degeneration in Language Modelscited by 1,235
- 2025Qwen3 Embedding: Advancing Text Embedding and Reranking Through Foundation Modelscited by 1,175
- 2019Plug and Play Language Models: A Simple Approach to Controlled Text Generationcited by 793
- 2022Contrastive Decoding: Open-ended Text Generation as Optimizationcited by 598
- 2023The Falcon Series of Open Language Modelscited by 526
- 2021DExperts: Decoding-Time Controlled Text Generation with Experts and Anti-Expertscited by 434
20 more
- 2022ToxiGen: A Large-Scale Machine-Generated Dataset for Adversarial and Implicit Hate Speech Detectioncited by 419
- 2019Nuanced Metrics for Measuring Unintended Bias with Real Data for Text Classificationcited by 396
- 2020GeDi: Generative Discriminator Guided Sequence Generationcited by 377
- 2024SWIFT:A Scalable lightWeight Infrastructure for Fine-Tuningcited by 345
- 2020Measuring and Reducing Gendered Correlations in Pre-trained Modelscited by 222
- 2020Learning from the Worst: Dynamically Generated Datasets to Improve Online Hate Detectioncited by 217
- 2024A Mechanistic Understanding of Alignment Algorithms: A Case Study on DPO and Toxicitycited by 179
- 2023Word Embeddings Are Steers for Language Modelscited by 70
- 2022Exploring the Limits of Domain-Adaptive Training for Detoxifying Large-Scale Language Modelscited by 67
- 2021Text Detoxification using Large Pre-trained Neural Modelscited by 52
- 2023Self-Detoxifying Language Models via Toxification Reversalcited by 45
- 2023Using In-Context Learning to Improve Dialogue Safetycited by 41
- 2022Detoxifying Text with MaRCo: Controllable Revision with Experts and Anti-Expertscited by 36
- 2024Can LLMs Recognize Toxicity? A Structured Investigation Framework and Toxicity Metriccited by 23
- 2025Deep Research: A Systematic Surveycited by 23
- 2022Leashing the Inner Demons: Self-Detoxification for Language Modelscited by 19
- 2024Parameter-Efficient Detoxification with Contrastive Decodingcited by 18
- 2025UniDetox: Universal Detoxification of Large Language Models via Dataset Distillationcited by 8
- 2023CMD: a framework for Context-aware Model self-Detoxificationcited by 6
- 2022Detoxifying Language Models with a Toxic Corpuscited by 5
Built on by
Not cited yet.