LongRoPE: Extending LLM Context Window Beyond 2 Million Tokens
By Yiran Ding, Li Lyna Zhang, Chengruidong Zhang, Yuanyuan Xu, Ning Shang, Jiahang Xu, Fan Yang, Mao Yang. International Conference on Machine Learning, 2024
360 citations recorded by the source corpus.
Large context window is a desirable feature in large language models (LLMs). However, due to high fine-tuning costs, scarcity of long texts, and catastrophic values introduced by new token positions, current extended context windows are limited to around 128k tokens. This paper introduces LongRoPE that, for the first time, extends the context window of pre-trained LLMs to an impressive 2048k tokens, with up to only 1k fine-tuning steps at within 256k training lengths, while maintaining performance at the original short context window. This is achieved by three key innovations: (i) we identify and exploit two forms of non-uniformities in positional interpolation through an efficient search, providing a better initialization for fine-tuning and enabling an 8x extension in non-fine-tuning scenarios; (ii) we introduce a progressive extension strategy that first fine-tunes a 256k length LLM and then conducts a second positional interpolation on the fine-tuned extended LLM to achieve a 2048k context window; (iii) we readjust LongRoPE on 8k length to recover the short context window performance. Extensive experiments on LLaMA2 and Mistral across various tasks demonstrate the effectiveness of our method. Models extended via LongRoPE retain the original architecture with minor modifications to the positional embedding, and can reuse most pre-existing optimizations.
Subfields: Computer Vision and Pattern Recognition
View Paper: https://www.semanticscholar.org/paper/c9603ec967879c24973b5bd48861df2e5555932e
How researchers see this paper
The researchers whose trusted networks rank it highest, strongest advocate first. Every researcher gets a different order.
In Computer Vision and Pattern Recognition
- Fan Yang
- Bo Li
- Yuanhan Zhang
- Jingkang Yang
- Vishrav Chaudhary
- Harkirat Singh Behl
- Liang Wang
- Cyril Zhang
Citations in the corpus
- Long-context LLMs Struggle with Long In-context Learning (2024, neutral): “To systematically assess how these extended input capabilities affect model performance in the realm of fine-grained text classification with in-context learning, we have compiled a benchmark, i.e. LongICLBench , consisting of six carefully-selected tasks with different difficulty levels in terms of”
- PyramidKV: Dynamic KV Cache Compression based on Pyramidal Information Funneling (2024, methodology): “These models have recently been scaled up to handle long contexts [11, 7, 36, 4], with GPT-4 processing up to 128K tokens and Gemini-pro-1.”
- MInference 1.0: Accelerating Pre-filling for Long-Context LLMs via Dynamic Sparse Attention (2024, positive): “Experimental results on benchmarks such as InfiniteBench, RULER, language modeling, and Needle In A Haystack demonstrate that our method effectively maintains the long-context capabilities of LLMs while achieving up to a 10 × speedup, reducing the latency from 30 minutes to 3 minutes per prompt for…”
- Phi-3 Technical Report: A Highly Capable Language Model Locally on Your Phone (2024, methodology): “Specifically, we employed the long-rope method [DZZ + 24a] and a mixed context window approach to expand the context length limit from 4K to 128K without compromising performance on 4K-context tasks.”
- Long Context Transfer from Language to Vision (2024, methodology): “To alleviate that, various RoPE-based [65] extension techniques [13, 7, 61, 57, 20] have been proposed to allow for training-free context extrapolation.”
- RULER: What's the Real Context Size of Your Long-Context Language Models? (2024, neutral): “…proposed to improve length extrapolation in Transformers (Vaswani et al., 2017), including ALiBi (Press et al., 2022), xPOS (Sun et al., 2023b), and RoPE (Su et al., 2023) variants (Chen et al., 2023; Xiong et al., 2023; Peng et al., 2024; Liu et al., 2024b; Ding et al., 2024; Zhu et al., 2024).”
- Phi-4-Mini Technical Report: Compact yet Powerful Multimodal Language Models via Mixture-of-LoRAs (2025, neutral): “All models are based on decoder-only Transformer [VSP + 17] and support 128K context length based on LongRoPE [DZZ + 24a].”
- LongEmbed: Extending Embedding Models for Long Context Retrieval (2024, background): “Meanwhile, there have been many successes in extending context window of existing LLMs in a plug-and-play way or via efficient fine-tuning, pushing their context from 4k to 128k (Xiong et al., 2023) and even 2 million tokens (Ding et al., 2024).”