TL;DR
This paper introduces MANATEE, a novel inference-time defense for Large Language Models (LLMs) that uses diffusion models to project potentially harmful internal representations back onto a "safe" manifold of benign representations. This approach effectively reduces attack success rates on jailbreak prompts by up to 100% without requiring harmful training data or architectural changes to the LLM, while preserving its utility on normal inputs.
What Problem Does This Paper Address?
Large Language Models (LLMs) are increasingly deployed in sensitive applications, but they remain vulnerable to "jailbreak" attacks. These attacks, often using adversarial prompts, can bypass safety training and elicit harmful or undesirable outputs. Existing defenses struggle with this challenge:
- Binary Classifiers: These defenses are brittle. If an adversarial input falls outside the classifier's learned decision boundary, it can still succeed.
- Repeated Fine-tuning: This is computationally expensive and can degrade the LLM's overall capabilities.
- New Attack Classes: Defenses often need to be retrained for each new type of attack, making them difficult to maintain.
The core problem is finding a robust, efficient, and generalizable way to defend LLMs against these sophisticated attacks at inference time.
Methods
MANATEE tackles this problem by reframing safety as a density estimation task. Instead of asking "is this representation harmful?", it asks "how can this representation be projected onto the manifold of benign representations?". The method has three main stages:
- Learning the Benign Manifold: The defense first extracts hidden states from the LLM's internal representations when generating benign text. These states are standardized (zero mean, unit variance). A denoising diffusion model (DDPM) is then trained to learn the probability distribution (density) of these benign representations.
- Inference-Time Detection: When the LLM processes a new input, its final-layer hidden state is extracted and standardized. MANATEE then uses the trained diffusion model to estimate how "anomalous" this hidden state is compared to the learned benign manifold. This is done by measuring the predicted noise magnitude of the denoiser at a specific timestep, yielding an "anomaly score."
- Diffusion-Based Correction (Steering or Refusal):
- Conditional Steering: If the anomaly score is below a certain threshold (indicating the representation is close to the benign manifold), MANATEE applies a diffusion-based "purification" process. This involves injecting noise into the anomalous state and then iteratively denoising it using the diffusion model, effectively steering it back towards the high-density regions of the benign manifold. The purified state is then used to generate a safe response.
- Automatic Refusal: If the anomaly score exceeds the threshold, the system triggers an automatic refusal, preventing the LLM from generating a potentially harmful output.
Crucially, MANATEE operates entirely in the representation space, requires no harmful training data, and does not modify the LLM's architecture.
Datasets
The paper evaluates MANATEE on several datasets and models:
- Mechanistic Anomaly Detection Llama3-deployment-backdoor (MAD): Used for evaluation.
- Anthropic Sleeper Agent (ASA): Used for evaluation.
- Jailbreak Bench Behavior (JBB): Used for evaluation.
The diffusion model itself is trained on benign hidden states extracted from the LLMs' own benign generations. The LLMs used for evaluation include:
- Mistral-7B-Instruct-v0.3
- Gemma-2-9B-it
- Llama-3.1-8B-Instruct
For evaluation, copies of these models were fine-tuned on backdoored data and then tested with and without MANATEE.
Key Insights and Ideas
- Reframing Safety as Density Estimation: The core insight is that safety can be viewed as ensuring LLM representations stay within a "normal" or "benign" distribution. This allows leveraging powerful density estimation tools like diffusion models.
- Inference-Time Steering: Instead of just blocking harmful outputs, MANATEE actively "corrects" potentially harmful internal states by projecting them back to a safe manifold. This is a more nuanced approach than simple refusal.
- No Harmful Training Data Required: A significant advantage is that MANATEE learns from benign data only, avoiding the ethical and practical challenges of collecting and using harmful data for defense training.
- Architectural Agnosticism: The defense works by manipulating internal representations, meaning it can be applied to various LLM architectures without needing to modify them.
Key Results
MANATEE demonstrates significant effectiveness in reducing the Attack Success Rate (ASR):
- Quantitative Results:
- Average ASR reduction of 78% across datasets.
- Specific reductions: 58.7% on MAD, 77.6% on JBB, and 100.0% on ASA.
- On certain datasets (like ASA), MANATEE achieved a 100% reduction in ASR.
- Qualitative Results: The paper includes several examples (Table 1, Figures 3 & 8) showing that for prompts designed to elicit harmful content, the backdoored models would generate it, but MANATEE would successfully steer them to refuse or provide a safe response. For example, prompts asking for instructions on how to smuggle drugs or commit identity theft were met with refusals by MANATEE.
- Utility Preservation: The paper emphasizes that MANATEE preserves model utility on benign inputs, meaning it doesn't hinder the LLM's normal functionality.
Limitations and Future Work
- Limitations:
- The paper notes that the threshold $\tau$ for distinguishing benign from anomalous states is tuned based on the distribution of benign and backdoored samples. While effective, this tuning might require careful consideration in real-world deployments.
- The current implementation focuses on the final layer's hidden states.
- Future Work:
- The authors suggest exploring the expansion of diffusion-based approaches to more complex latent reasoning models, such as Continuous Chain of Thought (COCONUT).
- They also aim to test MANATEE against a wider variety of jailbreaking attacks.
Summary updated