arXiv:2410.16327cs.CRcs.AI2024-10IJCAI被引 6

通过注意力分布设计攻防策略,揭示大模型安全漏洞与防御机制。

Feint and Attack: Attention-Based Strategies for Jailbreaking and Protecting LLMs

  • 用注意力权重分析诱导模型生成有害内容的攻击路径。
  • 提出新指标捕捉敏感词关注程度与注意力分散熵,定位攻击弱点。
  • 借鉴军事‘佯攻诱敌’策略,实现高效越狱攻击与反制防御。

越狱攻击可通过构造语义模糊提示,诱导大语言模型(LLMs)生成有害内容。为探究模型输入与输出之间的内在关联,本文引入注意力权重分布进行分析,并基于统计方法定义了三项新指标:敏感词注意力强度(Attn_SensWords)、基于注意力的上下文依赖得分(Attn_DepScore)及注意力分散熵(Attn_Entropy)。利用这些指标的差异特性,提出名为注意力驱动攻击(ABA)的新策略,借鉴军事“佯攻诱敌”思想,采用嵌套攻击提示转移模型注意力,使更多无害部分吸引模型关注。同时,受ABA启发,提出注意力驱动防御(ABD)策略,通过校准输入提示的注意力分布增强模型鲁棒性。对比实验验证了ABA与ABD的有效性,结果表明注意力分布对模型输出具有显著影响。

原文摘要 · Abstract (English)

Jailbreak attack can be used to access the vulnerabilities of Large Language Models (LLMs) by inducing LLMs to generate the harmful content. And the most common method of the attack is to construct semantically ambiguous prompts to confuse and mislead the LLMs. To access the security and reveal the intrinsic relation between the input prompt and the output for LLMs, the distribution of attention weight is introduced to analyze the underlying reasons. By using statistical analysis methods, some novel metrics are defined to better describe the distribution of attention weight, such as the Attention Intensity on Sensitive Words (Attn_SensWords), the Attention-based Contextual Dependency Score (Attn_DepScore) and Attention Dispersion Entropy (Attn_Entropy). By leveraging the distinct characteristics of these metrics, the beam search algorithm and inspired by the military strategy "Feint and Attack", an effective jailbreak attack strategy named as Attention-Based Attack (ABA) is proposed. In the ABA, nested attack prompts are employed to divert the attention distribution of the LLMs. In this manner, more harmless parts of the input can be used to attract the attention of the LLMs. In addition, motivated by ABA, an effective defense strategy called as Attention-Based Defense (ABD) is also put forward. Compared with ABA, the ABD can be used to enhance the robustness of LLMs by calibrating the attention distribution of the input prompt. Some comparative experiments have been given to demonstrate the effectiveness of ABA and ABD. Therefore, both ABA and ABD can be used to access the security of the LLMs. The comparative experiment results also give a logical explanation that the distribution of attention weight can bring great influence on the output for LLMs.

大模型安全注意力分析越狱攻击防御机制

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