Skip to main content
QUICK REVIEW

[论文解读] CMD: a framework for Context-aware Model self-Detoxification

Zecheng Tang, Keyan Zhou|arXiv (Cornell University)|Aug 16, 2023
Topic ModelingComputer Science被引用 3
一句话总结

本文提出CMD,一种上下文感知的框架,通过称为Detox-Chain的逐步过程实现大语言模型(LLMs)的自我净化。通过将净化过程分解为有序的子步骤——检测毒性、屏蔽毒性片段、并重述为非毒性提示——CMD使LLM能够在不损害连贯性或语义质量的前提下生成安全内容。该方法在六种LLM(1B–33B)中均显著提升了净化效果与生成质量。

ABSTRACT

Text detoxification aims to minimize the risk of language models producing toxic content. Existing detoxification methods of directly constraining the model output or further training the model on the non-toxic corpus fail to achieve a decent balance between detoxification effectiveness and generation quality. This issue stems from the neglect of constrain imposed by the context since language models are designed to generate output that closely matches the context while detoxification methods endeavor to ensure the safety of the output even if it semantically deviates from the context. In view of this, we introduce a Context-aware Model self-Detoxification~(CMD) framework that pays attention to both the context and the detoxification process, i.e., first detoxifying the context and then making the language model generate along the safe context. Specifically, CMD framework involves two phases: utilizing language models to synthesize data and applying these data for training. We also introduce a toxic contrastive loss that encourages the model generation away from the negative toxic samples. Experiments on various LLMs have verified the effectiveness of our MSD framework, which can yield the best performance compared to baselines.

研究动机与目标

  • 解决自回归LLM中毒性提示生成与净化之间的冲突。
  • 克服单步净化方法导致的生成质量下降问题。
  • 在实现有效毒性缓解的同时,保持强大的推理与生成能力。
  • 开发一种结构化、多步流程,引导LLM在生成前净化输入。
  • 即使在输入具有毒性的情况下,也能实现安全、连贯且语义一致的生成。

提出的方法

  • 将净化过程分解为三个有序子步骤:毒性内容检测、毒性片段屏蔽、以及重述为非毒性替代形式。
  • 提出Detox-Chain,一种受思维链(CoT)启发的框架,以逻辑化、分步的方式编排这些子步骤。
  • 在结合了毒性检测、片段修复和持续生成的多任务数据集上微调LLM,以增强其净化能力。
  • 利用S-adapter实现参数高效的微调,支持在多种LLM架构(如GPT-2、LLaMA、Flan-T5)上的适配。
  • 利用开源模型或商业API生成训练数据和推理链,确保可扩展性与可访问性。
  • 确保重述后的提示保留足够的上下文,以支持连贯的后续生成。
(a) Semantic similarity proportion
(a) Semantic similarity proportion

实验结果

研究问题

  • RQ1分步净化过程是否能降低LLM中毒性提示生成与安全强制之间的冲突?
  • RQ2与单步方法相比,将净化分解为子步骤对生成质量有何影响?
  • RQ3LLM在多大程度上能够以连贯且上下文感知的方式检测、屏蔽并重述毒性内容?
  • RQ4Detox-Chain框架在输入净化后是否能保持语义一致性和语篇连贯性?
  • RQ5所提出的方法是否能泛化至多种LLM架构和模型规模(1B至33B)而不会导致性能下降?

主要发现

  • CMD在六种LLM(1B–33B)中显著降低了生成内容的毒性,同时保持了语义一致性和语篇连贯性。
  • 自动评估与人工评估均表明,采用Detox-Chain训练的模型在毒性降低与生成质量方面均优于基线单步净化方法。
  • Detox-Chain框架使模型即使在处理初始具有毒性的输入时,也能保持强大的推理与生成能力。
  • 经过多任务训练设置(毒性检测、片段修复、生成)微调的模型,在安全性和流畅性指标上均表现出更优性能。
  • 该方法在语义相似度(SIM)方面实现可测量的提升,同时困惑度(PPL)降低,表明输入与输出之间对齐更优。
  • 该框架在多种架构中均表现有效,包括GPT-2-XL、LLaMA、Alpaca和Flan-T5,展现出广泛的适用性。
(b) Toxicity of LLMs (SIM)
(b) Toxicity of LLMs (SIM)

更好的研究,从现在开始

从阅读论文到最终审阅,大幅缩短您的研究时间。

无需绑定信用卡

本解读由 AI 生成,并经人工编辑审核。