用小模型注意力机制解释并防御新型越狱攻击,效果优于现有方法。
AttentionDefense: Leveraging System Prompt Attention for Explainable Defense Against Novel Jailbreaks
- 通过小模型的系统提示注意力识别越狱输入,实现可解释防御。
- 在基准数据集上检测性能等同或优于基于文本嵌入的分类器和GPT-4零样本检测。
- 对新型越狱变体仍保持鲁棒性,适合实际部署,计算开销低。
近年来,大语言模型(LMs)在多个领域展现出接近人类的能力。尽管应用广泛、用户量大,但其易受越狱攻击影响,恶意输入会利用模型弱点导致行为偏离预期。现有防御策略多为输入分类或阻止有害输出,但难以解释越狱原因,导致多数方法为黑盒。本研究提出并验证:小型语言模型(SLMs)的系统提示注意力可有效刻画恶意输入,构建出一种新颖、可解释且成本更低的防御方法——AttentionDefense。研究表明,注意力机制能捕捉文本嵌入未涵盖的模型响应规律,揭示越狱本质。AttentionDefense在现有越狱基准数据集上表现优异;消融实验显示其检测性能与基于文本嵌入的分类器及GPT-4零样本检测相当或更优。为进一步验证,我们使用闭环式大模型多智能体系统生成了现有基准数据集的新型越狱变体。结果表明,AttentionDefense在新数据集上依然稳健,而现有方法性能显著下降。此外,该方法计算开销仅相当于小模型,但检测性能媲美大模型,具备实际部署优势。
原文摘要 · Abstract (English)
In the past few years, Language Models (LMs) have shown par-human capabilities in several domains. Despite their practical applications and exceeding user consumption, they are susceptible to jailbreaks when malicious input exploits the LM's weaknesses, causing it to deviate from its intended behavior. Current defensive strategies either classify the input prompt as adversarial or prevent LMs from generating harmful outputs. However, it is challenging to explain the reason behind the malicious nature of the jailbreak, which results in a wide variety of closed-box approaches. In this research, we propose and demonstrate that system-prompt attention from Small Language Models (SLMs) can be used to characterize adversarial prompts, providing a novel, explainable, and cheaper defense approach called AttentionDefense. Our research suggests that the attention mechanism is an integral component in understanding and explaining how LMs respond to malicious input that is not captured in the semantic meaning of text embeddings. The proposed AttentionDefense is evaluated against existing jailbreak benchmark datasets. Ablation studies show that SLM-based AttentionDefense has equivalent or better jailbreak detection performance compared to text embedding-based classifiers and GPT-4 zero-shot detectors.To further validate the efficacy of the proposed approach, we generate a dataset of novel jailbreak variants of the existing benchmark dataset using a closed-loop LLM-based multi-agent system. We demonstrate that the proposed AttentionDefense approach performs robustly on this novel jailbreak dataset while existing approaches suffer in performance. Additionally, for practical purposes AttentionDefense is an ideal solution as it has the computation requirements of a small LM but the performance of a LLM detector.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。