提出无需训练的解码方法,解决多轮指令中角色优先级混乱问题
IHDec: Divergence-Steered Contrastive Decoding for Securing Multi-Turn Instruction Hierarchies

- 用JSD度量令牌级指令层级偏差,自动识别越权行为
- 动态对比解码压制低优先级指令,多轮场景效果优于微调方案
- 无需训练即可提升安全性,适合大模型部署场景
大型语言模型在处理多源输入时,常因角色优先级冲突而违背高层指令,出现下级指令覆盖上级的现象。现有防御方法多限于单轮场景且依赖昂贵微调。本文通过焦恩-申农散度(JSD)框架形式化多轮场景下的此失效模式,揭示普遍存在的角色影响力倒置现象。为在不训练的前提下修复该问题,提出IHDec(指令层级引导解码):利用JSD自动检测令牌级层级违规,并动态执行对比解码以抑制不符优先级的下级指令。大量实验表明,IHDec在多轮冲突中表现超越基于训练的基线,同时完全保持通用生成质量。此外,该方法增强了对对抗性提示注入的安全性,并与更大模型呈现稳健的缩放协同效应。代码已开源。
原文摘要 · Abstract (English)
Large Language Models (LLMs) often fail to maintain instruction hierarchies (IH) when processing multi-source inputs with varying role-level priorities, paradoxically adhering to lower-priority directives during conflicts. While existing defenses mitigate this issue, they are largely restricted to single-turn scenarios and require expensive fine-tuning. In this paper, we formalize this failure mode in multi-turn contexts via a Jensen-Shannon Divergence (JSD) framework, uncovering a pervasive role-influence inversion phenomenon where subordinate inputs override superior roles. To rectify this without training, we propose IHDec (Instruction Hierarchy-steered Decoding). IHDec leverages JSD to automatically detect token-level hierarchy violations and dynamically executes contrastive decoding to suppress misaligned subordinate roles. Extensive evaluations demonstrate that IHDec outperforms training-based baselines in multi-turn conflicts while fully preserving general response quality. Furthermore, IHDec strengthens safety against adversarial prompt injections and exhibits a robust scaling synergy with larger models. The Code is available at https://github.com/nxcolelxu/IHDec.git
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。