Skip to main content
QUICK REVIEW

[Paper Review] LongRoPE: Extending LLM Context Window Beyond 2 Million Tokens

Yiran Ding, Li Lyna Zhang|arXiv (Cornell University)|Feb 21, 2024
Image Processing and 3D ReconstructionComputer Science15 citations
TL;DR

LongRoPE introduces a non-uniform, evolution-guided RoPE rescale strategy to extend LLM context windows to 2048k tokens, with an efficient two-stage process and minimal fine-tuning. It preserves short-context performance and works with RoPE-based models like LLaMA2 and Mistral.

ABSTRACT

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.

Motivation & Objective

  • Motivate the need for much larger context windows in LLMs and identify barriers to extension beyond ~128k tokens.
  • Propose LongRoPE, a method leveraging two forms of non-uniform RoPE interpolation and an efficient search to extend context to 2048k without extensive fine-tuning.
  • Demonstrate effectiveness of LongRoPE on LLaMA2 and Mistral across perplexity, passkey retrieval, and standard benchmarks within short-context settings.

Proposed method

  • Identify two forms of non-uniformity in RoPE across dimensions and token positions.
  • Develop an evolutionary search to optimize per-dimension RoPE rescale factors and a starting-token threshold for interpolation.
  • Propose a progressive extension strategy: first extend to 256k/128k with RoPE rescaling, fine-tune briefly, then extend to 2048k with a second RoPE interpolation on the fine-tuned model.
  • Readjust RoPE at short context lengths to recover short-context performance.
  • Enable extension from 4k up to 2048k with minimal fine-tuning (1k steps) and a 256k training length in the second stage.

Experimental results

Research questions

  • RQ1Can RoPE interpolation be optimized beyond existing PI/NTK/YaRN strategies by using per-dimension non-uniform rescaling?
  • RQ2Is there an optimal starting-token count without interpolation to preserve key early-token information during extension?
  • RQ3Can a progressive, limited-finetuning workflow reach 2048k context windows without prohibitive training costs?
  • RQ4Does LongRoPE maintain performance on short-context benchmarks after ultra-long-context extension?

Key findings

  • Non-uniform RoPE dimensions and token positions show distinct interpolation needs, and optimizing per-dimension rescale factors improves perplexity at 8k–16k contexts.
  • An evolutionary search with monotonicity constraints yields better RoPE rescale factors than PI, NTK, or YaRN for extended contexts.
  • A progressive extension approach achieves 2048k context without direct long-text fine-tuning, requiring only brief fine-tuning steps at intermediate sizes.
  • Extending to 2048k can initially degrade short-context performance, which is mitigated by readjusting RoPE factors for short lengths.
  • LongRoPE-2048k models demonstrate competitive perplexity and passkey retrieval accuracy across books datasets and long-document evaluations, outperforming several baselines within 256k contexts.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.