Skip to main content
QUICK REVIEW

[논문 리뷰] Certifying LLM Safety against Adversarial Prompting

Aounon Kumar, Chirag Agarwal|arXiv (Cornell University)|2023. 09. 06.
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.

연구 동기 및 목표

  • 대형 언어 모델(LLM)에서 적대적 프롬프트에 대한 입증 가능한 방어의 필요성을 동기 부여한다.
  • 지정된 길이까지의 적대적 수정에 대해 안전성을 인증하기 위해 erase-and-check를 제안한다.
  • 두 가지 안전 필터 구현( Llama 2와 DistilBERT )을 제공하고 세 가지 공격 모드(접미사, 삽입, 주입)를 분석한다.
  • 강력한 탐지 성능을 유지하면서 계산량을 줄이는 효율적인 실험적 방어를 제시한다.
  • 안전한 프롬프트와 해로운 프롬프트에 대한 이론적 안전 보장과 실험적 성능을 보여준다.

제안 방법

  • erase-and-check은 프롬프트에서 최대 d개의 토큰을 지워 하위 시퀀스를 형성하고 각 시퀀스를 안전 필터로 검사한다.
  • 형식적인 안전 인증서를 제공한다: 필터가 어떤 하위 시퀀스나 프롬프트를 유해하다고 라벨링하면 erase-and-check는 프롬프트를 유해하다고 표시한다.
  • 구현된 안전 필터를 두 가지 방식으로 구현한다: (a) Llama 2 프롬pt 기반 분류기, (b) 미세 조정된 DistilBERT 분류기.
  • 세 가지 공격 모드 분석: 적대적 접미사, 적대적 삽입, 적대적 주입.
  • 세 가지 실험적 방어 제안: RandEC, GreedyEC, GradEC.
  • 해로운 프롬프트에서 안전 필터에 의한 정확도를 상한으로 하는 안전 정리(정리 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 vs DistilBERT)가 인증된 성능과 실험적 성능에 어떤 영향을 미치는가?
  • RQ3세 가지 공격 모드(접미사, 삽입, 주입)가 표준 및 실험적 방어에 얼마나 효과적인가?
  • RQ4효율적인 실험적 방어(RandEC, GreedyEC, GradEC)가 계산량을 줄이면서도 강력한 탐지를 유지하는가?
  • RQ5실제 사용 사례에서 인증 보장과 실제 런타임 간의 트레이드오프는 무엇인가?

주요 결과

  • erase-and-check은 AdvBench 프롬프트에서 Llama 2로 해로운 프롬프트에 대해 92%의 인증 탐지율을 달성하고 DistilBERT로는 100%를 달성한다.
  • DistilBERT 기반 안전 필터가 Llama 2 기반 필터보다 해로운 프롬프트에서 더 빠르고 정확한 성능을 제공한다.
  • 안전한 프롬프트의 경우, 공격 모드 전반에 걸쳐 erase-and-check가 높은 실험적 정확도( Llama 2로 97%, DistilBERT로 98% )를 유지한다.
  • 길이 20의 적대적 접미사 프롬프트에서 erase-and-check는 기존 GPT-3.5 성능 기준 대비 강력한 보호를 보인다.
  • RandEC, GreedyEC, GradEC는 GCG 공격에 대해 경쟁력 있는 탐지를 유지하면서 상당한 속도 향상을 제공한다(예: RandEC는 약 30%의 부분 시퀀스를 확인하여 >90% 정확도 달성).
  • 주입 모드 실험에서 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.

이 논문 읽기

누빈트 뷰어에서 원문을 열고, 읽으면서 궁금한 곳을 바로 물어보세요.

누빈트에서 이 논문 읽기

이 리뷰는 AI가 논문 원문을 바탕으로 만들었습니다. 인용하기 전에 원문을 확인해 주세요.