# Context Window
The **context window** is the maximum amount of text (measured in [[Tokenization]]) that an AI model can process in a single interaction — both the input it receives and the output it generates. It defines the model's working memory: everything outside the context window is invisible to the model for that interaction.
Context windows have expanded dramatically: GPT-2 (2019) had 1,024 tokens (~750 words). GPT-3 had 4,096. GPT-4 offered 32K and later 128K. As of mid-2026, frontier models from Google (Gemini) offer 1M+ tokens, and Anthropic's Claude handles 200K tokens — enough to process entire novels, codebases, or intelligence dossiers in a single interaction.
## Why It Matters
Context window size determines what an AI system can do in practice:
**Small windows (4K–8K):** Suitable for short conversations, individual document summaries, simple code generation. Cannot maintain context across long documents or complex multi-step reasoning.
**Medium windows (32K–128K):** Can process entire reports, legal contracts, lengthy articles. Enables more coherent long-form generation and multi-document analysis.
**Large windows (200K–1M+):** Can ingest entire books, full codebases, archives of correspondence, or collections of intelligence reports. This scale transforms AI from a conversation partner into a document-processing system capable of analysis that would take human analysts days or weeks.
The military and intelligence significance is direct: a model with a 1M-token context window can process hundreds of intelligence reports simultaneously, identifying patterns across sources that no individual analyst could hold in mind. This capability is the foundation of systems like [[Palantir AIP]].
## The Cost Dimension
Context window expansion is expensive. The [[Attention Mechanism]] scales quadratically with context length — processing 1M tokens requires roughly 1,000× the compute of processing 32K tokens. This cost is borne at [[Inference vs Training]] time (every query), making long-context processing a significant operational expense.
[[RAG (Retrieval-Augmented Generation)]] (Retrieval-Augmented Generation) emerged partly as a workaround: instead of stuffing everything into the context window, retrieve only the relevant documents and feed those in. But as context windows grow larger and cheaper, the trade-off between RAG complexity and raw context stuffing continues to shift.
## KB Significance
1. **The intelligence multiplier.** Context window size directly determines AI's value for intelligence analysis, legal review, and document-heavy work. The expansion from 4K to 1M tokens is what transformed LLMs from chatbots into analytical engines capable of the document processing documented in the KB's defense-tech sections.
2. **The compute-cost driver.** Long-context inference is a major driver of the compute and energy demands documented in the [[The Quest for 90 Gigawatts]]. Every user query that processes a long document consumes proportionally more GPU time and electricity.
## See Also
- [[Attention Mechanism]] — Why context expansion is computationally expensive
- [[Tokenization]] — How text is measured for context windows
- [[RAG (Retrieval-Augmented Generation)]] — An alternative to massive context windows
- [[Inference vs Training]] — Where context-window costs are incurred