What is the context window of an LLM?
Same topic, related formats. Practice these next.
Same topic, related formats. Practice these next.
The context window is the hard ceiling on prompt plus completion tokens the model can attend to in one call, fixed at training by the positional encoding scheme.
Imagine a desk where you can lay out a finite number of index cards at once. Every card is a token: words from the question, the conversation so far, plus the answer being written. The desk has a strict edge. Once the cards run past that edge, nothing more fits. The model cannot peek beyond the desk because it was only ever taught to read positions inside it. If you want to feed it a longer document, you either trim cards off the back, group several cards onto one space, or stretch the desk using a special technique designed for that. The desk size is decided when the model is built, not when you ask it a question, and it bundles both what you say and what it replies into the same finite space.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
5 min: define context window as prompt plus completion cap, trace it to positional encoding, show the KV cache scaling consequence, name the three extension techniques, then close on RAG versus bigger windows as a product call.
Real products, models, and research that use this idea.
What an interviewer would ask next. Try answering before peeking at the approach.
Red flags and common mistakes that signal junior thinking. Click to expand.
Treating the context window as input-only. The cap covers prompt plus completion combined, so a long prompt eats the budget the model has left to actually answer.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.