Context window
The context window of a large language model (LLM) is the maximum number of tokens that can be used by the model at one time when generating an output. It determines how much information, such as text from a conversation or document, the model can take into account when producing a response. Although context windows have grown substantially as LLMs have developed, research has shown that models do not necessarily use all the information within a large context window equally effectively.
Definition
[edit]The context window limits the combined number of input, output and reasoning tokens in a single model request.[1] Context windows are measured in tokens,[2] which are units produced by the model's tokenizer rather than words or characters. In practical terms, the context window determines the information available to the model when producing a response, which can include previous messages in a conversation.[3] Information outside the context window is not directly available to the model, but a process known as retrieval-augmented generation can retrieve information from external sources as additional context.[4] A longer context window can allow a model to work with longer prompts, conversations, documents, codebases, or retrieved passages without first compressing or discarding as much information.[5] It has been compared to working memory[6] or attention span.[7]
Increase in size and context rot
[edit]The practical size of context windows has increased rapidly as LLM systems have developed.[8] Some models are limited by the sequence lengths used during training, while attention variants and positional-encoding methods can allow models to operate on longer sequences than those seen during training.[9] Earlier large language models commonly used self-attention mechanisms whose computational requirements increased quadratically with sequence length, making longer context windows more expensive to process.[10] By the mid-2020s, long-context systems had reported context windows ranging from hundreds of thousands to millions of tokens; Google researchers reported Gemini 1.5 evaluations on retrieval tasks at up to 10 million tokens.[11]
Larger context windows tend to mean more coherent answers with fewer errors and hallucinations.[12] However, as context windows grow, there are often diminishing returns as a larger context window does not necessarily mean that a model can use the entire context equally well, sometimes called context rot.[13] In "Lost in the Middle", Liu et al.[14] found that performance on long-context tasks was often worse when relevant information appeared in the middle of an input rather than near the beginning or end.[15] Some studies indicate that the "effective context length" can be smaller than the advertised one, the former being the point in which the performance of the model starts to deteriorate when the answer isn't very easy to spot.[16] Other benchmarks have assessed long-context capability using tasks that go beyond simple retrieval, including multi-document question answering, long-dialogue understanding, code repository understanding, and structured-data reasoning.[17][18]
There are disadvantages of longer context windows including slower response times due to increased computational requirements,[19] reduced explainability of model outputs and higher costs associated with processing larger numbers of tokens.[20]
References
[edit]- ↑ "Conversation state | OpenAI API". OpenAI Developers. Retrieved 2026-10-01.
- ↑ Barkley, Warren (22 November 2024). "The Prompt: What is long context — and why does it matter for your AI?". Google Cloud Blog. Retrieved 10 October 2026.
- ↑ Guinness, Harry (2 October 2024). "What is a context window—and why does it matter?". Zapier.
- ↑ Richards, Ryan; Wilmott, Cal (April 2024). "Understanding LLM Context Windows: Implications and Considerations for AI Applications". Appen. Retrieved 12 October 2026.
- ↑ Ratner, Nir (2023). "Parallel Context Windows for Large Language Models". Proceedings of the 61st Annual Meeting of the Association for Computational Linguistics: 6383–6402. doi:10.18653/v1/2023.acl-long.352.
- ↑ Bergmann, Dave. "What is a context window?". IBM Think. IBM. Retrieved 8 October 2026.
- ↑ Maddula, Srujana (16 December 2025). "What is a Context Window for Large Language Models?". DataCamp. Retrieved 12 October 2026.
- ↑ Liu, Jiaheng; Zhu, Dawei; Bai, Zhiqi; He, Yancheng; Liao, Huanxuan; Que, Haoran; Wang, Zekun; Zhang, Chenchen; Zhang, Ge (2025-11-24), A Comprehensive Survey on Long Context Language Modeling, arXiv, doi:10.48550/arXiv.2503.17407, arXiv:2503.17407, retrieved 2026-10-01
- ↑ Smith, Noah A.; Lewis, Mike (2021). "Train Short, Test Long: Attention with Linear Biases Enables Input Length Extrapolation". Ofir Press. arXiv:2108.12409.
- ↑ Ndukwe, Nnenna (31 August 2025). "Understanding Context Windows: How It Shapes Performance and Enterprise Use Cases". Qodo. Retrieved 12 October 2026.
- ↑ Reid, Machel; Savage, Matej; Lee, Jason (2024). "Gemini 1.5: Unlocking multimodal understanding across millions of tokens of context". arXiv. arXiv:2403.05530.
- ↑ Bergmann, Dave. "What is a context window?". IBM Think. IBM. Retrieved 9 October 2026.
- ↑ "Context windows". Claude Platform Docs. Retrieved 2026-10-01.
- ↑ Liu, Nelson F. (2024). "Lost in the Middle: How Language Models Use Long Contexts". Transactions of the Association for Computational Linguistics. 12: 157–173. doi:10.1162/tacl_a_00638.
- ↑ Mabrouk, Mahmoud (16 July 2025). "Top techniques to Manage Context Lengths in LLMs". Agenta. Retrieved 12 October 2026.
- ↑ adobe-research/NoLiMa, Adobe Research, 2026-09-23, retrieved 2026-10-01
- ↑ Hsieh, Cheng-Ping; Sun, Simeng; Kriman, Samuel (2024). "RULER: What's the Real Context Size of Your Long-Context Language Models?". arXiv. arXiv:2404.06654.
- ↑ Bai, Yushi (2025). "LongBench v2: Towards Deeper Understanding and Reasoning on Realistic Long-context Multitasks". Proceedings of the 63rd Annual Meeting of the Association for Computational Linguistics: 3639–3664. doi:10.18653/v1/2025.acl-long.183.
- ↑ Walters, Andy (21 April 2025). "Long Context Windows in Generative AI: An AI Atlas Report". Emerge Haus. Retrieved 11 October 2026.
- ↑ "What is a context window?". McKinsey & Company. 5 December 2024. Retrieved 9 October 2026.