Notes

Context Window

Every language model has a hard limit on how much text it can hold in mind at once. The context window is that limit, measured in tokens, and it covers everything in the request — the system prompt, the chat history, retrieved documents, the question, and the answer being generated.

Where the limit comes from

It is set at training time by the positional scheme the model learned and the sequence lengths it was trained on. Two costs enforce it: attention compares every token with every other, so compute grows roughly with the square of the length, and the KV cache that makes generation fast grows linearly with it, meaning long conversations consume GPU memory per user. That is why windows grew in steps rather than smoothly, from 2,048 tokens in GPT-3 to hundreds of thousands in current frontier models, and why techniques such as RoPE scaling exist to stretch a trained window after the fact.

What it feels like in practice
  • Overflow is not graceful: the oldest turns are dropped or the request is rejected, which is why a long chat appears to forget what you said at the start.
  • The advertised window and the usable one differ — accuracy sags for material buried in the middle of a very long context.
  • Cost and latency scale with what you put in it, so pasting an entire manual into every request is a real bill, not just a design choice.

A large window is what makes it possible to skip retraining entirely and simply show the model the document. That is the shift which moved most practical leverage out of the weights and into the prompt.

Context window is the maximum number of tokens a model can process in a single request, covering the system prompt, conversation history, retrieved documents and the generated answer together. It is fixed when the model is trained, and bounded by attention cost and KV cache memory. It sets the practical ceiling on how much a model can be shown instead of retrained — and when it overflows, earlier content is silently dropped.

Think of a desk with room for only so many sheets of paper. The assistant can read anything you put on that desk, but once it is full, something slides off the edge. The context window is the size of that desk. It holds the instructions the assistant was given, everything said so far in the conversation, any documents you pasted in, and the reply it is writing. This is why a long chat seems to forget what you mentioned at the beginning — not because it decided that was unimportant, but because the paper it was written on fell off the desk.