TL;DR
HiRoute is an input-adaptive, hierarchical prompt-tuning framework that successfully balances large language model (LLM) safety with response helpfulness. By combining a globally shared coarse safety prompt with dynamically routed fine-grained prompt experts, it enforces a robust safety boundary while delivering risk-specific, constructive guidance without degrading general model utility.
What Problem Does This Paper Address?
Aligning LLMs to be safe usually involves a frustrating trade-off: either the model becomes overly conservative and responds with generic, unhelpful refusals (e.g., "I'm sorry, I can't help with that"), or it fails to handle complex, multi-risk queries effectively.
Parameter-efficient safety alignment methods like prompt tuning typically rely on a single global safety prompt or statically selected modules. These static designs struggle to maintain a firm safety boundary across diverse risk categories while simultaneously generating constructive, risk-specific alternatives—such as explaining why a request is dangerous or offering a lawful alternative. HiRoute bridges this gap by separating category-agnostic safety control from category-specific response guidance.
Methods
The authors introduce a decoupled, two-stage framework called HiRoute (Hierarchical Routed Prompt Tuning):
- Hierarchical Risk Routing: A lightweight Transformer encoder acts as a router. It extracts representations from a frozen LLM and feeds them into two heads: a coarse head to detect harmful intent (binary safe/risk) and a fine head that outputs multi-label risk scores across specific categories (e.g., cybercrime, privacy violations).
- Hierarchical Prompt Composition: If an input is flagged as risky, HiRoute dynamically constructs a composite prompt. This prompt combines a shared coarse-grained prompt (establishing a stable cross-category safety boundary) and a weighted mixture of fine-grained prompt experts scaled by the router's predicted risk distribution. Benign inputs bypass this safety branch entirely.
- Decoupled Optimization: Training is split into two stages to prevent the text-generation objective from shifting the risk decision boundary. First, the router is trained. Second, the prompts are optimized using Direct Preference Optimization (DPO) with an alternating gradient masking strategy to prevent the coarse and fine prompts from interfering with each other. The base LLM remains completely frozen throughout.
Datasets
- Router Training: Coarse-grained binary labels were sourced from WildGuardMix. Fine-grained category annotations came from PKU-SafeRLHF, covering four primary risk categories: cybercrime, economic crime, privacy violations, and violence.
- Prompt Tuning: The shared prompt was trained on 1,200 coarse safety preference pairs, while the fine-grained experts utilized 1,000 category-annotated preference triplets.
- Evaluation: Safety and helpfulness were evaluated using StrongReject, AdvBench, and JailbreakBench. General utility and over-refusal were measured via GSM8K (mathematical reasoning), MT-Bench (instruction following), TruthfulQA (factual reliability), and XSTest (over-refusal on benign prompts).
Key Insights and Ideas
- The Complementary Nature of Prompts: The authors discovered a clear trade-off: a single coarse prompt yields high safety but low helpfulness, while a fine-grained mixture yields high helpfulness but poor safety due to expert mismatch. Combining them hierarchically provides a robust fallback mechanism.
- Gradient Masking is Crucial: Alternating updates during DPO ensure that fine-grained experts learn specific guidance while the coarse prompt maintains the global boundary, preventing optimization interference.
- Dynamic Gating Slashes Over-Refusal: Allowing confidently safe prompts to completely bypass the safety prompt layer ensures that the model's standard capabilities and reasoning performance remain intact.
Key Results
- Superior Safety & Helpfulness: Across Mistral-7B, Vicuna-7B, and Zephyr-7B, HiRoute achieved the highest average safety rates (93.2%, 97.7%, and 94.8%, respectively) while outperforming baselines in safe-response helpfulness.
- Massive Over-Refusal Reduction: On Mistral, HiRoute dropped the XSTest over-refusal rate to just 2.5%, compared to 40.5% for Robust Prompt Optimization (RPO) and 18.0% for Directional Preference Optimization (DRO).
- Preserved Utility: HiRoute retained competitive performance on general benchmarks, keeping 48.0% GSM8K accuracy on Mistral compared to the base model's 51.0%.
Limitations and Future Work
- Router Dependency: The system's efficacy relies heavily on the router's accuracy; out-of-distribution or misclassified compound risks can lead to suboptimal prompt expert mixtures.
- Single-Turn Focus: The current implementation is evaluated primarily on single-turn text interactions, leaving multi-turn and multimodal settings underexplored.
- Future Directions: The authors suggest exploring open-set risk recognition, uncertainty-aware routing, and extending the hierarchical prompting framework to multi-turn dialogues and multimodal safety alignment.
Summary updated