arXiv:2506.15751cs.AIcs.CL2025-06被引 4

用可变系统提示增强大模型安全,不改模型参数也能大幅提高拒答有害请求能力。

Sysformer: Safeguarding Frozen Large Language Models with Adaptive System Prompts

  • 设计可动态调整的系统提示,通过轻量级Transformer模型生成适配输入的提示。
  • 在5个大模型上测试,有害请求拒答率提升最高达80%,安全请求响应符合度提升90%。
  • 无需微调模型参数,对复杂越狱攻击也有效,适合追求低成本安全防护的研究者。

随着大语言模型(LLMs)在安全关键场景中的部署,确保其输出符合安全标准至关重要。已有研究发现,LLMs常无法理解安全行为,导致对无害提示拒绝回应或生成有害内容。尽管已有大量工作致力于提升其鲁棒性,但现有防御方法通常依赖昂贵的参数微调或次优的启发式技术。本文提出一种新方法:通过学习自适应调整指令微调后的LLM的系统提示。传统上LLM使用固定系统提示,而我们研究了针对每个用户输入定制系统提示对响应安全性的影响。为此,我们提出Sysformer——一个Transformer模型,在保持LLM参数冻结的前提下,基于用户提示在嵌入空间中动态更新初始系统提示,以增强安全性和鲁棒性。训练目标是使模型对一组有害提示拒绝响应,同时理想地响应一组安全提示。在5个不同家族的大型语言模型和2个近期基准上的广泛实验表明,Sysformer能显著提升模型鲁棒性:有害提示拒答率最高提升80%,安全提示合规度提升高达90%。结果在复杂越狱攻击下也具有良好泛化能力,使模型对不同攻击策略的鲁棒性提升达100%。本工作希望推动更低成本的LLM安全防护,并激发未来对可变系统提示设计的研究。

原文摘要 · Abstract (English)

As large language models (LLMs) are deployed in safety-critical settings, it is essential to ensure that their responses comply with safety standards. Prior research has revealed that LLMs often fail to grasp the notion of safe behaviors, resulting in either unjustified refusals to harmless prompts or the generation of harmful content. While substantial efforts have been made to improve their robustness, existing defenses often rely on costly fine-tuning of model parameters or employ suboptimal heuristic techniques. In this work, we take a novel approach to safeguard LLMs by learning to adapt the system prompts in instruction-tuned LLMs. While LLMs are typically pre-trained to follow a fixed system prompt, we investigate the impact of tailoring the system prompt to each specific user input on the safety of the responses. To this end, we propose $\textbf{Sysformer}$, a trans$\textbf{former}$ model that updates an initial $\textbf{sys}$tem prompt to a more robust system prompt in the LLM input embedding space while attending to the user prompt. While keeping the LLM parameters frozen, the Sysformer is trained to refuse to respond to a set of harmful prompts while responding ideally to a set of safe ones. Through extensive experiments on $5$ LLMs from different families and $2$ recent benchmarks, we demonstrate that Sysformer can significantly enhance the robustness of LLMs, leading to upto $80\%$ gain in the refusal rate on harmful prompts while enhancing the compliance with the safe prompts by upto $90\%$. Results also generalize well to sophisticated jailbreaking attacks, making LLMs upto $100\%$ more robust against different attack strategies. We hope our findings lead to cheaper safeguarding of LLMs and motivate future investigations into designing variable system prompts.

大模型安全系统提示零样本防护防御机制

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。