Abstract
In this study, we introduce RePD, an innovative attack Retrieval-based Prompt Decomposition framework designed to mitigate the risk of jailbreak attacks on large language models (LLMs). Despite rigorous pretraining and finetuning focused on ethical alignment, LLMs are still susceptible to jailbreak exploits. RePD operates on a one-shot learning model, wherein it accesses a database of pre-collected jailbreak prompt templates to identify and decompose harmful inquiries embedded within user prompts. This process involves integrating the decomposition of the jailbreak prompt into the user's original query into a one-shot learning example to effectively teach the LLM to discern and separate malicious components. Consequently, the LLM is equipped to first neutralize any potentially harmful elements before addressing the user's prompt in a manner that aligns with its ethical guidelines. RePD is versatile and compatible with a variety of open-source LLMs acting as agents. Through comprehensive experimentation with both harmful and benign prompts, we have demonstrated the efficacy of our proposed RePD in enhancing the resilience of LLMs against jailbreak attacks, without compromising their performance in responding to typical user requests.
Introduction
Large Language Models (LLMs) have demonstrated remarkable capabilities, yet they remain vulnerable to "jailbreak" attacks. These attacks employ sophisticated prompt engineering—such as role-playing scenarios, "Developer Mode" simulations, or complex encoding—to bypass safety filters and elicit harmful content. Most existing defenses suffer from either high false positive rates (refusing benign queries) or excessive computational costs due to expensive fine-tuning.
The core insight of the RePD (Retrieval-based Prompt Decomposition) framework is that jailbreak prompts typically consist of a malicious intent wrapped in a deceptive template. By teaching the model to explicitly decouple these two components, the model's inherent safety alignment can be re-activated to recognize and refuse the underlying harmful request.
Methodology
RePD utilizes a one-shot learning paradigm to guide the LLM through the decomposition process without requiring retraining. The framework follows a structured three-step workflow:
- Retrieval: Upon receiving a user prompt, the system queries a database of known jailbreak templates to identify the template that most closely matches the structure and style of the input.
- Prompt Decomposition: RePD constructs a meta-prompt that includes a "one-shot" example. This example demonstrates how a similar jailbreak prompt was previously decomposed into its template and its core harmful question.
- Decoupling and Response: The LLM is instructed to first identify and state the "real" question hidden within the user's prompt. By forcing this explicit isolation, the model's attention is shifted from the distracting template to the malicious intent.
To enhance robustness against adaptive attackers, the researchers also developed RePD-M, a multi-agent variant where one model performs the decoupling and another evaluates the response. Furthermore, a randomization strategy is employed in the defense templates to prevent attackers from predicting and circumventing the defense mechanism.
Experimental Evaluation
The efficacy of RePD was evaluated using several benchmarks, including ToxicChat for harmful prompts, a set of Benign Questions to test the False Positive Rate (FPR), and the SALAD Benchmark for categorizing various attack methodologies.
Key Results
The experimental results demonstrate that RePD significantly enhances LLM security while maintaining operational efficiency:
- ASR Reduction: RePD achieved an average 87.2% reduction in Attack Success Rate (ASR) across multiple models.
- Low False Positives: The framework maintained a low FPR (averaging 8.2%), ensuring that legitimate user requests are not unnecessarily blocked.
- Scaling and Robustness: Larger models (e.g., 70B parameters) showed superior performance in the decomposition task compared to smaller models (7B), indicating that reasoning capability is crucial for identifying deceptive templates.
Discussion and Conclusion
RePD offers a lightweight yet powerful defense against template-based jailbreak attacks. By leveraging the reasoning capabilities of LLMs through one-shot learning, it restores the model's "moral compass" that is often bypassed by complex prompt wrappers.
While highly effective, the framework does introduce some overhead in terms of token length due to the inclusion of retrieval templates and one-shot examples. Future work will focus on optimizing token efficiency and extending the framework to handle non-templated, emerging attack vectors. Overall, RePD represents a significant step toward building more resilient and ethically aligned AI systems.
Reference: Wang, P., Liu, X., & Xiao, C. (2024). RePD: Defending Jailbreak Attack through a Retrieval-based Prompt Decomposition Process. arXiv:2410.08660v3.
Summary updated