arXiv:2604.19124cs.CL2026-04ACL

通过语义保持的文本重写,从源头净化预训练数据以降低大模型毒性。

Detoxification for LLM: From Dataset Itself

论文配图:Detoxification for LLM: From Dataset Itself
图 1 · 摘自论文原文
  • 用软对比解码定位并重写原始语料中的毒害片段,保留原意。
  • 在GPT2-XL上将毒性概率从0.42降至0.18,最大预期毒性从0.43降至0.20。
  • 适用于多种模型,可直接替换训练数据,减少后期调优成本。

现有大语言模型去毒方法多集中于微调阶段或推理时控制,少有从数据源本身入手。训练阶段或可控解码方法无法彻底消除模型固有毒性,而对预训练数据进行去毒可从根本上减少模型学习到的毒性。为此,本文提出层级语义保持去毒(HSPD)框架,采用软对比解码(SoCD)引导大模型定位并重写原始语料中的毒害段落,同时保持语义不变,生成可直接替代原始数据用于微调或训练的去毒语料。在GPT2-XL上,该方法将毒性概率(TP)从0.42降至0.18,最大预期毒性(EMT)从0.43降至0.20,并在LLaMA2-7B、OPT-6.7B和Falcon-7B上均取得最佳性能。结果表明,基于语义保持的语料级重写能有效抑制下游毒性,同时维持数据可用性,实现源头治理,降低后期模型行为调整成本。(代码见:https://github.com/ntsw2001/data_detox_for_llm)

原文摘要 · Abstract (English)

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)

去毒数据清洗语义保持LLM

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。