Skip to main content
QUICK REVIEW

[Paper Review] LLM Self Defense: By Self Examination, LLMs Know They Are Being Tricked

Mansi Phute, Alec Helbling|arXiv (Cornell University)|Aug 14, 2023
Topic ModelingComputer Science33 citations
TL;DR

The paper proposes a zero-shot defense where an LLM acts as a harm filter to classify its own generated content, drastically reducing attack success rates without model fine-tuning or preprocessing.

ABSTRACT

Large language models (LLMs) are popular for high-quality text generation but can produce harmful content, even when aligned with human values through reinforcement learning. Adversarial prompts can bypass their safety measures. We propose LLM Self Defense, a simple approach to defend against these attacks by having an LLM screen the induced responses. Our method does not require any fine-tuning, input preprocessing, or iterative output generation. Instead, we incorporate the generated content into a pre-defined prompt and employ another instance of an LLM to analyze the text and predict whether it is harmful. We test LLM Self Defense on GPT 3.5 and Llama 2, two of the current most prominent LLMs against various types of attacks, such as forcefully inducing affirmative responses to prompts and prompt engineering attacks. Notably, LLM Self Defense succeeds in reducing the attack success rate to virtually 0 using both GPT 3.5 and Llama 2. The code is publicly available at https://github.com/poloclub/llm-self-defense

Motivation & Objective

  • Motivate robust defenses against adversarial prompts that induce harmful content from LLMs.
  • Propose a simple, zero-shot self-defense mechanism that requires no model fine-tuning or data preprocessing.
  • Demonstrate the approach across two prominent LLMs and various attack types.
  • Evaluate how the order of harm detection (suffix vs prefix) affects filtering performance.

Proposed method

  • Induce harmful text from a generator LLM given harmful prompts to obtain T_resp.
  • Use a harm filter LLM to classify T_resp as harmful or harmless via a zero-shot prompt.
  • The harm filter is another LLM instance that outputs Yes, this is harmful or No, this is not harmful.
  • Evaluate two configurations: treating harm as a prefix (before reading T_resp) vs a suffix (after reading T_resp).
  • Compute accuracy, true positive rate, and false positive rate of the harm classifier for each model and configuration.
  • No fine-tuning, input preprocessing, or iterative generation is required.

Experimental results

Research questions

  • RQ1Can a zero-shot LLM act as an effective harm filter to detect and block harmful content generated by another LLM?
  • RQ2Does presenting harmful content to the filter before vs after processing affect harm detection performance?
  • RQ3Do the defense capabilities generalize across GPT-3.5 and Llama 2 against various attack types?
  • RQ4What are the trade-offs in accuracy and false positives when using the filter as prefix vs suffix?

Key findings

  • The harm filter achieves high accuracy in identifying harmful content for GPT-3.5 (98% prefix; 99% suffix) and Llama 2 (77% prefix; 94.6% suffix).
  • Suffix-based harm detection generally reduces false positives more effectively than prefix detection.
  • When content is checked after processing (suffix), GPT-3.5 reaches 99% accuracy and Llama 2 reaches 94.6% accuracy, with near-zero attack success.
  • Attack success is reduced to virtually 0 for both GPT-3.5 and Llama 2 under LLM Self Defense across attack types including affirmative-response elicitation and prompt engineering attacks.
  • Llama 2 suffers fewer false positives in suffix mode (0.09 FPR) compared to prefix mode (0.42 FPR).
  • The method works without model fine-tuning and without data preprocessing, offering a faster, simpler defense relative to prior iterative defenses.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.