This research, presented at ACL 2024, investigates the internal "tug-of-war" within Large Language Models (LLMs) between the objectives of helpfulness and safety. By introducing a framework for "Goal Prioritization," the authors demonstrate a method to ensure safety takes precedence without compromising the model's overall utility.
The Conflict of Goals in LLM Alignment
Standard alignment techniques, such as Supervised Fine-Tuning (SFT) and Reinforcement Learning from Human Feedback (RLHF), typically train models to be both helpful and safe. However, these methods often fail to establish a clear hierarchy for when these two goals inevitably conflict. Jailbreaking attacks, such as the "DAN" (Do Anything Now) prompts, exploit this ambiguity by embedding harmful requests within "helpful" contexts—like roleplay scenarios or technical challenges. This tricks the model into prioritizing its helpful persona over its safety constraints.
The authors argue that models struggle with these attacks because they lack an explicit hierarchy of goals, particularly when encountering out-of-distribution (OOD) prompts that were not present during the initial alignment phase.
Methodology: Establishing a Priority Hierarchy
The paper proposes a two-pronged approach to implement "Goal Prioritization" depending on model accessibility:
1. Inference-Stage Defense (Black-Box Models)
For models where weights are inaccessible (e.g., GPT-4), the researchers utilize a "plug-and-play" prompting strategy:
- Explicit Priority Instructions: The model is explicitly instructed to prioritize safety over helpfulness in every interaction.
- Internal Thoughts: The model is forced to generate a hidden "chain-of-thought" analysis regarding the query's safety before formulating a final response. This acts as a cognitive buffer.
- Few-Shot Examples: Contrastive examples of safe versus unsafe responses are provided to guide the model's decision-making.
2. Training-Stage Defense (Open-Source Models)
For models with accessible weights, the authors employ Contrastive Training. They developed a dataset where queries are paired with conflicting instructions: "Prioritize Safety" and "Prioritize Helpfulness." * When instructed to "Prioritize Helpfulness" for a harmful query, the model is trained to provide the answer. * When instructed to "Prioritize Safety," it is trained to refuse.
This teaches the model to strictly follow the prioritization instruction itself. During deployment, the "Prioritize Safety" instruction is consistently appended to ensure the safety-first behavior.
Experimental Setup and Datasets
The framework was evaluated using a comprehensive suite of datasets:
- Jailbreak Test Set: 1,000 samples combining 50 jailbreak templates (roleplay, gradient-based, etc.) with 20 harmful questions.
- Wild Jailbreak Dataset: A broader evaluation set covering hate speech, malware, and privacy violations.
- XSTest: Used to monitor "exaggerated safety," ensuring the model does not become overly restrictive and refuse benign queries.
Key Results and Insights
The implementation of Goal Prioritization led to a dramatic reduction in Attack Success Rates (ASR) across various state-of-the-art models:
- GPT-4 (Inference-only): ASR dropped from 48.3% to 3.1%.
- ChatGPT (Inference-only): ASR plummeted from 66.4% to 3.6%.
- Llama2-13B (With Training): ASR was reduced from 71.0% to 6.6%.
The "Scaling Law" of Defense
A significant finding is that while more capable models (like GPT-4) are vulnerable to sophisticated jailbreaks, they are also easier to defend. Their superior instruction-following capabilities allow them to adhere more strictly to prioritization instructions than smaller models.
Generalization and Stability
The contrastive training method showed remarkable zero-shot generalization. Even without jailbreak samples in the training set, the method halved the ASR compared to standard models. Furthermore, general utility (measured via AlpacaEval and VicunaEval) remained stable, indicating that safety can be prioritized without "breaking" the model's intelligence.
Limitations and Future Directions
While effective, the approach has some drawbacks. Generating "Internal Thoughts" increases token overhead, leading to higher latency and costs. Additionally, like many safety mechanisms, it can trigger "false positives" (exaggerated safety) where benign queries are incorrectly refused. The authors also note that attackers may eventually attempt to "jailbreak" the prioritization instruction itself, necessitating ongoing red-teaming efforts.
Reference: Zhang, Z., Yang, J., Ke, P., Mi, F., Wang, H., & Huang, M. (2024). Defending Large Language Models Against Jailbreaking Attacks Through Goal Prioritization. Proceedings of the 62nd Annual Meeting of the Association for Computational Linguistics.
Summary updated