IHDec: Divergence-Steered Contrastive Decoding for Securing Multi-Turn Instruction Hierarchies

TL;DR

IHDec uses JSD-based role attribution and contrastive decoding for real-time hierarchy correction, improving multi-turn instruction adherence by 11.98pp.

cs.CL 🔴 Advanced 2026-06-29 44 views
Nicole Geumheon Liu Haeun Jang Yonghyun Jun Hwanhee Lee
contrastive decoding instruction hierarchy multi-turn dialogue model safety training-free

Key Findings

Methodology

This paper introduces a Jensen-Shannon Divergence (JSD) based role influence attribution framework combined with dynamic contrastive decoding. It monitors role influence scores during inference, detects hierarchy violations, and applies logits adjustments to suppress subordinate role interference. The approach operates without model fine-tuning, relying on real-time divergence measurements to guide output correction. Extensive experiments on IHEval demonstrate that IHDec surpasses training-based baselines by 11.98 percentage points in multi-turn conflict scenarios, significantly enhancing instruction adherence and safety. The method also shows robustness against adversarial prompts and scales effectively with larger models, such as Qwen3-32B, where performance improves monotonically with model size.

Key Results

  • In multi-turn conflict environments, IHDec achieves an instruction hierarchy adherence rate of 70.96%, compared to 39.04% of the baseline, a gain of over 30 percentage points, validating its effectiveness in complex dialogues.
  • In adversarial prompt injection tests, IHDec improves safety accuracy to 54.3%, outperforming traditional methods by approximately 25 percentage points, demonstrating enhanced robustness.
  • Scaling experiments with Qwen3 models show that IHDec's performance increases with model size, with a maximum improvement of 27.8 percentage points on Qwen3-32B, indicating excellent scalability and adaptability.

Significance

This work addresses the critical challenge of maintaining instruction hierarchy in multi-source, multi-turn interactions without costly retraining. By introducing a real-time, inference-only correction mechanism, it significantly improves model safety, reliability, and compliance, paving the way for safer deployment of large language models in sensitive applications like customer service and automated assistance. Its model-agnostic design and scalability make it a versatile solution for advancing AI safety standards across diverse architectures and tasks.

Technical Contribution

The core technical innovation lies in leveraging JSD for role influence attribution, enabling the detection of hierarchy violations during inference. The contrastive decoding mechanism dynamically adjusts logits based on divergence measurements, effectively suppressing subordinate influence. This approach departs from traditional fine-tuning or prompt engineering, offering a lightweight, scalable, and model-agnostic solution that guarantees hierarchical compliance during generation, with theoretical and empirical validation.

Novelty

This is the first work to combine JSD-based influence attribution with dynamic, training-free contrastive decoding for real-time hierarchy enforcement in multi-turn dialogues. Unlike prior methods relying on costly fine-tuning or static prompts, IHDec offers a flexible, inference-only mechanism that adapts to complex multi-source inputs, filling a significant gap in current AI safety research.

Limitations

  • The accuracy of influence attribution depends on the clarity of role definitions; ambiguous roles may reduce effectiveness.
  • In highly adversarial or ambiguous scenarios, the divergence-based detection might be insufficient, requiring further robustness enhancements.
  • Real-time logits adjustment introduces additional computational overhead, potentially affecting response latency, especially in large models.

Future Work

Future research will focus on integrating reinforcement learning to optimize influence attribution dynamically, extending the framework to multi-modal inputs, and exploring more efficient divergence estimation techniques to reduce inference latency. Additionally, developing adaptive hyperparameters for diverse application contexts will further enhance robustness and generalization.

AI Executive Summary

Large language models (LLMs) have revolutionized natural language processing, enabling complex multi-source, multi-turn interactions. However, maintaining strict instruction hierarchies—where higher-priority directives override subordinate ones—remains a significant challenge, especially in multi-turn dialogues. Existing solutions often rely on costly fine-tuning or prompt engineering, which are limited in scalability and robustness. This paper introduces IHDec, a novel inference-time framework that leverages Jensen-Shannon Divergence (JSD) to quantify role influence during generation. By monitoring divergence scores, IHDec detects potential hierarchy violations at token level and dynamically adjusts logits through contrastive decoding, suppressing subordinate role interference. Extensive evaluations on the IHEval benchmark demonstrate that IHDec outperforms state-of-the-art training-based methods, achieving an 11.98 percentage point improvement in instruction adherence in conflict scenarios. It also enhances safety against adversarial prompts, with accuracy rising to 54.3%. The approach scales effectively with larger models, such as Qwen3-32B, where performance improves monotonically with size, reaching a 27.8-point gain. This method’s model-agnostic, training-free nature makes it highly practical for deployment across diverse architectures, offering a significant step toward safer, more reliable AI systems. Future work will explore reinforcement learning integration and multi-modal extensions, aiming to further improve robustness and efficiency in complex real-world applications.

Deep Analysis

Background

近年来,随着大规模语言模型(LLMs)在多源信息融合和复杂指令执行方面的突破,模型在单轮对话中表现优异,但在多轮对话中,指令层级(IH)维护成为瓶颈。传统方法多依赖微调或提示工程,成本高昂且难以适应长对话场景。研究发现,模型易受次级角色影响,导致安全风险和行为偏差。如何在不增加训练成本的情况下,实时检测并校正角色偏离,成为研究热点。本文在此背景下,提出基于JSD的角色影响归因机制,结合动态对比解码,旨在提升多轮对话中的指令遵循和安全性。

