liveBook · Manning

Context window

As explained in Machine Learning Platform Engineering

A context window is the maximum amount of tokenized input and output that a language model can process in one interaction.

A context window is an LLM's finite working space for tokenized input and generated output. Its size constrains how much prompt, retrieved information, conversation history, and response content can fit into one interaction. section 12.1.1 section 12.2.2

Treat the window as an architectural budget rather than a headline model capability. Retrieval volume, chunk length, system instructions, user queries, and max_tokens compete for space. Exceeding the input limit fails the request; exhausting the output allocation can truncate a response mid-sentence. section 12.1.1

Plan context budgets by:

  • Limiting how many document chunks retrieval supplies and controlling their length. section 12.1.1
  • Reserving space for system instructions, the user query, and a complete generated response. section 12.1.1
  • Splitting complex work into focused, composable steps instead of sending an entire documentation corpus in one prompt. section 12.2.2

A retrieval budget

Fifty retrieved chunks at 500 tokens each consume 25,000 tokens. Adding a 2,000-token system prompt and a 100-token query uses 27,100 tokens, leaving roughly 5,000 tokens in a 32,000-token window for generation. section 12.1.1

How Machine Learning Platform Engineering covers it

How deep it goes
Explains token budgeting, failure modes, and decomposition, but stops short of model-specific implementation code.
Examples
Uses a 50-chunk RAG calculation, a 32K window, and model comparisons including GPT-4 Turbo, Claude 3.5 Sonnet, and Gemini.
What you can do after
Operate/configure retrieval and generation budgets to avoid request failures, truncation, wasted tokens, and degraded reasoning.
How it connects
Connects context windows to RAG, token budgets, prompt design, output limits, and composable LLM systems.

Also explained in

Compare how 22 books explain context window →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning Platform Engineering. The section links point to the parts of the book it draws on.