In plain words

Context window

How much text an AI model can keep in view at one time.

What it means

A context window is the maximum amount of information an artificial intelligence model can process in a single interaction. When people interact with a large language model, they send an input, such as a question or an entire document. The model reads this input and generates a response. The context window includes both the prompt provided by the user and the output created by the machine.

Artificial intelligence systems do not read words the way humans do. Instead, they break text down into smaller pieces called tokens. A token can be a single word, part of a word, or even a single character. For example, the word ‘cat’ is usually one token, while a longer word like ‘unbelievable’ might be split into three tokens. Because of this, context windows are measured in tokens rather than words or pages. If a model reaches the limit of its context window, it cannot see any information that came before that limit.

How it works

Large language models rely on a deep learning design known as the transformer architecture. Transformers use an internal mechanism called attention to evaluate how different tokens in a sequence relate to one another. When a model processes a sentence, the attention mechanism calculates mathematical scores between every token and every other token in the prompt. This helps the system understand grammar, facts, and meaning.

Processing information this way requires significant computer memory and processing power. In standard attention mechanisms, the computational cost grows quadratically as the number of tokens increases. This means that doubling the context window quadruples the memory and computation required to process it. To manage this cost, engineers use techniques like:

  • Sparse attention: Algorithms that allow the model to focus only on the most important tokens instead of comparing every single token to all others.
  • Positional encodings: Mathematical markers attached to tokens so the model knows their order in very long texts.
  • KV caching: A method where the model stores previously calculated key and value states in memory to avoid recalculating the entire prompt for every new token generated.

Once the prompt fills the context window, any older tokens are dropped from view. The model acts as if the dropped text never existed, which can cause it to lose track of earlier instructions or details.

A real example

Consider a developer building a tool to review corporate legal agreements. A standard commercial contract might be 50 pages long, which translates to roughly 25,000 tokens. If the developer uses a model with an 8,000-token context window, the model cannot read the full contract at once. The developer would have to split the contract into pieces, analyze each piece separately, and try to stitch the results together. This can lead to missed details, such as a clause on page 48 that overrides a rule on page 3.

If the developer upgrades to a model with a 128,000-token context window, the entire 50-page document fits comfortably inside a single prompt. The user can paste the full agreement, ask questions about specific risks, and receive answers based on the whole text. The model maintains awareness of all terms and definitions from the beginning of the document to the end.

Why it matters for builders and investors

For builders, the size of the context window determines what types of software products are feasible. A small window restricts applications to short chat prompts and brief summaries. A large window allows developers to build systems that analyze complete codebases, books, scientific papers, and financial filings without complex workarounds. However, larger windows demand more system memory. Builders must balance the benefit of a long window against the increased latency and server costs required to run it.

For investors, the context window is a key benchmark for evaluating artificial intelligence hardware and software companies. Expanding the context window efficiently is a primary engineering goal for model providers. Startups that create better memory management techniques, or hardware companies that build graphics processing units with larger memory capacity, often hold a strong competitive advantage. Context size directly impacts how much it costs to serve each customer request, which influences the profit margins of software companies using generative artificial intelligence.

Common mix-ups

People often confuse the context window with a model’s long-term memory or its training dataset. These are distinct concepts:

  • Context window vs. training data: The training data is the massive collection of text used to teach the model before it is released. The context window is simply the scratchpad the model uses during a live conversation. Information in the context window does not automatically become part of the model’s permanent knowledge base.
  • Context window vs. output limit: The total context window covers both the user’s input and the model’s reply. Most models have a separate, smaller limit on how many tokens they can generate in a single response, even if the total context window is very large.
  • Context length vs. retrieval performance: Just because a model has a huge context window does not mean it retrieves facts perfectly. Models can suffer from the ‘lost in the middle’ problem, where they struggle to find information hidden deep within a very long prompt compared to data at the very start or end.

Questions people ask

What is a token in artificial intelligence?

A token is a basic unit of text that an AI model processes. It can represent a single character, a whole word, or part of a word.

Does a larger context window make an AI model smarter?

Not necessarily. A larger context window lets the model read more text at once, but its reasoning ability still depends on its architecture and training.

What happens when a prompt exceeds the context window?

The model cannot accept the input or it cuts off earlier parts of the text. As a result, it ignores any information outside the limit.

Related wordstokeninference

Stories that use this word

Play and test yourself

Riddle of the day

Who or what am I?

I coat the living wires inside your head.

Solve itNew every day
Real or invented?

Spot the headline we made up

Five headlines. Four are real stories from this week. One is not.

Play nowA new round every day
Weekly quiz

How well did you follow the week?

5 questions. 2 minutes. Points for every right answer.

Take the quizNew every Monday
Prediction of the week

Will Northrop Grumman’s Cygnus XL successfully dock or berth with the ISS within 7 days?

Put free points on Yes or No and climb the leaderboard.

Make your callFor fun, no money