arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2602.02498cs.CLcs.AIcs.LG
收藏

无需训练或学习的测试时去毒化

Test-Time Detoxification without Training or Learning Anything

Baturay Saglam, Dionysis Kalogerias

AI总结:

本文提出一种无需训练或学习的测试时去毒化方法,通过零阶优化调整输入嵌入以减少生成文本的毒性,实现安全高效的文本生成。

摘要:

大型语言模型即使在良性输入下也可能生成有毒或不适当的内容,这在大规模部署时带来风险。去毒化对于安全和用户信任至关重要,尤其在不牺牲模型生成质量的前提下减少有害内容。现有方法依赖模型重新训练、梯度或学习的辅助组件,成本高且可能无法跨模型家族或真正黑盒设置转移。我们介绍了一种测试时程序,通过近似完成毒性对输入嵌入的梯度,并使用少量下降步骤引导生成向更不具毒性的延续发展。这通过仅需访问输入嵌入、毒性评分函数和模型的前向评估的零阶优化实现。实证结果表明,该方法在不同模型和提示下均能稳健地减少毒性,并在大多数情况下实现最佳的毒性-质量权衡。更广泛地说,我们的工作将词嵌入定位为有效的控制变量,并鼓励更广泛地使用黑盒优化来指导自回归语言模型实现可扩展、更安全的文本生成,而无需任何训练或访问中间计算。

英文摘要:

Large language models can produce toxic or inappropriate text even for benign inputs, creating risks when deployed at scale. Detoxification is therefore important for safety and user trust, particularly when we want to reduce harmful content without sacrificing the model's generation quality. Many existing approaches rely on model retraining, gradients, or learned auxiliary components, which can be costly and may not transfer across model families or to truly black-box settings. We introduce a test-time procedure that approximates the gradient of completion toxicity with respect to the input embeddings and uses a small number of descent steps to steer generation toward less toxic continuations. This is achieved with zeroth-order optimization that requires only access to input embeddings, a toxicity scoring function, and forward evaluations of the model. Empirically, the approach delivers robust toxicity reductions across models and prompts and, in most settings, achieves the best overall toxicity-quality trade-off. More broadly, our work positions word embeddings as effective control variables and encourages wider use of black-box optimization to guide autoregressive language models toward scalable, safer text generation, without requiring any training or access to intermediate computations.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