# Context Window Extension

> Context window extension is a family of methods for making a pre-trained transformer handle sequences longer than those it was trained on, typically by rescaling its position encoding and briefly fine-tuning on longer text.

- Identifier: PTL-0259
- Category: Foundations
- Canonical URL: https://protologue.com/t/context-window-extension/
- Also known as: context extension, long-context extension, position interpolation, YaRN, RoPE scaling
- Introduced: 2023

## Description

Models using rotary position embeddings perform poorly beyond their training length. Chen et al. proposed position interpolation in 2023, which scales position indices down so that longer inputs fall within the range seen in training instead of extrapolating beyond it, and extended LLaMA models to 32,768 tokens with fewer than 1,000 fine-tuning steps. Peng et al.'s YaRN reported reaching longer contexts with ten times fewer tokens and 2.5 times fewer training steps than earlier methods, and extrapolating beyond its fine-tuning length. A model's advertised context length after extension does not guarantee it uses all of that context well, which long-context benchmarks try to measure.

## Broader terms

- [Context Window](https://protologue.com/t/context-window/)

## Related terms

- [Rotary Position Embedding](https://protologue.com/t/rotary-position-embedding/)
- [RULER](https://protologue.com/t/ruler/)
- [Needle in a Haystack](https://protologue.com/t/needle-in-a-haystack/)
- [Lost in the Middle](https://protologue.com/t/lost-in-the-middle/)

## Sources

- Chen et al. (2023). Extending Context Window of Large Language Models via Positional Interpolation. https://arxiv.org/abs/2306.15595
- Peng et al. (2023). YaRN: Efficient Context Window Extension of Large Language Models. https://arxiv.org/abs/2309.00071

## Cite this entry

Protologue. (2026). Context Window Extension. In Protologue: A Taxonomy of Prompting and LLM Techniques (v1.9.1, PTL-0259). https://protologue.com/t/context-window-extension/

License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)
