LESSON 3.7 · Lab · 100 min

Sampling is not a random button

Sampling is not a random button. Learn temperature, top-k, top-p, and repetition control and complete: Build a phase map of sampling parameters. Part of the “From Attention to GPT”

Learning objectives

  1. Explain what problem “Sampling is not a random button” solves without hiding behind terminology.
  2. Trace the variables and causal links across temperature, top-k, top-p.
  3. Complete “Build a phase map of sampling parameters” and judge the result with evidence rather than intuition.

Core concepts

temperature

temperature is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment before moving to an optimized implementation.

top-k

top-k is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment.

top-p

top-p is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment.

and repetition control

and repetition control is part of the lesson’s causal model. State its inputs, outputs, invariants, and failure mode; then verify it with a hand-check or a minimal experiment.

Build and verify

Build a phase map of sampling parameters

  • Predict: write the expected output, trend, or failure before running code.
  • Build: implement only the minimum components needed to answer the question.
  • Verify: compare with a baseline or trusted implementation; save seeds, parameters, and raw outputs.
  • Transfer: change one shape, dataset, scale, or workload condition and explain whether the conclusion still holds.

Open the complete interactive lesson