TL;DR
Large Language Models (LLMs) remain highly vulnerable to adversarial "jailbreaking" attacks that bypass safety alignments. This paper introduces RESTA, a defense that injects random noise directly into continuous token embedding vectors and aggregates parallel token-level predictions via majority voting. Crucially, by applying this smoothing only to the initial response prefix, RESTA drastically reduces jailbreak success rates while preserving model utility and keeping computational overhead low.
What Problem Does This Paper Address?
While safety alignment techniques (like RLHF) successfully guide LLMs to refuse harmful requests, adversarial jailbreaking attacks can subvert these guardrails. Attacks like Greedy Coordinate Gradient (GCG) or Prompt Automatic Iterative Refinement (PAIR) append optimized token suffixes or use social engineering prompts to trick the model into complying with dangerous requests.
Existing inference-time defenses, such as SmoothLLM, attempt to disrupt these attacks by randomly perturbing the input text at the character level (e.g., swapping or inserting characters). However, discrete text perturbations frequently destroy the semantic meaning of benign prompts, severely degrading the model's general utility. Other defenses rely on separate, auxiliary LLMs to judge or paraphrase inputs, which introduces high computational costs and secondary security vulnerabilities.
The authors address this gap by proposing a defense that operates in the continuous embedding space rather than the discrete text space, aiming for a superior balance between robustness (stopping attacks) and utility (answering normal prompts correctly).
Methods
The authors propose RESTA (Randomized Embedding Smoothing and Token Aggregation), which consists of three core components:
- Embedding Perturbation: Instead of altering text characters, RESTA adds random noise directly to the continuous embedding vectors of the user's prompt. The authors explore four noise types: Isotropic Gaussian, Hard directional (scaling the embedding vector), Soft directional (element-wise scaling), and Orthogonal noise. Noise is strictly applied to the user content portion of the prompt, leaving system instructions untouched.
- Token-Level Aggregation: RESTA generates $k$ independent noisy samples of the input embeddings. During autoregressive generation, the LLM processes these $k$ samples in parallel to predict the next token. A majority vote across the $k$ outputs selects the final token, which is then embedded and appended to all parallel sequences for the next step.
- Response Prefix Smoothing: To minimize computational overhead, RESTA leverages the insight that jailbreak success is usually determined within the first few tokens of a response (e.g., if a model starts with "Sure, I can help...", it will likely proceed to output harmful content). RESTA applies parallel noisy aggregation only for the first $l$ tokens (e.g., $l=20$). Once this safe prefix is established, the defense deactivates, and the remaining response is generated via standard, single-stream autoregression.
Datasets
The defense was evaluated using the following resources:
- Models: Vicuna-13B (v1.5) and Llama-2-7B-chat.
- Attacks: GCG, PAIR, and Random Search (RS) attack prompt artifacts sourced from the JailbreakBench dataset.
- Utility Benchmarks: AlpacaEval (using GPT-4o to measure length-controlled win rates) and the Instruction-Following Evaluation (IFEval) benchmark (using prompt-level loose accuracy) to ensure benign performance is preserved.
Key Insights and Ideas
- The Power of the Prefix: Securing just the first 20 tokens is highly effective. By forcing the model to generate a refusal prefix (e.g., "Sorry, I cannot..."), the autoregressive nature of the LLM naturally maintains that safe sentiment for the rest of the unperturbed generation.
- Direction Matters in Embedding Space: Isotropic (normal) Gaussian noise quickly degrades model utility at higher intensities because it alters the vector's direction. In contrast, directional noise (hard or soft) primarily scales the vector along its existing orientation, preserving vital semantic information while still successfully disrupting adversarial token patterns.
- No Auxiliary LLM Needed: Operating entirely within the target model's continuous embedding space eliminates the need for secondary guard models or prompt-paraphrasing LLMs, reducing system complexity and latency.
Key Results
RESTA demonstrates a significantly better robustness-vs-utility tradeoff compared to character-level defenses like SmoothLLM:
- Against GCG on Vicuna-13B: An undefended model suffers a 94% Attack Success Rate (ASR). SmoothLLM drops the ASR to 7% but tanks benign utility (AlpacaEval score drops from 61.5% to 27.8%). RESTA (with hard directional noise at $\sigma=0.8$) reduces the ASR to 9% while maintaining a high utility score of 57.7%. At $\sigma=1.0$, it achieves a 2% ASR with 50.3% utility.
- Against PAIR on Vicuna-13B: SmoothLLM struggles, only reducing the ASR to 65.8% while degrading utility to 27.8%. RESTA ($\sigma=1.0$) successfully drives the ASR down to 30.4% while preserving 50.3% utility.
Limitations and Future Work
The authors present this work as an initial proof-of-concept with a few noted limitations:
- Attack Scope: The evaluation was restricted to established attack artifacts from JailbreakBench (GCG, PAIR, RS). The defense's resilience against newer or adaptive attacks specifically optimized to bypass embedding-level smoothing remains an open question.
- Comparative Evaluation: While RESTA clearly outperforms SmoothLLM, further comprehensive benchmarking against a wider variety of emerging inference-time defenses is required to fully map its competitive landscape.
Summary updated