大模型可自我净化,无需额外训练或奖励模型。
Large Language Models can be Strong Self-Detoxifiers
- 利用模型内部表示动态构建毒性和非毒性空间,实时调整生成策略。
- 在多个数据集上将毒性水平显著降低,效果接近顶尖净化技术。
- 轻量级算法,适用于不同规模模型,适合追求安全生成的开发者。
减少大语言模型生成有害内容是其对齐的关键任务。现有方法多依赖外部奖励模型或基于自生成数据的微调。本文提出一种轻量级解码算法Self-disciplined Autoregressive Sampling (SASA),使大模型无需额外奖励模型或重训练即可实现自我净化。SASA利用模型上下文表征学习毒性和非毒性输出的线性子空间,并在逐词生成时动态追踪当前输出与毒性空间的距离,通过调整自回归采样策略引导生成远离毒性区域。在Llama-3.1-Instruct(8B)、Llama-2(7B)和GPT2-L等不同规模模型上,结合RealToxicityPrompts、BOLD和AttaQ基准测试,SASA显著提升生成质量,毒性水平大幅下降,性能媲美现有最先进净化方法,仅依赖模型内部表示完成。
原文摘要 · Abstract (English)
Reducing the likelihood of generating harmful and toxic output is an essential task when aligning large language models (LLMs). Existing methods mainly rely on training an external reward model (i.e., another language model) or fine-tuning the LLM using self-generated data to influence the outcome. In this paper, we show that LLMs have the capability of self-detoxification without the use of an additional reward model or re-training. We propose \textit{Self-disciplined Autoregressive Sampling (SASA)}, a lightweight controlled decoding algorithm for toxicity reduction of LLMs. SASA leverages the contextual representations from an LLM to learn linear subspaces characterizing toxic v.s. non-toxic output in analytical forms. When auto-completing a response token-by-token, SASA dynamically tracks the margin of the current output to steer the generation away from the toxic subspace, by adjusting the autoregressive sampling strategy. Evaluated on LLMs of different scale and nature, namely Llama-3.1-Instruct (8B), Llama-2 (7B), and GPT2-L models with the RealToxicityPrompts, BOLD, and AttaQ benchmarks, SASA markedly enhances the quality of the generated sentences relative to the original models and attains comparable performance to state-of-the-art detoxification techniques, significantly reducing the toxicity level by only using the LLM's internal representations.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。