通过分层路由实现安全对齐,让大模型精准识别风险并灵活回应。
HiRoute: Hierarchical Routed Prompt Tuning for Safety Alignment of Large Language Models

- 分层路由动态判断输入风险,分离通用安全控制与具体响应引导。
- 在多个安全基准上达到高防护率,同时减少误拒正常请求。
- 适合需要高安全性和响应灵活性的对话系统研发者使用。
大型语言模型仍易受有害请求和越狱攻击影响。基于提示调优的参数高效安全对齐方法通常依赖单一全局提示或外部选定的提示模块,这类静态设计难以在生成针对性回复的同时维持跨类别安全边界,并容易过度拒绝良性输入。为此,我们提出HiRoute,一种输入自适应的分层提示调优框架,将无类别依赖的安全控制与类别特定的响应引导相分离。HiRoute首先在冻结的LLM提取的表示上训练一个轻量级分层路由,联合检测有害意图并预测多标签风险分数。随后冻结主干模型与路由,采用交替梯度更新的偏好优化学习共享粗粒度提示和一组细粒度提示专家作为连续嵌入。推理时,良性输入绕过安全分支,而风险输入则结合共享提示与路由加权的风险特异性提示专家混合体进行处理。在三个指令微调模型上的实验表明,HiRoute在多个安全基准上实现高安全率,同时保持安全回复的有用性,降低过度拒绝现象,并在通用任务上保持竞争力。
原文摘要 · Abstract (English)
Large language models (LLMs) remain vulnerable to harmful requests and jailbreak attacks. Parameter-efficient safety alignment methods based on prompt tuning typically rely on a single global prompt or externally selected prompt modules. Such static designs struggle to maintain a cross-category safety boundary while generating constructive responses tailored to specific risks and avoiding over-refusal of benign inputs. To address these limitations, we propose HiRoute, an input-adaptive hierarchical prompt-tuning framework that separates category-agnostic safety control from category-specific response guidance. HiRoute first trains a lightweight hierarchical router on representations extracted from a frozen LLM to jointly detect harmful intent and predict multi-label risk scores. It then freezes both the backbone model and the router and uses preference optimization with alternating gradient updates to learn a shared coarse-grained prompt and a set of fine-grained prompt experts as continuous embeddings. At inference time, benign inputs bypass the safety branch, whereas risky inputs are processed using the shared prompt together with a router-weighted mixture of risk-specific prompt experts. Experiments across three instruction-tuned models show that HiRoute achieves high safety rates across multiple safety benchmarks while preserving safe-response helpfulness, reducing over-refusal, and maintaining competitive performance on general-purpose tasks.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。