Skip to main content
QUICK REVIEW

[Paper Review] Extending Context Window of Large Language Models via Positional Interpolation

Shouyuan Chen, S.H. Wong|arXiv (Cornell University)|Jun 27, 2023
Topic ModelingComputer Science44 citations
TL;DR

The paper introduces Position Interpolation (PI) to extend RoPE-based LLMs’ context windows up to 32768 tokens with minimal fine-tuning, maintaining performance on original tasks and enabling strong long-context modeling across multiple LLaMA model sizes.

ABSTRACT

We present Position Interpolation (PI) that extends the context window sizes of RoPE-based pretrained LLMs such as LLaMA models to up to 32768 with minimal fine-tuning (within 1000 steps), while demonstrating strong empirical results on various tasks that require long context, including passkey retrieval, language modeling, and long document summarization from LLaMA 7B to 65B. Meanwhile, the extended model by Position Interpolation preserve quality relatively well on tasks within its original context window. To achieve this goal, Position Interpolation linearly down-scales the input position indices to match the original context window size, rather than extrapolating beyond the trained context length which may lead to catastrophically high attention scores that completely ruin the self-attention mechanism. Our theoretical study shows that the upper bound of interpolation is at least $\sim 600 imes$ smaller than that of extrapolation, further demonstrating its stability. Models extended via Position Interpolation retain its original architecture and can reuse most pre-existing optimization and infrastructure.

Motivation & Objective

  • Extend the effective context window of RoPE-based LLMs (e.g., LLaMA) beyond training length.
  • Demonstrate that interpolating position indices, not extrapolating, yields stable attention and easier adaptation.
  • Show empirical benefits on long-context language modeling, retrieval-like tasks, and long-document summarization.
  • Assess the impact on performance within the original context window (2048) after extension.

Proposed method

  • Use Position Interpolation to down-scale input position indices so the maximum position matches the pre-training window.
Figure 1: An illustration of our Position Interpolation method. Consider a Llama model pre-trained with a 2048 context window length. Upper left illustrates the normal usage of an LLM model: input position indices (blue dots) are within the pre-trained range. Upper right illustrates length extrapola
Figure 1: An illustration of our Position Interpolation method. Consider a Llama model pre-trained with a 2048 context window length. Upper left illustrates the normal usage of an LLM model: input position indices (blue dots) are within the pre-trained range. Upper right illustrates length extrapola

Experimental results

Research questions

  • RQ1Can Position Interpolation extend RoPE-based LLM context windows to sizes such as 32768 tokens without architectural changes?
  • RQ2Does interpolated positioning provide a more stable and scalable extension than direct extrapolation for attention scores?
  • RQ3What are the empirical effects of PI on perplexity, passkey retrieval, and long-document summarization across LLaMA 7B–65B?
  • RQ4How does PI affect performance on tasks within the original 2048-token window?
  • RQ5What is the theoretical bound difference between interpolation and extrapolation for RoPE attention?

Key findings

  • PI can extend context windows up to 32768 with minimal fine-tuning (about 1000 steps) across LLaMA 7B–65B.
  • Interpolated attention scores are more stable, with an interpolation bound about 600× smaller than extrapolation in the LLaMA 7B setting.
  • Models extended with PI show perplexity improvements with longer context windows across PG19 and proof-pile datasets, unlike direct fine-tuning which regresses at longer contexts.
  • PI-extended models preserve original-context performance with only minor degradations on some benchmarks within 2048 tokens.
  • Passkey retrieval experiments indicate PI reaches the extended context as the effective context window after ~200 steps across 7B and 33B models.
  • For long-document summarization (GovReport), PI-enabled 16K context yields competitive ROUGE scores compared to baselines.
Figure 2: Extrapolation versus interpolation. Left: a fitted attention score function (in red) in the form of Eqn. 3 with $d=d_{\mathrm{model}}/n_{\mathrm{head}}=4096/32=128$ (setting of LLaMA 7B). Dots are random input points to be fitted and red curve is the fitted score function via least square,
Figure 2: Extrapolation versus interpolation. Left: a fitted attention score function (in red) in the form of Eqn. 3 with $d=d_{\mathrm{model}}/n_{\mathrm{head}}=4096/32=128$ (setting of LLaMA 7B). Dots are random input points to be fitted and red curve is the fitted score function via least square,

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.