Abstract
While Large Language Models (LLMs) have achieved tremendous success in various applications, they are also susceptible to jailbreaking attacks. Several primary defense strategies have been proposed to protect LLMs from producing harmful information, mostly focusing on model fine-tuning or heuristical defense designs. However, how to achieve intrinsic robustness through prompt optimization remains an open problem. In this paper, motivated by adversarial training paradigms for achieving reliable robustness, we propose an approach named Prompt Adversarial Tuning (PAT) that trains a prompt control attached to the user prompt as a guard prefix. To achieve our defense goal whilst maintaining natural performance, we optimize the control prompt with both adversarial and benign prompts. Comprehensive experiments show that our method is effective against both grey-box and black-box attacks, reducing the success rate of advanced attacks to nearly 0%, while maintaining the model's utility on the benign task and incurring only negligible computational overhead.
Introduction: The Vulnerability of Alignment
Despite extensive safety alignment, Large Language Models (LLMs) remain vulnerable to "jailbreaking"—adversarial prompts designed to bypass safety filters and force the generation of prohibited content, such as instructions for illegal acts. Current defenses typically rely on expensive model fine-tuning or brittle, manually-written heuristic prompts (e.g., "You are a helpful assistant"). While fine-tuning is robust but costly, heuristic prompts are easily bypassed by mathematically optimized attacks.
Prompt Adversarial Tuning (PAT) seeks a middle ground: a defense that is as efficient as a prompt but as robust as fine-tuning.
Methodology: Prompt Adversarial Tuning (PAT)
Instead of altering model weights, PAT optimizes a sequence of tokens—a "defense control"—prefixed to every user prompt. The training process employs a min-min optimization framework inspired by adversarial training:
- Attack Phase: An "attack control" (suffix) is optimized to minimize the loss of a target malicious string (e.g., "Sure, here is how to build a bomb").
- Defense Phase: The "defense control" (prefix) is optimized to simultaneously minimize harm (ensuring the model refuses adversarial attacks) and maintain utility (ensuring high-quality answers to benign questions).
To navigate the discrete nature of text tokens, the authors utilize a Greedy Coordinate Gradient (GCG) strategy, identifying token substitutions that most effectively lower the loss based on model gradients.
Experimental Setup
The effectiveness of PAT was evaluated using several benchmarks:
- Advbench: 500 harmful prompts to measure Attack Success Rate (ASR).
- MS MARCO: Real-world benign questions to ensure functional integrity.
- MT-bench & MMLU: Standard benchmarks for general reasoning, coding, and knowledge capabilities.
Key Results and Insights
PAT demonstrates remarkable efficacy across various models and attack vectors. On Vicuna-7B, PAT reduced the average ASR of advanced attacks from 70.8% to just 1.8%.
Transferability and Utility
A significant finding is the transferability of PAT prefixes. A prefix trained on open-source models like Llama or Vicuna remains effective when applied to closed-source models like GPT-4, reducing the PAIR attack success rate from 34% to 2%.
Furthermore, PAT often maintains or even improves model performance on reasoning tasks (MT-bench). This "Utility Paradox" suggests that adversarial tuning might sharpen the model's focus, helping it ignore prompt noise.
The Nature of the Prefix
The optimized defense prefixes often manifest as "mojibake"—non-human-readable jumbles of characters. These are mathematically optimized to steer the model's internal latent space more effectively than natural language instructions.
Conclusion and Future Work
PAT offers a highly efficient, "plug-and-play" defense with negligible computational overhead. While it significantly raises the bar for attackers, the authors note that a white-box adaptive attacker with knowledge of the PAT prefix can still achieve some success (~20%). Future research will explore dynamic prefixes tailored to specific inputs and expanding training sets to cover complex ciphers and rare languages.
Summary updated