The other dials — top-k & top-p.
Temperature bends the odds without ever removing a note. These two dials do something blunter — they throw the long shots out before the draw, so they can't be played at all.
Last page, temperature squeezed or stretched the odds across every candidate note, but it never took one off the table. Top-k and top-p take the other route to keeping a solo from wandering: before the soloist draws, they delete the least likely notes outright.
Top-k keeps only the k most likely notes and drops the rest. Set k = 2 and the soloist may reach only for its top two notes; everything below that is gone.
Top-p (also called nucleus) is smarter: it keeps the fewest notes whose odds add up to at least p. Set p = 0.9 and it keeps just enough of the top notes to cover 90% of the probability — only a couple when the ear is sure, more when it is torn.
Why "smarter"? Because it counts probability, not notes. If the ear were dead sure — say C at 85%, E at 10% — the same p = 0.9 would keep just C and E (already 95%) and drop the rest. If the ear were torn, the odds spread thin across many notes, it would keep six or seven to reach the 90% mark. A fixed top-k can't flex like that: k = 2 always keeps exactly two, whether the model is certain or hopelessly split.
The payoff is the same either way: the long tail of odd, out-of-key notes is gone before the draw, so it can't sneak into the line — while the natural variety near the top survives untouched.
Cut the tail with top-k or top-p and watch the unlikely notes drop away while the survivors share out the odds between them — then play a few draws and hear the difference.
Two more arguments on the call.
Like temperature, these are just settings you pass. They are usually combined — temperature to flatten the odds, top-p or top-k to lop off the tail.
Trim the tail, then draw.
Temperature reshapes the odds; top-k and top-p cut the unlikely notes out before the draw — a fixed number of them (k), or as many as it takes to cover a share of the probability (p). Whatever survives is re-scaled to 100%, and the draw happens only there. Tight dials give a safe, in-key line; loose ones let the odd spicy note — an Eb or a Bb — slip through.
In a real model these notes are tokens, and top-p — nucleus sampling — is the tail-trimmer most chat systems ship with, usually near 0.9. Temperature and the trimmer ride together: one sets how flat the odds are, the other decides how far down the list the draw may reach.