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

Yuhan Chen, Ang Lv, Jian Luan, Bin Wang, Wei Liu

Introduction

The rapid evolution of Large Language Models (LLMs) has pushed the boundaries of context length, necessitating robust mechanisms for handling long sequences. Traditional Positional Encodings (PEs), such as Rotary Position Encoding (RoPE) and ALiBi, have historically relied on the inductive bias of "long-term decay"—the assumption that token relevance naturally decreases with distance. While effective for short-range dependencies, this bias acts as a "straitjacket" in the era of Retrieval-Augmented Generation (RAG) and massive document analysis, where models must retrieve specific information (the "needle") from arbitrary positions within a large "haystack."

This paper introduces HoPE (High-frequency rotary Position Encoding), a novel scheme that removes forced decay to enhance context awareness and extrapolation capabilities far beyond training limits.

Methodology: Deconstructing the Long-Term Decay Bias

The researchers performed a "medical checkup" on RoPE by decomposing it into individual frequency components and tracking their influence on attention patterns during training. They identified two critical failure modes inherent in standard RoPE:

  1. The "Activated" Component Trap: Certain low-frequency components in RoPE dominate the attention pattern, creating a "U-shape" focus (where the model looks primarily at the very beginning and very end of a text). The model uses these components as a "shortcut," leading to poor optimization of semantic relationships.
  2. Extrapolation Failure: When the sequence length increases beyond training limits, these "activated" components produce out-of-distribution (OOD) values, causing the attention mechanism to hallucinate or fail entirely.
Analysis of RoPE frequency components showing how specific 'activated' components (red) dominate attention and fail during extrapolation beyond training limits (panel c).

The HoPE Solution

HoPE addresses these issues by surgically modifying the rotation mechanism. Instead of rotating every dimension of the hidden state, HoPE identifies and replaces the "doomed-to-be-activated" low-frequency components with position-independent ones. It retains only high-frequency signals, which provide sufficient "local texture" for the model to understand token order without imposing a global decay constraint. This hybrid approach allows the model to learn global attention patterns naturally through data rather than forcing them through rigid mathematical priors that break during extrapolation.

Experimental Results

HoPE was validated across several scales, including 3B parameter models trained on 500 billion tokens. The results demonstrate a clear "performance ceiling" lift over standard RoPE.

Needle-in-a-Haystack and Extrapolation

In the "Needle-in-a-Haystack" test, which measures retrieval accuracy from arbitrary positions, a 3B model trained on 8k tokens using HoPE maintained near-perfect accuracy up to 32k tokens. In contrast, the RoPE-based version began failing immediately after the 8k mark.

Needle-in-a-Haystack performance comparison. (a) RoPE shows rapid performance degradation (red) beyond the training limit, while (b) HoPE demonstrates significantly better extrapolation capabilities up to 32k tokens.

General Benchmarks and Efficiency

On the LongBench suite, HoPE outperformed RoPE in almost every category, particularly in multi-document QA (+4.5 points) and few-shot reasoning (+24 points). Furthermore, in "In-Context Copying" tasks, HoPE achieved an average score of 60.23, nearly tripling RoPE’s score of 23.80. Validation loss curves also indicated that HoPE converges to a lower loss than RoPE, suggesting it is inherently easier for the model to optimize.

Conclusion

HoPE represents a significant shift in positional encoding design, moving away from hardcoded decay toward flexible, high-frequency representations. By eliminating "shortcut" components that cause OOD failures, HoPE enables LLMs to achieve superior context awareness and robust extrapolation. Future work will focus on optimizing HoPE for high-performance kernels like FlashAttention and testing its scalability on 70B+ parameter models.

Summary updated

BibTeX
@inproceedings{chen2025hope,
  author = {Yuhan Chen and Ang Lv and Jian Luan and Bin Wang and Wei Liu},
  title = {{HoPE: A Novel Positional Encoding Without Long-Term Decay for Enhanced Context Awareness and Extrapolation}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2025},
}
Figure