LongRoPE is a method for extending the context of pretrained language models that use RoPE. It determines, by search, how much to shrink the RoPE rotation angles for each dimension pair and each position. Proposed by Ding et al. at Microsoft Research in 2024, it extended the context of Llama 2 from 4096 tokens to 2048k (about 2.1 million) tokens. Earlier methods had reached only about 128k.
Position interpolation and YaRN compute the per-pair scaling with hand-designed rules. The LongRoPE paper showed that rule-based scaling is not optimal and that exploiting two further "non-uniformities" reduces information loss even more.
- Differences across dimension pairs: the optimal scaling differs by pair, and there are better combinations than the rule-based ones (position interpolation, NTK, YaRN)
- Differences across positions: the first few words of a sequence are better left at their original angles without scaling
By determining these two through search, LongRoPE can extend the context 8x even without fine-tuning. It then reaches 2048k through progressive extension, re-running the search on a model fine-tuned up to 256k, and finally re-searches the scaling for short contexts to recover performance at the original length.
The left side of the figure at the top of the article shows where position information is injected. It uses the same layout as the figures in the RoPE, position interpolation, and YaRN articles; only the way the rotation angles are shrunk differs. The upper right shows the search range for extending Llama 2 by 8x and the scaling of the three rules used as starting points for the search (position interpolation, NTK, YaRN). The values LongRoPE actually found are not given in the paper, so they are not drawn. The lower right shows how the first few positions are left unscaled.

