Gradient
Lesson 8.7ConceptModel~50 min

Sampling & temperature

How a model chooses its next word: greedy, temperature, top-k and top-p.

Module 8 · 0/8 done

From probabilities to text

A language model doesn’t write — it outputs a probability for every possible next token. Writing means repeatedly picking one, appending it, and asking again. How you pick is called decoding, and it dramatically changes what comes out.

  • Greedy: always take the single most likely token. Safe, but dull and prone to loops (“the the the”).
  • Sampling: pick randomly, in proportion to the probabilities. Varied and natural — but occasionally picks something absurd from the long tail.