Core Problem

多轮对话中,模型容易被次级角色干扰,导致指令优先级失衡,表现为次级角色影响力超过主导角色。微调方案成本高且难以快速适应变化场景,提示工程缺乏鲁棒性。缺少实时、无训练调节机制,使得模型在复杂、多源、多角色环境中难以保证行为安全和一致性。如何在保证响应质量的同时,动态检测和校正角色偏离,成为核心难题。

Innovation

本文创新点包括:1)引入基于JSD的角色影响归因机制,量化角色对输出的影响力;2)设计动态对比解码策略,实时调节生成logits,抑制次级角色干扰;3)实现无训练、端到端的指令层级校正,兼容多模型架构。该方案突破了微调依赖,显著降低成本,提升多轮对话中的指令遵循能力,为模型安全提供新技术路径。

Methodology

  • �� 计算角色影响分数:利用JSD衡量完整上下文与去除特定角色后输出分布差异。
  • �� 识别偏离角色:根据影响分数,检测角色偏离,构建冲突集。
  • �� 实时调节:在解码过程中,计算对比偏差,动态调整logits,抑制偏离行为。
  • �� 影响归因:监测角色影响,确保层级优先关系,动态校正生成。
  • �� 超参数调节:通过β和衰减系数,平衡调节强度与响应速度。
  • �� 评估:在IHEval多轮冲突场景中,比较不同模型和方法的指令遵从率、安全性和扩展性。

Experiments

采用IHEval数据集,重点测试多轮冲突场景中的指令遵从性。基线包括微调模型和提示工程方法。指标涵盖指令层级遵守率、安全性指标和模型响应质量。超参数调节包括β值和衰减速率。通过消融实验验证影响归因和调节机制的有效性。多模型、多场景、多任务的评估确保方法的普适性和鲁棒性。

Results

IHDec在多轮冲突场景中达70.96%的指令遵从率,显著优于微调基线的39.04%,提升超过30个百分点。在安全性测试中,提示注入防御准确率提升至54.3%,比传统方法高出约25个百分点。模型扩展实验显示,结合Qwen3-32B,性能随模型规模线性增长,最大提升27.8个百分点,验证了其良好的扩展性和适应性。

Plain Language Accessible to non-experts

想象你在厨房做饭,有很多厨师在帮忙,每个人都告诉你该做什么。系统厨师是老板,最有权决定菜的味道;用户厨师是客人,提出各种需求;助手厨师是帮手,按照指令操作;数据厨师提供原料。每个厨师的指令都有优先级,但有时候,助手会听错,按照次要厨师的指令做事,导致菜变味。为了避免这种情况,厨房引入了一个智能助手,它能实时检测谁在说话,谁的指令更重要,然后调整厨师的指令,让菜保持原有味道。这样,厨房里每个人都能合作愉快,菜也更好吃。这就像论文里的模型,利用JSD检测角色偏离,动态调节生成内容,确保优先级正确,避免误操作。

ELI14 Explained like you're 14

想象你在学校里,有很多老师和同学在给你指示。老师是最重要的,他们说的话必须听从;同学是次要的,他们说的话可以忽略或听少一些。有时候,同学会说一些和老师相反的话,如果你只听信他们,就会搞砸事情。现在,有个聪明的朋友会在你听到指示时,马上判断谁说得更重要,然后帮你调整听到的内容,确保你听到的指令是正确的。这个朋友会用一种特别的方法,观察每个人的话对你做事的影响,及时提醒你该听谁的话,避免被次要的声音误导。就像论文里的方法一样,它用一种叫JSD的数学工具,实时检测谁在影响模型,然后调整模型的回答,让它始终遵循最重要的指令,保证对话的安全和正确。

Glossary

Jensen-Shannon Divergence (JSD) ( Jensen-Shannon散度)

一种衡量两个概率分布差异的对称指标,范围在0到1之间,越小表示越相似。

用于衡量模型输出分布在不同角色影响下的偏离程度。

角色影响分数 (Role Influence Score)

通过JSD计算的指标,量化每个角色对模型生成的影响力。

用以识别模型偏离指令层级的偏差。

对比偏差 (Contrastive Divergence)

一种调节生成分布的技术,通过比较不同条件下的输出分布,调整模型行为。

在本文中用于动态调节模型输出,抑制次级角色干扰。

指令层级 (Instruction Hierarchy)

定义不同角色在多源输入中的优先级关系,确保模型遵循安全和行为规范。

本文核心目标,保证模型在多轮对话中优先执行高优先级指令。

Open Questions Unanswered questions from this research

  • 1 如何在极端复杂场景中保持角色偏离检测的准确性仍需验证。
  • 2 模型在多模态、多源信息融合时,指令层级维护的适应性和效率有待研究。

Applications

Immediate Applications

多轮对话安全增强

在客服、智能助理中,实时检测并校正指令偏离,提升系统安全性与用户体验。

Long-term Vision

多模态交互系统

结合视觉、语音等多模态信息,构建更智能、更安全的多源交互平台,推动人机协作的智能化发展。

Abstract

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

cs.CL