Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMs

Xiaoran Liu, Yuerong Song, Zhigeng Liu, Zengfeng Huang, Qipeng Guo +4 more
12/8/2025
cs.CL

Official code: OpenMOSS/rope_pp (33 stars, last commit 2025-12-09).

Abstract

Rotary Position Embeddings (RoPE) have become a standard for encoding sequence order in Large Language Models (LLMs) by applying rotations to query and key vectors in the complex plane. Standard implementations, however, utilize only the real component of the complex-valued dot product for attention score calculation. This simplification discards the imaginary component, which contains valuable phase information, leading to a potential loss of relational details crucial for modeling long-context dependencies. In this paper, we propose an extension that re-incorporates this discarded imaginary component. Our method leverages the full complex-valued representation to create a dual-component attention score. We theoretically and empirically demonstrate that this approach enhances the modeling of long-context dependencies by preserving more positional information. Furthermore, evaluations on a suite of long-context language modeling benchmarks show that our method consistently improves performance over the standard RoPE, with the benefits becoming more significant as context length increases. The code is available at https://github.com/OpenMOSS/rope_pp.

View on arXivView PDF

Code Implementations(1)

OpenMOSS/rope_ppOfficial100%

[ICLR26] Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMs

333Shell, PythonDec 8, 202510 months ago

Similar Papers

Cite this paper

@article{liu2025beyond,
  title  = {Beyond Real: Imaginary Extension of Rotary Position Embeddings for Long-Context LLMs},
  author = {Xiaoran Liu and Yuerong Song and Zhigeng Liu and Zengfeng Huang and Qipeng Guo and Zhaoxiang Liu and Shiguo Lian and Ziwei He and Xipeng Qiu},
  year   = {2025},
  eprint = {2512.07525},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2512.07525v1}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2512.07525.svg)](https://codeofpaper.com/paper/2512.07525)

Discussion