Stage 2 · Teens · Working with LLMs

Sampling Parameters

Temperature, top-p, and top-k, and how randomness is controlled at generation time.

When a model generates text, it doesn't always pick the single most likely next token. Several parameters control how much randomness is introduced:

Temperature scales the probability distribution before sampling — low values make the model more deterministic and repetitive; high values make it more random and creative (sometimes incoherent).

Sampling Temperature Playground
0.1 — deterministic2.0 — very random
mat
43.7%
floor
21.9%
sofa
14.6%
roof
9.4%
table
5.2%
ceiling
3.1%
moon
2.1%
Low temperature sharpens the distribution toward the top choice; high temperature flattens it, giving rarer words a real chance of being picked.
All lessons in Stage 2: How AI works