How to Budget a Context Window So Prompt, History and Answer All Fit
Add up system prompt, history, retrieved documents and reserved output, then trim before the call fails.
WORKFLOW TAG
Check what fits in the input and output context for your model.
Add up system prompt, history, retrieved documents and reserved output, then trim before the call fails.
Start mlx_lm.chat for a terminal chat session where the conversation context is preserved for the life of the REPL.
Start vLLM with --max-model-len to cap the context window, trading long-document support for lower memory use.
Set --max-kv-size on an mlx-lm generation so a long prompt or long reply fits in the memory you have, at a known…
Give an Ollama model a longer context window with num_ctx when a long conversation or document gets cut off, using /set parameter…
Find out how many tokens the running model can actually hold before you paste a long document into it, so a summary…