AI engineering · 25 of 42

Temperature & Top-p

The same distribution, read two ways

Scroll

The same distribution, read two ways

At each step the model produces a probability for every possible next token. Temperature and top-p decide how that distribution gets turned into an actual choice.

Temperature reshapes it: low values sharpen the peak so the likeliest token nearly always wins, high values flatten it so unlikely tokens get a real chance. Top-p works differently — it keeps only the most likely tokens until their probabilities sum to p and samples from those, so the long tail is removed entirely.

Neither makes the model more accurate. They change how often it takes a risk. Temperature 0 is not a truth setting; it just makes the same confident mistake every time, which is at least reproducible.

Generation
THE SAME DISTRIBUTION, READ TWO WAYS temperature 0.2 — the peak gets sharper mat floor rug sofa moon temperature 1.2 — it flattens mat floor rug sofa moon top-p 0.9: keep words until they sum to 0.9, then sample only from those — moon never appears Temperature reshapes the odds. Top-p truncates the tail. Neither makes the model smarter; both change how often it takes a risk.
The same five candidate words at low and high temperature, and the cut-off top-p applies.