动态调整注意力权重,让大模型更准地处理长文本推理。
DySCO: Dynamic Attention-Scaling Decoding for Long-Context Language Models
- 用专用检索头识别关键信息,动态加权提升相关上下文影响力。
- 在128K上下文长度下,长文本推理任务最高提升25%准确率。
- 无需训练,适配任意现成大模型,且能解释注意力机制行为。
理解与推理长上下文是语言模型的关键能力。尽管当前模型支持越来越长的上下文窗口,但输入长度增加时性能常下降。实际中,模型难以在生成过程中保持注意力与最相关上下文对齐。本文提出DYSCO,一种新型解码算法,用于提升长上下文推理能力。DYSCO利用检索头——一组专用于长上下文检索的注意力头——在每一步解码时识别任务相关标记,并显式加强其权重。通过动态调整注意力,更好地利用相关上下文。该方法无需训练,可直接应用于任意现成语言模型。在多个指令微调和推理模型上,DYSCO在挑战性长上下文推理基准测试中持续提升性能,在128K上下文长度下,对MRCR和LongBenchV2的相对提升最高达25%,仅需少量额外计算。进一步分析表明,动态注意力重缩放与检索头引导选择对方法有效性均至关重要,同时提供了解码阶段注意力行为的可解释性洞察。代码已开源。
原文摘要 · Abstract (English)
Understanding and reasoning over long contexts is a crucial capability for language models (LMs). Although recent models support increasingly long context windows, their accuracy often deteriorates as input length grows. In practice, models often struggle to keep attention aligned with the most relevant context throughout decoding. In this work, we propose DYSCO, a novel decoding algorithm for improving long-context reasoning. DYSCO leverages retrieval heads--a subset of attention heads specialized for longcontext retrieval--to identify task-relevant tokens at each decoding step and explicitly up-weight them. By doing so, DYSCO dynamically adjusts attention during generation to better utilize relevant context. The method is training-free and can be applied directly to any off-the-shelf LMs. Across multiple instruction-tuned and reasoning models, DYSCO consistently improves performance on challenging long-context reasoning benchmarks, yielding relative gains of up to 25% on MRCR and LongBenchV2 at 128K context length with modest additional compute. Further analysis highlights the importance of both dynamic attention rescaling and retrievalhead guided selection for the effectiveness of the method, while providing interpretability insights into decoding-time attention behavior. Our code is available at https://github.com/princeton-pli/DySCO.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。