A working memory
A language model does not remember conversations the way people do. Each time it responds, it reads the entire conversation so far, plus any instructions and documents provided, and generates a reply based on all of it. The maximum amount of text it can read at once is called its context window. Anything outside the window, such as the start of a very long conversation, is effectively invisible to the model.
Measured in tokens
Context windows are measured in tokens, the small chunks of text that models process, which are often parts of words. In English, a token is on average roughly three quarters of a word, so 1,000 tokens is about 750 words. Languages such as Arabic may use more tokens per word, depending on the model's tokeniser. The context window includes both the user's input and the model's own output.
From pages to books
Early large language models had small windows. GPT-3, in 2020, could handle about 2,048 tokens, roughly a few pages. GPT-4, in 2023, offered versions with 8,000 and 32,000 tokens. In May 2023, Anthropic expanded Claude's window to 100,000 tokens, enough for a short novel. In February 2024, Google announced Gemini 1.5 with a window of up to a million tokens, later extended further in testing.
Why windows were small
Context windows were limited because of how transformers work. The attention mechanism compares every token with every other token, so the computing work and memory needed grow roughly with the square of the length: doubling the text quadruples the work. Researchers developed techniques to make attention more efficient, compress information and spread computation across many chips, making very long contexts practical.
New possibilities
Large context windows allow people to give AI entire documents, such as contracts, research papers, financial reports or books, and ask questions about them. Programmers can include large parts of a codebase so AI can understand how different files fit together. Long windows also allow AI agents to work on extended tasks, keeping track of many steps, tools and results, and let models learn from many examples provided in the prompt.
Lost in the middle
Having a large window does not guarantee that a model uses all the information well. A 2023 study found that models often performed better when relevant information appeared at the beginning or end of a long context than in the middle, an effect called lost in the middle. Tests such as the needle in a haystack, hiding a fact in a long document, measure recall. Newer models have improved but are not perfect.
Cost and speed
Processing very long contexts costs more and takes longer, because the model must handle many more tokens. Companies often charge by the number of tokens processed. To reduce costs, some services cache repeated parts of prompts, such as long instructions or documents used in many questions. Users and developers often find that giving AI only the most relevant information produces faster, cheaper and sometimes better answers.
Windows versus memory
Some chatbots now offer memory features that store information about users between conversations, such as preferences or past projects, and bring relevant details into the context window when needed. Retrieval-augmented generation similarly searches large collections of documents and places only relevant passages in the window. These approaches let AI draw on far more information than any single context window could hold.
Tips for users
When using AI for long tasks, it helps to provide clear, well-organised information, put key instructions near the beginning or end, and start a new conversation when switching topics, since very long conversations can confuse models or cause them to lose track of earlier details. Asking the AI to summarise progress periodically can also help keep long projects on track.
Why it matters
The context window determines how much information an AI can work with at once, shaping what tasks it can perform. Its rapid growth, from a few pages to entire libraries of text, has opened new uses in law, research, coding and business. Understanding context windows helps people use AI more effectively and understand why it sometimes seems to forget things.
Sources & further reading
- Anthropic · Introducing 100K context windows (2023) ↗
- Google · Our next-generation model: Gemini 1.5 (2024) ↗
- arXiv · Lost in the Middle: How Language Models Use Long Contexts (Liu et al., 2023) ↗
Context sizes vary by model and product and change frequently. Photograph: original AI-generated illustration (Adobe Firefly). Reference organisations do not endorse this website.


