arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2406.16743cs.CL
收藏

通过对比安全与有害分布实现大语言模型的安全对齐

Safety Alignment of Large Language Models via Contrasting Safe and Harmful Distributions

Xiaoyun Zhang, Zhengyue Zhao, Wenxuan Shi, Kaidi Xu, Di Huang, Xing Hu

AI总结:

本文提出ACD方法,通过生成安全与对抗性提示,实现大语言模型的安全对齐,提升安全性的同时保持生成能力。

摘要:

随着大语言模型(LLMs)的广泛应用,确保其安全性和防止有害响应已成为重要关注点。尽管基于指令微调和人类反馈强化学习(RLHF)的当前安全对齐方法能有效减少LLMs的有害响应,但它们通常需要高质量的数据集和模型训练时的高计算开销。另一种对齐语言模型的方法是修改模型输出中token的logit,而无需大量训练。最近的研究表明,对比解码可通过减少混淆token的概率来提升语言模型的性能。然而,这些方法需要手动选择对比模型或指令模板,限制了对比程度。为此,我们提出对抗对比解码(ACD),一种基于优化的框架,用于生成两个相反的软系统提示,即安全提示(SP)和对抗提示(AP),用于基于提示的对比解码。SP旨在促进更安全的输出,而AP旨在利用模型中的有害部分,提供强烈的对比以将模型对齐到安全。ACD仅需在相对较小的锚数据集上应用轻量级的提示微调,而无需训练目标模型。在广泛模型和基准上的实验表明,所提出的方法在安全性能上比以前无模型训练的解码方法要好得多,且不牺牲其原有的生成能力。

英文摘要:

With the widespread application of Large Language Models (LLMs), it has become a significant concern to ensure their safety and prevent harmful responses. While current safe-alignment methods based on instruction fine-tuning and Reinforcement Learning from Human Feedback (RLHF) can effectively reduce harmful responses from LLMs, they often require high-quality datasets and heavy computational overhead during model training. Another way to align language models is to modify the logit of tokens in model outputs without heavy training. Recent studies have shown that contrastive decoding can enhance the performance of language models by reducing the likelihood of confused tokens. However, these methods require the manual selection of contrastive models or instruction templates, limiting the degree of contrast. To this end, we propose Adversarial Contrastive Decoding (ACD), an optimization-based framework to generate two opposite soft system prompts, the Safeguarding Prompt (SP) and the Adversarial Prompt (AP), for prompt-based contrastive decoding. The SP aims to promote safer outputs while the AP aims to exploit the harmful parts of the model, providing a strong contrast to align the model with safety. ACD only needs to apply a lightweight prompt tuning on a rather small anchor dataset without training the target model. Experiments conducted on extensive models and benchmarks demonstrate that the proposed method achieves much better safety performance than previous model training-free decoding methods without sacrificing its original generation ability.

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

↑