arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2405.18166cs.AI
收藏

通过特定层编辑保护大语言模型免受越狱攻击

Defending Large Language Models Against Jailbreak Attacks via Layer-specific Editing

Singapore Management University(新加坡管理大学);National University of Singapore(新加坡国立大学)

Wei Zhao, Zhe Li, Yige Li, Ye Zhang, Jun Sun

AI总结:

本文提出 Layer-specific Editing(LED),通过识别并重新对齐 LLM 早期关键安全层来防御越狱攻击,并在 Llama2、Mistral 上验证其有效性。

摘要:

大语言模型(LLM)正越来越多地被广泛应用于各类真实场景。尽管其性能令人瞩目,但近期研究表明,即使 LLM 已通过基于人类反馈的强化学习或监督微调进行对齐,仍容易受到精心构造的对抗性提示攻击。现有防御方法要么侧重于检测有害提示,要么通过各种方式降低有害响应的可能性,而基于 LLM 内部机制来防御越狱攻击的研究仍基本未被探索。本文研究了 LLM 如何响应有害提示,并提出一种名为 Layer-specific Editing(LED,特定层编辑)的新型防御方法,以增强 LLM 对越狱攻击的抵御能力。通过 LED,我们揭示了 LLM 的早期层中存在若干关键的“安全层”。随后表明,利用从选定目标层解码出的安全响应来重新对齐这些安全层(以及一些选定的附加层),可以显著提升 LLM 针对越狱攻击的对齐水平。在多种 LLM(如 Llama2、Mistral)上进行的大量实验证明了 LED 的有效性:它能有效防御越狱攻击,同时保持在良性提示上的性能。代码位于 https://github.com/ledllm/ledllm。

英文摘要:

Large language models (LLMs) are increasingly being adopted in a wide range of real-world applications. Despite their impressive performance, recent studies have shown that LLMs are vulnerable to deliberately crafted adversarial prompts even when aligned via Reinforcement Learning from Human Feedback or supervised fine-tuning. While existing defense methods focus on either detecting harmful prompts or reducing the likelihood of harmful responses through various means, defending LLMs against jailbreak attacks based on the inner mechanisms of LLMs remains largely unexplored. In this work, we investigate how LLMs response to harmful prompts and propose a novel defense method termed \textbf{L}ayer-specific \textbf{Ed}iting (LED) to enhance the resilience of LLMs against jailbreak attacks. Through LED, we reveal that several critical \textit{safety layers} exist among the early layers of LLMs. We then show that realigning these safety layers (and some selected additional layers) with the decoded safe response from selected target layers can significantly improve the alignment of LLMs against jailbreak attacks. Extensive experiments across various LLMs (e.g., Llama2, Mistral) show the effectiveness of LED, which effectively defends against jailbreak attacks while maintaining performance on benign prompts. Our code is available at \url{https://github.com/ledllm/ledllm}.

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

↑