AI Search
Context window
The context window is the maximum amount of text, measured in tokens, that an artificial intelligence model can process and hold in working memory during a single request.
// definition
A context window is not a permanent database or a model's trained weights; it is the temporary working memory limit of a Large Language Model during a single interaction. Expressed in sub-word units called tokens, this operational boundary includes both the incoming prompt and the generated response.
Every piece of data, such as system instructions, retrieved document text, and past conversational turns, must fit inside this allocation. Unlike training data that forms a permanent knowledge base, this working memory completely clears once a request finishes processing, retaining only the immediate information supplied for that specific operational run.
// why it matters
The capacity of a context window dictates how much information an application can evaluate simultaneously without losing essential data. Exceeding this boundary forces software to truncate content, causing dropped details and inaccurate outputs. Larger windows allow systems to evaluate entire documents or long chat transcripts in one step.
However, expanded memory capacity increases processing latency and computational resource expenses for every individual query. Product teams must carefully balance operational memory against processing speed and financial costs when configuring search and retrieval systems.
// example
A regional credit union deploys a search assistant to analyze a seven-page product manual during a member query. The prompt and manual text total six thousand tokens.
Because the assistant uses a model capped at a four thousand token context window, the application cuts off the trailing two thousand tokens. As a result, the assistant generates an answer based on incomplete information, omitting key safety instructions located at the end of the manual.
Questions and Answers
- How are tokens counted in a context window?
- Tokens represent sub-word text fragments, covering both the incoming prompt and the generated response. Everything sent during a request, including system instructions, retrieved document text, and past conversational turns, counts toward this allocation limit. If the total token count exceeds the window limit, trailing text is truncated.
- How does a context window differ from long-term memory?
- A context window acts as temporary working memory that completely clears after a request completes. In contrast, long-term memory or trained model weights serve as a permanent knowledge base. The context window only holds the immediate text explicitly provided during a specific processing run, rather than retaining data across multiple interactions.
- What happens when input text exceeds the context window?
- When input text exceeds the context window, the application must truncate the content to fit the allocation. This process drops trailing data, which forces the model to generate responses using incomplete information and leads to inaccurate outputs or missing instructions located near the end of the provided text.
