NEW
Also known as: Sequence Length, Token context
The maximum number of tokens a model can consider within a single prompt-response exchange.
DESCRIPTION
A model’s context window limits how much text it can condition on, typically measured in tokens. Larger windows enable longer documents and multi-turn reasoning but increase cost and latency. Practitioners use chunking, summarization, retrieval, and windowed attention to work within limits. Choosing the right window involves tradeoffs among quality, speed, and price.
ALTERNATIVE DEFINITIONS
Anthropic
The context window refers to the amount of text (measured in tokens) Claude can consider in a single request.
Defines the concept directly and notes token-based measurement.
OpenAI
Models have a context length limit which determines how many tokens are processed for a given prompt and completion.
Stresses prompt and completion combined within the token budget.
RELATED TERMS
Token Position Embeddings Rotary Embeddings Sliding Window Attention Long-Context Models Truncation Chunking Retrieval-Augmented Generation Attention Mechanism Memory
COMPETING TERMS
External Memory
KNOWLEDGE AREAS
TARGET AUDIENCE
AI Engineer Data Scientist MLOps Engineer Software Developer
EXTERNAL SOURCES
- Wikipedia - Transformer (machine learning)
- Anthropic - Explanation of long context
- OpenAI - Context length guidance
TOP QUESTIONS
Why does the Context Window matter for LLM applications?
It constrains how much information fits in a prompt, affecting reasoning and grounding. Exceeding it truncates inputs and harms quality.
Category: Relevancy
How can I handle content longer than the Context Window?
Use chunking, summarization, or retrieval to include only relevant parts. Sliding windows and chain-of-thought compression also help.
Category: HowTo
What’s a common mistake with Context Window usage?
Stuffing irrelevant context reduces signal-to-noise and increases cost. Curate content and provide references instead of raw dumps.
Category: Mistakes
Does a larger Context Window always improve performance?
Not necessarily. It can add latency and noise; retrieval plus a moderate window often performs better for targeted tasks.
Category: Opinion
How do position embeddings relate to the Context Window?
Position embeddings (e.g., RoPE) encode token order within the window. Extrapolation techniques can extend effective window size.
Category: Concept
What happens if inputs exceed the Context Window?
Models typically truncate tokens beyond the limit, potentially dropping critical information and degrading output quality.
Category: Risk
How does Context Window affect cost and latency?
More tokens increase compute and time. Optimizing prompt brevity and retrieval relevance reduces both.
Category: Performance
How do multi-turn conversations interact with the Context Window?
Conversation history consumes tokens. Summarize or selectively retain turns to keep crucial context.
Category: BestPractices
Are long-context models always better for RAG?
They help, but precise retrieval and ranking are more important. Long context is complementary to strong retrievers.
Category: Opinion