Skip to main content
QUICK REVIEW

[论文解读] Certifying LLM Safety against Adversarial Prompting

Aounon Kumar, Chirag Agarwal|arXiv (Cornell University)|Sep 6, 2023
Adversarial Robustness in Machine LearningComputer Science被引用 25
一句话总结

论文介绍 erase-and-check,一个框架,通过擦除提示中的子序列令牌并用筛选器检查安全,在指定攻击规模下提供安全保证。

ABSTRACT

Large language models (LLMs) are vulnerable to adversarial attacks that add malicious tokens to an input prompt to bypass the safety guardrails of an LLM and cause it to produce harmful content. In this work, we introduce erase-and-check, the first framework for defending against adversarial prompts with certifiable safety guarantees. Given a prompt, our procedure erases tokens individually and inspects the resulting subsequences using a safety filter. Our safety certificate guarantees that harmful prompts are not mislabeled as safe due to an adversarial attack up to a certain size. We implement the safety filter in two ways, using Llama 2 and DistilBERT, and compare the performance of erase-and-check for the two cases. We defend against three attack modes: i) adversarial suffix, where an adversarial sequence is appended at the end of a harmful prompt; ii) adversarial insertion, where the adversarial sequence is inserted anywhere in the middle of the prompt; and iii) adversarial infusion, where adversarial tokens are inserted at arbitrary positions in the prompt, not necessarily as a contiguous block. Our experimental results demonstrate that this procedure can obtain strong certified safety guarantees on harmful prompts while maintaining good empirical performance on safe prompts. Additionally, we propose three efficient empirical defenses: i) RandEC, a randomized subsampling version of erase-and-check; ii) GreedyEC, which greedily erases tokens that maximize the softmax score of the harmful class; and iii) GradEC, which uses gradient information to optimize tokens to erase. We demonstrate their effectiveness against adversarial prompts generated by the Greedy Coordinate Gradient (GCG) attack algorithm. The code for our experiments is available at https://github.com/aounon/certified-llm-safety.

研究动机与目标

  • 为在大型语言模型中对抗对抗性提示提供可证明的防御的需求提供动机。
  • 提出 erase-and-check,以对抗在规定长度内修改的对抗性修改来证明安全性。
  • 提供两种安全过滤实现(Llama 2 和 DistilBERT),并分析三种攻击模式(后缀、插入、混入)。
  • 提供高效的经验防御以在保持强检测性能的同时降低计算。
  • 证明理论上的安全保证和在安全提示与有害提示上的经验表现。

提出的方法

  • erase-and-check 从提示中擦除多达 d 个令牌以形成子序列,并对每个子序列进行安全筛选。
  • 提供正式的安全证明:如果筛选器将任何子序列或提示标记为有害,erase-and-check 将提示标记为有害。
  • 以两种方式实现安全筛选:a) Llama 2 基于提示的分类器,b) 微调的 DistilBERT 分类器。
  • 分析三种攻击模式:对抗性后缀、对抗性插入、对抗性混入。
  • 提出三种经验防御:RandEC、GreedyEC、GradEC。
  • 证明一个安全定理,通过对有害提示上安全筛选器的工作来界定 erase-and-check 的准确性(Theorem 4.1)。
  • 在 AdvBench 提示上对安全提示和有害提示的经验表现进行评估。
Figure 1 : An illustration of how erase-and-check works on adversarial suffix attacks. It erases tokens from the end and checks the resulting subsequences using a safety filter. If any of the erased subsequences is detected as harmful, the input prompt is labeled harmful.
Figure 1 : An illustration of how erase-and-check works on adversarial suffix attacks. It erases tokens from the end and checks the resulting subsequences using a safety filter. If any of the erased subsequences is detected as harmful, the input prompt is labeled harmful.

实验结果

研究问题

  • RQ1erase-and-check 能否对最多长度 d 的对抗性提示提供可证明的安全保证?
  • RQ2不同的安全过滤后端(Llama 2 与 DistilBERT)如何影响认证和经验表现?
  • RQ3这三种攻击模式(后缀、插入、混入)对标准和经验防御有多大影响?
  • RQ4高效的经验防御(RandEC、GreedyEC、GradEC)在降低计算的同时是否保持强检测?
  • RQ5对认证保证与实际运行时间之间的权衡在实际应用中如何?

主要发现

  • erase-and-check 在使用 Llama 2 时对有害提示的认证检测率为 92%,在 AdvBench 提示上使用 DistilBERT 为 100%。
  • 基于 DistilBERT 的安全过滤在有害提示上的性能比基于 Llama 2 的过滤更快且更准确。
  • 对于安全提示,erase-and-check 在所有攻击模式下保持较高的经验准确性(使用 Llama 2 为 97%;使用 DistilBERT 为 98%)。
  • 在长度为 20 的对抗性后缀提示中,erase-and-check 展现出比 Prior GPT-3.5 性能基线更强的保护。
  • RandEC、GreedyEC 和 GradEC 在对抗 GCG 攻击时提供显著的加速,同时保持有竞争力的检测能力(例如 RandEC 在约 30% 的子序列被检查时达到 >90% 的准确率)。
  • infusion 模式的实验表明 DistilBERT 在准确性和速度方面优于 Llama 2,使得对更多对抗性令牌的认证成为可能。
Figure 2 : Adversarial prompts under different attack modes. Adversarial tokens are represented in red.
Figure 2 : Adversarial prompts under different attack modes. Adversarial tokens are represented in red.

阅读本论文

在 Nubint 阅读器中打开原文,边读边就任意段落提问。

在 Nubint 中阅读本论文

本解读由 AI 根据论文原文生成,引用前请核对原文。