13. Why does `model.generate()` keep a KV cache?
- To store the vocabulary on the GPU
- To remember previous conversations across program runs
- To make sampling random
- To avoid recomputing keys and values for earlier tokens at every step
Show answer
Answer: To avoid recomputing keys and values for earlier tokens at every step
Each step only adds one token, so cached keys and values of earlier positions are reused instead of recomputed.
Lesson: How generate() Writes Text
14. What happens when you lower the sampling temperature from 1.0 to 0.3?
- The distribution sharpens, so the most likely tokens are chosen far more often
- The model generates fewer tokens
- Every token becomes equally likely
- Beam search is switched on
Show answer
Answer: The distribution sharpens, so the most likely tokens are chosen far more often
Dividing logits by a small temperature widens the gaps between them, so softmax concentrates probability on the top tokens.
Lesson: Decoding Strategies: Greedy, Sampling, Beams
15. What does `add_generation_prompt=True` add to a rendered chat prompt?
- A system message with safety rules
- The model's end-of-sequence token
- The marker that starts the assistant's turn, so the model replies instead of continuing the user
- A random seed for sampling
Show answer
Answer: The marker that starts the assistant's turn, so the model replies instead of continuing the user
It appends the assistant-turn header defined by the template, cueing the model to answer.
Lesson: Chat Models and Chat Templates