← CS Lab AI & Machine Learning / Context Window Open standalone ↗

The context window is the fixed number of tokens a model can look at while it answers. Everything has to fit in one box: your prompt, the chat so far, the documents you pasted, and the reply being written.

Where you meet it

What it does

It sets the model's working memory. The window is not what the model learned during training — it's what it can see right now. Nothing outside the window influences the next token at all.

The window is working memory, not memory — it forgets everything between requests, and the chat history quietly eats the room left for the answer.

How it works

The window is a fixed token budget, and three things share it: the system prompt, the running conversation (every earlier turn), and the answer being generated. Each new turn is added to the input, so usage climbs turn after turn until the budget runs out. At that point old content is either evicted (chat UIs drop the oldest turns, first-in-first-out) or the request simply stops once generation hits the ceiling.

budget        = 200_000 tokens
system prompt =   1_200
chat history  = 180_000   # grows every turn
your question =     400
--------------------------------
left for reply ≈ 18_400 tokens   # shrinks as history grows

Why is it capped at all? Self-attention lets every token look at every other token, so cost scales ~O(n²) in the sequence length n. Double the context and the attention work roughly quadruples — that's the wall behind the token limit, not a storage problem.

Watch out

  • Lost in the middle. Models use the start and end of a long context well, but accuracy drops for facts buried in the middle (Liu et al.). Put the important stuff at the edges.
  • Full ≠ better. A bigger window costs more compute and latency, and recall degrades as it fills — Anthropic calls this context rot. Curate what goes in.
  • Chat history eats the budget. In a long session, old turns crowd out room for the answer. Summarise or trim instead of carrying everything.
  • A big window is not memory. It resets every request. For durable knowledge use RAG (retrieve only the relevant chunks) — don't stuff the whole corpus in.

Go deeper

Das Kontextfenster ist die feste Anzahl Tokens, die ein Modell beim Antworten sieht. Alles muss in eine Box passen: dein Prompt, der bisherige Chat, die eingefügten Dokumente und die Antwort, die gerade entsteht.

Wo es vorkommt

Was es tut

Es legt das Arbeitsgedächtnis des Modells fest. Das Fenster ist nicht das im Training Gelernte — es ist das, was das Modell gerade sieht. Was außerhalb liegt, beeinflusst das nächste Token überhaupt nicht.

Das Fenster ist Arbeitsgedächtnis, kein Gedächtnis — es vergisst alles zwischen Anfragen, und der Chat-Verlauf frisst leise den Platz für die Antwort.

Wie es funktioniert

Das Fenster ist ein festes Token-Budget, und drei Dinge teilen es sich: der System-Prompt, die laufende Konversation (jeder frühere Turn) und die Antwort, die generiert wird. Jeder neue Turn wird zum Input hinzugefügt, der Verbrauch steigt also Turn um Turn, bis das Budget aufgebraucht ist. Dann wird alter Inhalt entweder verdrängt (Chat-UIs werfen die ältesten Turns raus, First-in-first-out) oder die Anfrage bricht ab, sobald die Generierung an die Decke stößt.

Budget        = 200_000 Tokens
System-Prompt =   1_200
Chat-Verlauf  = 180_000   # wächst jeden Turn
deine Frage   =     400
--------------------------------
Rest für Antwort ≈ 18_400 Tokens   # schrumpft, je voller der Verlauf

Warum überhaupt gedeckelt? Self-Attention lässt jedes Token auf jedes andere schauen, die Kosten skalieren also ~O(n²) in der Sequenzlänge n. Doppelter Kontext heißt grob vierfacher Attention-Aufwand — das ist die Wand hinter dem Token-Limit, kein Speicherproblem.

Worauf achten

  • Lost in the middle. Modelle nutzen Anfang und Ende eines langen Kontexts gut, aber die Genauigkeit fällt für Fakten in der Mitte (Liu et al.). Das Wichtige gehört an die Ränder.
  • Voll ≠ besser. Ein größeres Fenster kostet mehr Rechenzeit und Latenz, und der Recall sinkt, je voller es wird — Anthropic nennt das Context Rot. Kuratiere, was reingeht.
  • Der Chat-Verlauf frisst das Budget. In langen Sessions verdrängen alte Turns den Platz für die Antwort. Lieber zusammenfassen oder kürzen statt alles mitzuschleppen.
  • Ein großes Fenster ist kein Gedächtnis. Es wird bei jeder Anfrage zurückgesetzt. Für dauerhaftes Wissen RAG nutzen (nur relevante Stücke holen) — nicht den ganzen Korpus reinstopfen.

Mehr dazu

Next up
AI & Machine LearningNext-Token Prediction AI & Machine LearningWord Embeddings All concepts →