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

关于大型语言模型的提示驱动安全防护

On Prompt-Driven Safeguarding for Large Language Models

Tsinghua University(清华大学);University of California, Los Angeles(加利福尼亚大学洛杉矶分校);Tencent Inc.(腾讯公司)

Chujie Zheng, Fan Yin, Hao Zhou, Fandong Meng, Jie Zhou, Kai-Wei Chang, Minlie Huang, Nanyun Peng

AI总结:

本研究从模型表示视角揭示了安全提示使LLM更易拒绝查询的机制,并提出DRO方法将安全提示作为可训练嵌入进行优化,在不损害通用性能的前提下显著提升了域外和越狱基准的安全防护效果。

摘要:

在模型输入前添加安全提示是保护大型语言模型(LLMs)免受恶意意图查询的常见做法。然而,安全提示的底层工作机制尚未被揭示,这限制了自动优化它们以提升LLM安全性的可能性。在本研究中,我们从模型表示的角度探讨了LLMs的行为(即遵从或拒绝用户查询)如何受安全提示的影响。我们发现,在表示空间中,安全提示通常将输入查询推向“更高拒绝率”的方向,在该方向上模型变得更倾向于拒绝提供协助,即使查询是无害的。另一方面,LLMs在没有安全提示的情况下,天然具备区分有害和无害查询的能力。受这些发现的启发,我们提出了一种安全提示优化方法,即DRO(Directed Representation Optimization,定向表示优化)。DRO将安全提示视为连续的、可训练的嵌入,根据查询的有害性,学习沿着或逆着拒绝方向移动查询的表示。在八个LLM上针对域外和越狱基准的实验表明,DRO显著提升了人工设计安全提示的防护性能,且未损害模型的通用性能。

英文摘要:

Prepending model inputs with safety prompts is a common practice for safeguarding large language models (LLMs) against queries with harmful intents. However, the underlying working mechanisms of safety prompts have not been unraveled yet, restricting the possibility of automatically optimizing them to improve LLM safety. In this work, we investigate how LLMs' behavior (i.e., complying with or refusing user queries) is affected by safety prompts from the perspective of model representation. We find that in the representation space, the input queries are typically moved by safety prompts in a "higher-refusal" direction, in which models become more prone to refusing to provide assistance, even when the queries are harmless. On the other hand, LLMs are naturally capable of distinguishing harmful and harmless queries without safety prompts. Inspired by these findings, we propose a method for safety prompt optimization, namely DRO (Directed Representation Optimization). Treating a safety prompt as continuous, trainable embeddings, DRO learns to move the queries' representations along or opposite the refusal direction, depending on their harmfulness. Experiments with eight LLMs on out-of-domain and jailbreak benchmarks demonstrate that DRO remarkably improves the safeguarding performance of human-crafted safety prompts, without compromising the models' general performance.

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

↑