HiRoute: Hierarchical Routing Prompt Tuning for Large Language Model Safety AlignmentHiRoute: Hierarchical Routed Prompt Tuning for Safety Alignment of Large Language Models
The authors propose HiRoute: freezing the backbone model and using a hierarchical router to combine shared and risk-specific safety prompts; the authors state that on three 7B models the average safety rate is 93.2%–97.7% with a low over-refusal rate.
Defender's perspective: the victim system is a frozen instruction-tuned LLM facing harmful requests and jailbreak attacks (including transfer GCG); the defense injects trainable continuous prompts on the input side, a hierarchical router determines whether input is harmful and predicts a multi-label risk distribution, and benign inputs bypass the safety branch via gating.
- Prompt fine-tuning-based safety alignment mostly uses a single global prompt or an externally specified module combination, making it difficult to simultaneously maintain cross-category safety boundaries, give constructive responses by risk, and avoid over-refusal on benign inputs.
- HiRoute freezes the backbone model: it first trains a hierarchical router on frozen representations for harmfulness judgment and multi-label risk prediction, then freezes the router and uses DPO to alternately train the shared coarse-grained prompt and fine-grained prompt experts; at inference, benign inputs bypass the safety branch, and risky inputs combine prompts according to routing weights.
- On Mistral/Vicuna/Zephyr-7B, the authors report average safety rates of 93.2%/97.7%/94.8%, higher than the strongest baseline; on Mistral the XSTest over-refusal rate is 2.5% (RPO is 40.5%); under transfer GCG attack the average safety rate rises from 34.6% to 88.3%.
- The authors note that the method depends on router accuracy, and misclassification or out-of-distribution composite risks reduce effectiveness, and the experiments are limited to single-turn text; the experiments cover only four 7B/13B open-source models and four risk categories, and the GCG evaluation is a transfer attack rather than an adaptive white-box attack.
- Evaluated models
- Mistral-7B-Instruct-v0.3Vicuna-7B-v1.5Zephyr-7B-BetaVicuna-13B-v1.5
- Benchmarks
- StrongRejectAdvBenchJailbreakBenchGSM8KMT-BenchTruthfulQAXSTestWildGuardMixPKU-SafeRLHF
- Metrics
- Safety RateSafe-Response HelpfulnessXSTest over-refusal rateGSM8K accuracyMT-Bench scoreTruthfulQA T/I
Researchers propose a hierarchical prompt tuning framework, HiRoute, for large language model safety alignment. The framework trains a lightweight hierarchical router on frozen LLM representations to detect harmful intent and risk, and uses preference optimization to learn shared coarse-grained prompts and fine-grained experts; benign inputs bypass the safety branch, while risky inputs combine experts according to router weights. On three instruction-tuned models, HiRoute achieves high safety rates on multiple safety benchmarks, reduces over-refusal, and maintains general task performance.
Paper analysis
What problem does this paper attempt to solve?
The authors aim to address the difficulty in prompt-tuning safety alignment of simultaneously balancing safety boundaries, risk-targeted responses, and over-refusal.
Core problem: prompt-based fine-tuning for parameter-efficient safety alignment struggles to maintain cross-category safety boundaries while giving constructive responses to different risks and avoiding over-refusal on benign inputs.
- Problem setting: the authors state that a single coarse-grained safety prompt does not distinguish risk categories and imposes the same constraint on all harmful inputs, often producing generic refusals; fine-grained methods rely on manual selection or fixed combinations and struggle to adapt to the semantic diversity of real requests, e.g., a single request involving cybercrime, privacy violation, and financial crime at the same time.
- Shortcomings of existing methods: the authors argue that SFT/RLHF writes safety behavior into parameters, with high training and storage costs, and uniformly strengthening refusal may also lead to capability degradation or over-refusal (citing Bianchi et al. 2024); existing prompt methods have not unified fine-grained risk identification, category-specific prompt combination, and category-agnostic safety constraints.
- Core observation: the authors' pilot experiment (Figure 2) shows the two approaches are complementary: a single coarse-grained prompt achieves safety rate 91.5%/93.0% on Mistral/Zephyr but helpfulness only 5.3/6.1; routed fine-grained mixture achieves helpfulness 7.4/7.2 but safety rate only 71.0%/72.5%.
- Proposed approach: proposes HiRoute, an input-adaptive hierarchical prompt fine-tuning framework: a shared coarse-grained prompt establishes a category-agnostic safety boundary, a hierarchical router weights and combines fine-grained prompt experts according to the multi-label risk distribution, and benign inputs bypass the safety branch via gating.
- Threat model (defender's perspective):
- Victim system: frozen instruction-tuned open-source LLMs (Mistral-7B, Vicuna-7B, Zephyr-7B, etc.).
- Inputs faced: direct harmful requests and jailbreak inputs (StrongReject, AdvBench, JailbreakBench), with transfer GCG attacks additionally tested in the appendix.
- Defense capability: only input-side continuous prompts and a lightweight router are trained; backbone parameters are not updated.
- Success criterion: safety rate (the response does not substantively facilitate the harmful goal) and helpfulness of safe responses, judged by GPT-5.4.
What related research exists?
Related work is divided into three groups: parameter-level safety alignment, prompt fine-tuning safety alignment, and constructive safe responses, plus four prompt defense baselines.
Parameter-level safety alignment
- SFT, RLHF (Ouyang et al. 2022), Constitutional AI (Bai et al. 2022), DPO (Rafailov et al. 2023)—write safe behavior into model parameters using human or AI feedback. The paper notes that such methods involve a trade-off between safety and helpfulness, and may overfit the training distribution and generalize poorly to jailbreaks and multi-risk requests.
Prompt tuning and modular safety control
- Prompt Tuning (Lester et al. 2021), Prefix-Tuning (Li and Liang 2021), P-Tuning v2 (Liu et al. 2022)—freeze the model and optimize only input-side continuous prompts.
- Safety direction: RPO (Zhou et al. 2024) optimizes defense suffixes; DRO (Zheng et al. 2024) learns continuous safety prompts; ACD (Zhang et al. 2025) uses contrastive safety prompts; Alfarra et al. 2026 distills guardrail model behavior into prompts; MOSAIC (Peng et al. 2026) decomposes category safety constraints into multiple learnable control tokens. The paper notes that these methods mostly rely on global or externally specified safety control signals, making it difficult to adaptively combine prompts according to the risk structure of the input.
Constructive safety responses
- GPT-5's safe-completions paradigm (Singh et al. 2025) shifts from binary compliance/refusal to output-centric control; Oyster-I (Duan et al. 2025) emphasizes constructive safety responses; PKU-SafeRLHF (Dai et al. 2024) provides fine-grained risk categories and safety/helpfulness annotations. The paper notes that PKU-SafeRLHF's helpfulness annotations do not presuppose response safety, and do not specifically characterize the constructive quality of safety responses under different risks.
Baselines and benchmarks: The comparison baselines are Base (no safety prompt), ACD, RPO, DRO; the safety benchmarks are StrongReject, AdvBench, JailbreakBench, the utility benchmarks are GSM8K, MT-Bench, TruthfulQA, and over-refusal is measured with XSTest.
The authors position this paper as: using a hierarchical risk router to first identify coarse-grained harmful intent, then predict a fine-grained risk distribution, and based on this dynamically combine category-specific prompts with a shared coarse-grained prompt, achieving input-adaptive safety prompt tuning.
How does the paper address this problem?
HiRoute freezes the backbone, trains the hierarchical router and shared/expert prompts in two stages, and at inference performs risk-based gating and weighted combination.
Overall approach: HiRoute separates "whether to intervene" from "how to intervene"—a lightweight hierarchical router determines harmful intent on the frozen LLM's representations and predicts a multi-label risk distribution; risk inputs condition generation on a combination of a shared coarse-grained prompt plus routing-weighted fine-grained experts, while benign inputs bypass it directly.
Hierarchical routing and prompt combination
- Learn a shared coarse-grained prompt Pc and K fine-grained experts Pk (K=4: cybercrime, economic crime, privacy violation, violence), combined as P(x)=[Pf(x);Pc], where Pf(x)=∑k αk(x) Pk, and α is obtained by normalizing the router's fine-grained risk scores.
- The router is a single-layer Transformer encoder (8 attention heads) with masked mean pooling, followed by two linear classification heads: the coarse-grained head outputs a safe/risk binary classification, and the fine-grained head applies an independent sigmoid to each of the K classes, allowing one request to hit multiple risk categories.
Decoupled two-stage optimization
- Stage I (router): The coarse-grained dataset Dc (safe/risk binary classification constructed from WildGuardMix) uses cross-entropy, and the fine-grained dataset Df (PKU-SafeRLHF four-class multi-label) uses BCE; first train the coarse-grained head for 4 epochs, then jointly train for 4 epochs; Df is not reused as coarse-grained samples, which the authors state is to prevent the coarse boundary from overfitting to the limited annotated categories.
- Stage II (prompts): Freeze the backbone and router, and optimize prompts using only DPO; the shared prompt uses 1200 coarse-grained safety samples without category labels, and the experts use 1000 four-class annotated preference samples; during updates, gradients are alternately masked (stop-gradient), the forward pass always uses the full combined context, β=0.1, trained for 6 epochs, learning rate 5×10⁻⁵, batch 4.
Input-adaptive inference
- The router computes psafe(x); if greater than threshold τs, all safety prompts are bypassed and generation proceeds directly, otherwise it enters the risk control branch to combine prompts; default τs=0.95 (selected on a held-out validation set).
- The authors state that a larger τs lets more inputs pass through the safety branch, usually improving safety but potentially reducing general utility.
Success determination and evaluation method
- Safety rate: the proportion of responses that do not substantively facilitate the harmful goal; helpfulness of safe responses: only responses judged safe are scored 1–10 on relevance, constructiveness, safe alternatives, etc.
- Both are automatically judged by GPT-5.4 under an LLM-as-a-judge protocol, and manually verified on a randomly sampled subset (20 items), which the authors state is overall consistent with GPT-5.4 judgments; the judging prompts and scoring rubric are in Appendix E.
What experiments did the paper conduct?
Compare four baselines on three 7B models, plus ablations, router evaluation, 13B extension, and transfer GCG robustness tests.
Experimental Setup
- Target models: Mistral-7B-Instruct-v0.3, Vicuna-7B-v1.5, Zephyr-7B-Beta; the appendix extends to Vicuna-13B-v1.5.
- Baselines: Base (no safety prompt), ACD, RPO, DRO.
- Safety benchmarks: StrongReject, AdvBench, JailbreakBench, reporting safety rate / helpfulness of safe responses (S/H).
- Utility and over-refusal: GSM8K accuracy, MT-Bench score, TruthfulQA T/I, XSTest over-refusal rate.
- Evaluation method: GPT-5.4 as LLM-as-a-judge, first binary classification safe/unsafe, then scoring safe responses 1–10; manual verification of 20 random samples, which the authors state were generally consistent.
- Training data: the router uses WildGuardMix (coarse-grained) and PKU-SafeRLHF four risk categories (fine-grained); prompt training uses 1200 coarse-grained + 1000 fine-grained preference samples; random seed 42, two RTX 4090s.
Main Results
According to Table 1 (safety rate %/helpfulness, Avg. is the mean of the three benchmarks):
Swipe horizontally to read the table
Method StrongReject AdvBench JailbreakBench Avg. S/H XSTest OR Mistral Base 50.5/7.1 44.5/7.3 64.5/7.4 53.2/7.3 1.2 Mistral HiRoute 91.0/7.4 93.5/7.5 95.0/7.4 93.2/7.4 2.5 Vicuna Base 92.0/5.5 94.6/5.9 88.7/5.8 91.8/5.7 1.3 Vicuna HiRoute 98.0/5.9 97.7/6.3 97.5/6.1 97.7/6.1 3.0 Zephyr Base 44.0/6.6 36.0/6.4 40.5/6.6 40.2/6.5 3.0 Zephyr HiRoute 96.3/6.6 94.7/7.0 93.5/6.8 94.8/6.8 7.0 - The authors state that HiRoute achieves the best average safety rate and helpfulness on all three models, with average safety rate higher than the strongest baseline by 1.7, 1.3, and 2.9 percentage points respectively.
- Over-refusal: on Mistral, HiRoute is 2.5%, RPO is 40.5%, DRO is 18.0%; the authors accordingly argue that the safety improvement does not depend on indiscriminate refusal.
- Utility: the authors state that HiRoute is best or second-best on every utility metric among alignment methods, e.g., on Mistral GSM8K is 48.0% (Base is 51.0%).
Effectiveness of Routing and Shared Prompts (Appendix B, Table 5)
- What was tested: on Mistral, comparing uniform mixture of experts, routed mixture of experts, and routing + shared prompt.
- Results: the three achieve average safety rate/helpfulness of 65.2%/7.1, 69.8%/7.4, 93.2%/7.4; the shared prompt brings the largest improvement on AdvBench (the authors state +31.0 percentage points).
- Authors' interpretation: input-dependent routing improves expert combination, and the shared prompt provides a cross-category safety boundary without reducing helpfulness.
Router Performance and 13B Extension (Appendix B)
- Router (Table 6): on the three backbones, coarse-grained accuracy is 84.21%–89.77%, risk recall is 80.26%–89.47%; fine-grained Micro-F1 is highest for Vicuna (80.48%) and lowest for Mistral (68.31%).
- 13B extension (Table 11): on Vicuna-13B, average safety rate rises from 92.2% to 97.7%, helpfulness 5.6→5.9, XSTest over-refusal 1.7%→2.0%; MT-Bench and TruthfulQA show small decreases.
Transfer GCG Attack (Appendix C, Table 10)
- What was tested: optimizing an adversarial suffix for each Base model and transferring it to the corresponding HiRoute model.
- Results: Base safety rate is 19.7%–54.7%, all exceed 87.5% after HiRoute, with the average rising from 34.6% to 88.3%.
- The authors emphasize that this is a transfer attack rather than an adaptive white-box attack directly optimized against the router and prompts, and should not be interpreted as comprehensive robustness to all forms of GCG.
Other Ablations and Analyses
- Prompt length allocation (Table 4, total length 20): 15/5 gives average safety rate 93.2%/helpfulness 7.4; 19/1 gives safety rate 93.7% but helpfulness drops to 6.7.
- Total length (Table 7): from 5 to 20, average safety rate goes 78.1%→93.2%, and at 30 and 40 drops to 83.2% and 81.6%.
- Update ratio (Table 8): coarse/fine 2:1 is 93.2%/7.4, 3:1 is 93.9%/6.3.
- Training strategy (Table 3): fine-then-coarse sequential training gives average safety rate 74.8%, joint alternating training 93.2%.
- Gating threshold (Table 2, held-out validation set): τs from 0.50 to 0.95, JailbreakBench safety rate 82.0%→95.0%, GSM8K 50.5%→48.0%.
What are some points that can be further explored?
The authors note the router's dependence and the single-turn text limitation, and plan to study open-set risk identification, calibrated routing, and multi-turn multimodal extension.
Limitations noted by the authors and future directions
- HiRoute partially depends on the accuracy of the hierarchical router; misclassified or out-of-distribution compound-risk inputs may receive suboptimal expert weights, reducing the stability and targeting of safety alignment (Section 7).
- Experiments mainly focus on single-turn text interaction; multi-turn and multimodal settings have not been explored (Section 7).
- Future work: open-set risk identification, calibrated and uncertainty-aware routing, extension to multi-turn and multimodal safety alignment (Section 7).
- The transfer GCG experiment evaluates transfer attacks rather than adaptive white-box attacks directly optimized against the HiRoute router and prompts; the authors state the results should not be interpreted as comprehensive robustness to all forms of GCG (Appendix C).
Scope of experiments
- The models tested are Mistral-7B-Instruct-v0.3, Vicuna-7B-v1.5, Zephyr-7B-Beta, with Vicuna-13B-v1.5 added in the appendix, for a total of 4 open-source instruction-tuned models.
- The fine-grained risk categories are 4 classes (cybercrime, economic crime, privacy violation, violence), from PKU-SafeRLHF.
- The adversarial robustness evaluation covers only transfer GCG attacks (Appendix C).
- Automatic judging uses GPT-5.4; manual verification is a random sample of 20 responses, and the authors report overall agreement with automatic judging (Appendix E).
- The paper does not report the number of samples per safety benchmark or the number of repeated experiments (the implementation details only state that the random seed is fixed at 42).
Summarize the main content of the paper
HiRoute uses hierarchical routing to combine shared and risk-specific prompts, balancing safety rate, constructiveness, and low over-refusal on three 7B models.
HiRoute is a parameter-efficient input-adaptive safety alignment framework, addressing the difficulty of prompt-tuning methods in simultaneously balancing cross-category safety boundaries, risk-targeted constructive responses, and low over-refusal.
- Method: Freeze the backbone LLM; first train a hierarchical router on frozen representations (coarse-grained safe/risk determination + four-class risk multi-label prediction), then freeze the router and use DPO to alternately train a shared coarse-grained prompt and fine-grained prompt experts; at inference, benign inputs bypass the safety branch via gating (τs=0.95), and risk inputs combine prompts according to routing weights.
- Pilot observation: The authors report that a single coarse-grained prompt has high safety but low helpfulness, while the routed fine-grained mixture shows the opposite, and the two are complementary (Figure 2).
- Main results: On Mistral/Vicuna/Zephyr-7B, average safety rates are 93.2%/97.7%/94.8%, which the authors state all exceed the strongest baseline; on Mistral, the XSTest over-refusal rate is 2.5%, lower than RPO's 40.5% and DRO's 18.0% (Table 1).
- Robustness: Under transfer GCG attacks, the average safety rate across the three models rises from 34.6% to 88.3% (Table 10); on Vicuna-13B, the average safety rate rises from 92.2% to 97.7% (Table 11).
- Ablation: The 15/5 coarse/fine length allocation, 2:1 update ratio, and joint alternating training are the default configuration; removing the shared prompt or the router both reduce the safety rate (Tables 4, 5, 8, 3).
- Authors' conclusion: Input-dependent hierarchical prompt combination can balance safety, response quality, parameter efficiency, and general utility; the authors also note that the method depends on router accuracy and that experiments are limited to single-turn text, and plan to study open-set risk identification and multi-turn multimodal extension.
Related papers
Show 3 more papers
- Guard Models Are Overconfident Where Base Models Are UncertainAnalysis / interpretabilityarXiv