arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.20778cs.CRcs.LG
收藏

针对安全对齐大语言模型的对抗样本改进生成方法

Improved Generation of Adversarial Examples Against Safety-aligned LLMs

Harbin Institute of Technology(哈尔滨工业大学);Tencent Security Big Data Lab(腾讯安全大数据实验室);UC Davis(加利福尼亚大学戴维斯分校)

Qizhang Li, Yiwen Guo, Wangmeng Zuo, Hao Chen

AI总结:

针对基于梯度的对抗提示词攻击安全对齐LLM成功率有限的问题,本文将图像迁移攻击中的跳跃梯度法和中间层攻击理念引入对抗提示词生成,组合方法在AdvBench上相比GCG基线大幅提升攻击成功率且无额外计算开销。

摘要:

利用基于梯度的方法生成的对抗提示词,在对安全对齐大语言模型(LLM)实施自动越狱攻击方面表现出优异性能。然而,由于文本的离散特性,LLM的输入梯度难以精确反映提示词中令牌替换导致的损失变化幅度,使得即便在白盒设置下,针对安全对齐LLM的攻击成功率也十分有限。本文从全新视角探讨该问题,提出可借鉴最初用于攻击黑盒图像分类模型的基于迁移的攻击的创新思路来缓解这一问题。我们首次将这类基于迁移的攻击中的有效方法——即Skip Gradient Method(跳跃梯度法)和Intermediate Level Attack(中间层攻击)的理念,应用于基于梯度的对抗提示词生成中,在未引入明显计算开销的情况下实现了显著的性能提升。同时,通过探讨性能提升背后的机制,我们得出了新的见解,并开发了这些方法的合理组合方案。我们的实验结果显示,所开发的组合方法生成的查询特定对抗后缀中,有87%能够诱导Llama-2-7B-Chat在AdvBench上生成与目标字符串完全匹配的输出。该匹配率比性能极强的基线方法GCG高出33%,证明了针对LLM的对抗提示词生成的离散优化技术取得了先进进展。此外,在未引入明显开销的情况下,针对AdvBench上的Llama-2-7B-Chat模型生成查询特定对抗提示词(38% -> 68%)和通用对抗提示词(26.68% -> 60.32%)时,该组合方法相比GCG的攻击成功率实现了超过30%的绝对提升。代码见:https://github.com/qizhangli/Gradient-based-Jailbreak-Attacks。

英文摘要:

Adversarial prompts generated using gradient-based methods exhibit outstanding performance in performing automatic jailbreak attacks against safety-aligned LLMs. Nevertheless, due to the discrete nature of texts, the input gradient of LLMs struggles to precisely reflect the magnitude of loss change that results from token replacements in the prompt, leading to limited attack success rates against safety-aligned LLMs, even in the white-box setting. In this paper, we explore a new perspective on this problem, suggesting that it can be alleviated by leveraging innovations inspired in transfer-based attacks that were originally proposed for attacking black-box image classification models. For the first time, we appropriate the ideologies of effective methods among these transfer-based attacks, i.e., Skip Gradient Method and Intermediate Level Attack, into gradient-based adversarial prompt generation and achieve significant performance gains without introducing obvious computational cost. Meanwhile, by discussing mechanisms behind the gains, new insights are drawn, and proper combinations of these methods are also developed. Our empirical results show that 87% of the query-specific adversarial suffixes generated by the developed combination can induce Llama-2-7B-Chat to produce the output that exactly matches the target string on AdvBench. This match rate is 33% higher than that of a very strong baseline known as GCG, demonstrating advanced discrete optimization for adversarial prompt generation against LLMs. In addition, without introducing obvious cost, the combination achieves >30% absolute increase in attack success rates compared with GCG when generating both query-specific (38% -> 68%) and universal adversarial prompts (26.68% -> 60.32%) for attacking the Llama-2-7B-Chat model on AdvBench. Code at: https://github.com/qizhangli/Gradient-based-Jailbreak-Attacks.

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

↑