arXiv:2410.21216cs.CLcs.AI2024-10ACL被引 19

提出新型位置编码HoPE,突破长距离衰减限制,提升大模型上下文感知与外推能力。

HoPE: A Novel Positional Encoding Without Long-Term Decay for Enhanced Context Awareness and Extrapolation

  • 用高频旋转编码替代原有组件,打破长距离信息衰减假设
  • 实验显示在4096以上序列长度下注意力分布更均匀,外推性能显著提升
  • 适合需要精准定位长文本信息的场景,如法律、医疗文档分析

许多位置编码基于长期衰减假设,认为远离当前位置的词元信息相关性更低。我们通过实证分析发现,大模型实际学习到的是局部衰减、全局呈U型的注意力模式,与长期衰减相悖。进一步分析发现,旋转位置编码(RoPE)中的部分可学习成分导致了这种U型模式,也限制了其表达能力和外推性能。受此启发,我们提出高频旋转位置编码(HoPE),将RoPE中特定组件替换为与位置无关的结构,仅保留高频信号,理论上打破了长期衰减原则。实验表明,HoPE能有效消除长期衰减带来的矛盾因素,提升模型对上下文信息的感知能力与外推性能,在4096以上序列长度上表现优异。

原文摘要 · Abstract (English)

Many positional encodings (PEs) are designed to exhibit long-term decay, based on an entrenched and long-standing inductive opinion: tokens farther away from the current position carry less relevant information. We argue that long-term decay is outdated in the era of LLMs, as LLMs are now applied to tasks demanding precise retrieval of in-context information from arbitrary positions. Firstly, we present empirical analyses on various PEs, demonstrating that models inherently learn attention with only a local-decay pattern while forming a U-shape pattern globally, contradicting the principle of long-term decay. Furthermore, we conduct a detailed analysis of rotary position encoding (RoPE, a prevalent relative positional encoding in LLMs), and found that the U-shape attention is caused by some learned components, which are also the key factor limiting RoPE's expressiveness and extrapolation.Inspired by these insights, we propose High-frequency rotary Position Encoding (HoPE). HoPE replaces the specific components in RoPE with position-independent ones, retaining only high-frequency signals, which also breaks the principle of long-term decay in theory. HoPE achieves two major advantages: (1) Without constraints imposed by long-term decay, contradictory factors that limit spontaneous attention optimization and model extrapolation performance are removed. (2) Components representing positions and semantics are are optimized. These enhances model's context awareness and extrapolation, as validated by extensive experiments.

位置编码大模型注意力机制外推能力

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。