Temperature and Sampling
In this article
- Explain how greedy decoding and sampling pick the next token from the same table of probabilities.
- Predict which way a lower or higher temperature moves a random pick, and why it changes nothing under greedy decoding.
- List the tokens that top-k and top-p keep from a table of probabilities.
- Explain why temperature, top-k and top-p change how varied replies are but not whether they are true.
- Terms defined here: decoding strategy, greedy decoding, sampling, temperature, top-k, top-p.
Overview
Ask a chat assistant the same question twice and the second answer is often worded differently. A language model writes a reply one small piece of text at a time, rating every piece it could write next. If it always chose the highest-rated piece, the same question would get the same reply every time. So the choice must be able to go another way.
Settings sent with a request, starting with one called temperature, steer that choice. As of 8 Nov 2026, the newest Claude and Gemini models keep them at the provider's defaults and still choose with those, so what follows still explains why their replies vary. [4,6,7]
Afterwards you can say how a piece is chosen, the top one every time or by a random draw, predict what a setting called temperature and two cut-off settings do to the draw, and explain why none of them changes what the model knows.
Sign in to keep reading
The rest of this article opens with an account. An account also keeps your progress and quiz results on every device, and lets you follow news for up to five topics.
Still to read in this article
- Greedy decoding and sampling
- Temperature: reshaping the table
- Top-k and top-p: cutting the table
- What the settings cannot change
- Sources
- Check yourself, 5 questions