Abstract Large Language Models' (LLMs) safety remains a critical concern due to their vulnerability to jailbreaking attacks, which can prompt these systems to produce harmful and malicious responses. Safety classifiers, computational models trained to discern and mitigate potentially harmful, offensive, or unethical outputs, offer a practical solution to address this issue. However, despite their potential, existing safety classifiers often fail when exposed to adversarial attacks such as gradient-optimized suffix attacks. In response, our study introduces Adversarial Prompt Shield (APS), a lightweight safety classifier model that excels in detection accuracy and demonstrates resilience against unseen jailbreaking prompts. We also introduce efficiently generated adversarial training datasets, named Bot Adversarial Noisy Dialogue (BAND), which are designed to fortify the classifier's robustness. Through extensive testing on various safety tasks and unseen jailbreaking attacks, we demonstrate the effectiveness and resilience of our models. Evaluations show that our classifier has the potential to significantly reduce the Attack Success Rate by up to 44.9%. This advance paves the way for the next generation of more reliable and resilient Large Language Models.
1. Introduction
Large Language Models (LLMs) have demonstrated remarkable capabilities but remain susceptible to "jailbreaking" attacks. These attacks utilize adversarial prompts—often containing optimized suffixes of random characters—to bypass safety guardrails and elicit harmful content. Traditional safety filters, such as the OpenAI Moderation API, frequently fail against these sophisticated, gradient-optimized perturbations. This paper presents the Adversarial Prompt Shield (APS), a robust and efficient defense mechanism designed to act as a front-end filter for LLMs.
2. Methodology
2.1 Adversarial Prompt Shield (APS)
The APS is a lightweight classifier based on the DistilBERT architecture (66M parameters). Its small footprint allows for low-latency deployment regardless of the target LLM's size. A key feature of APS is its support for multi-turn dialogue; by considering a context window of the last eight turns, the model can identify threats that are contextually dependent rather than just single-turn violations.
2.2 BAND Datasets
A major challenge in training robust classifiers is the computational cost of generating adversarial examples. To address this, we introduce Bot Adversarial Noisy Dialogue (BAND), a framework for efficient adversarial data generation:
- BAND Random: Involves appending random character strings to training prompts, teaching the model to ignore non-semantic "noise" often found in adversarial suffixes.
- BAND Pseudo: A "semi-optimization" technique that applies token substitutions across all modifiable locations in a single step. This method is approximately 55 times faster than standard Greedy Coordinate Gradient (GCG) attacks while effectively mimicking their structural properties for training purposes.
3. Experimental Results
The effectiveness of APS was evaluated against several benchmarks, including AdvBench and the Anthropic Red-Team corpus. The results highlight the model's superior defensive capabilities against state-of-the-art attacks.
As shown in the performance data, the APS Pseudo model achieved a near-total reduction in Attack Success Rate (ASR). For instance, against GCG attacks on the Vicuna-7B model, the ASR dropped from 25.0% to 0.0%. Similarly, for the Falcon model, the ASR was reduced from 44.9% to 0.0%. Furthermore, APS demonstrated strong generalization to unseen datasets, significantly outperforming existing baselines in multi-turn safety classification tasks.
4. Conclusion
The Adversarial Prompt Shield provides a scalable and effective solution for securing LLMs against adversarial jailbreaking. By utilizing the BAND training methodology, APS achieves state-of-the-art robustness without the need for expensive gradient-based data generation. Future work will focus on expanding the scope of adversarial perturbations to include mid-prompt and prefix-based attacks, ensuring safety against evolving jailbreaking techniques.
Summary updated