Raindrop lab · Glossary

context window

How to explain it

The most text a model can take in at once. Everything it is working from - the conversation so far, any documents it was given, and its own answer as it writes - has to fit inside.

The largest number of tokens a model can read in one go, counting both the prompt and the reply it is writing. Qwen3.5-4B's context window is 262,144 tokens, several long books' worth of text. Once a conversation outgrows the window, something has to go: usually the app around the model drops the oldest text, which the model then never sees.

The limit comes from two places. One is training: a model is trained on texts up to some length, with a way of marking each position, and is not expected to work beyond it. The other is memory when the model runs: in a layer with full attention, every token read leaves keys and values behind for later tokens to look back at, so the memory needed grows with the text. A hybrid model such as Qwen3.5-4B, with its window of 262,144 tokens, keeps that growing record on only some of its layers, which is part of what makes a long window affordable.

Qwen3.5-4B's config sets max_position_embeddings to 262,144 (2182^{18}). Lesson 4's probe measured the memory a text leaves in the model's cache: 16,384 numbers a token across the 8 full-attention layers, and a fixed 12,582,912 across the 24 linear-attention layers. A full window would therefore leave 4,294,967,296 numbers of keys and values, about 8.6 GB at 2 bytes each, against 2.37 GB for the 4-bit model's own weights; with full attention in all 32 layers it would be four times that. The window is a limit on what can be read, not a promise about what is used: how well a model recalls from far back in a long context is a separate, measured question.

The window is all the model has to go on, besides what it learned in training. It does not remember earlier conversations unless their text is put back inside the window.

A context window is not a memory that lasts. The model's own numbers do not change as it reads, so when a conversation ends nothing of it stays in the model. For the model to "remember" something later, the text has to be placed in the window again.

What a model knows comes from two sources: its weights, fixed after training, and the context it is reading now. Systems that seem to remember across sessions do so by storing text outside the model and writing it back into the window; reading a text does not alter the weights.

Inference leaves the weights untouched; all state that depends on the text lives in the per-layer caches (keys and values, and the linear-attention layers' recurrent states), which are discarded with the context. Persistent "memory" in deployed systems is retrieval into the context, not a change to the model.