Skip to main content

Exercises — Autoregressive generation

Self-check questions, exercises, and worked answers

← Back to the lesson: Autoregressive generation

Check your understanding

Try to answer the following questions before revealing the explanations.

  1. Why can the same model with the same context produce different texts?
Show the answer

Because sampling can draw different tokens from the distribution. Each selected token then changes the context of subsequent predictions.

  1. Why does a very low temperature make sampling approach greedy selection?
Show the answer

It amplifies differences between logits. The distribution becomes highly concentrated on the highest-scoring token, making other choices very unlikely (except for ties and numerical effects).

  1. Why cannot generation correct a poorly trained model?
Show the answer

Parameters remain fixed during inference: no update takes place, no matter how many tokens are generated.

  1. What is the difference between prefill and teacher forcing?
Show the answer

Prefill is an inference phase: the known prompt is processed to produce the first generated-token distribution and, when enabled, populate the KV cache. Teacher forcing is a conditioning strategy: during training, the reference prefix is supplied as input and the logits are compared with shifted targets. A scoring computation can also use an observed prefix to evaluate a continuation with fixed parameters. Both uses condition predictions on known tokens under a causal mask, but prefill is an inference phase and does not compute a training loss.

Extended practice

For more practice, the Generation exercise collection provides worked calculations and guided traces on selection, the autoregressive loop, KV caching, temperature, and top-k/top-p filters.

Language: Français · English