Decoding and constraints / 5 of 9
Context windows and memory
What you’ll learn
- Explain the main idea of “Context windows and memory” in your own words.
- Trace a concrete example and identify the assumptions behind it.
- Apply the principle in a practice problem and recognize a common failure.
The idea, intuitively
The context window bounds how many tokens a model can consider in one invocation. Prompt instructions, conversation history, retrieved documents, and generated output can compete for this budget. Application memory is separate from model context.
Separate what a model learned during training from what an application supplies at runtime. Generation settings change how outputs are selected, while architecture and precision affect resource needs. The labs use small transparent calculations so you can understand mechanisms without downloading a model or calling an API.
Under the hood
Track token budgets with the correct tokenizer. Truncation strategies, retrieval, and summarization can manage long inputs, but may discard crucial details. A model accepting long context does not guarantee equal use of every position.
A larger context window does not make untrusted documents into trusted instructions.
A worked example
For a shared 8,000-token budget with 1,000 reserved output tokens, leave at most 7,000 for inputs under that model’s accounting rules.
How to use this way of thinking
Compare one setting at a time using fixed inputs and a written quality rubric. Record the checkpoint, tokenizer, decoding options, and hardware. Report failures and resource costs alongside successful examples. Do not infer factual reliability from confidence, fluency, or parameter count alone.
Try it yourself
A critical instruction is lost after truncation. What could you change?
Key takeaways
- Retrieved document text
- A larger context window does not make untrusted documents into trusted instructions.
- Check the assumptions with a small example before applying this idea to a larger system.
Check your understanding
Use feedback to learn. Quiz scores and lesson completion are tracked separately.
Go to lesson completionFurther reading
Original papers and reference material for this school. External resources may be in English and require internet access.
Hugging Face: generation configuration (opens a new tab)llama.cpp project (opens a new tab)Finish this lesson
Mark this lesson complete when you’re ready to continue.