Skip to the workspace
Pebellslearn by building
Controlling the Output  ›  Lesson

Temperature — The Randomness Dial

Temperature 12 minTemperature reshapes the next-token probabilities: low values make output focused and repeatable, high values make it varied and riskier.

prompt engineering / Temperature — The Randomness Dial

Explore each scene at your own pace.

01 · The rule

The rule

Temperature — The Randomness Dial

The triage prompt labelled the same email refund on Monday and order on Tuesday, with no change to the prompt. Meanwhile, the owner's request for spring-sale names kept returning near-identical lists. Both problems had the same cause: the temperature setting was wrong for each job.

The rule

Low temperature for right answers, higher temperature for fresh ideas.

Remember that at each step the model has a probability for every possible next token. Temperature is a number, usually between 0 and 2, that reshapes those probabilities before one token is picked.

  • Low (near 0) — sharpens the distribution. The favourite token wins almost every time. Output is focused and close to repeatable.
  • Around 1 — leaves the learned probabilities roughly as they are.
  • High (above 1) — flattens the distribution. Unlikely tokens get a real chance. Output becomes varied, then odd, then incoherent.

Here is one next-token choice after "The noise is coming from the" at three temperatures, treating these three tokens as the only options:

Token     T = 0.5    T = 1.0    T = 2.0
brake      0.78       0.60       0.47
chain      0.20       0.30       0.33
bell       0.02       0.10       0.19

The ranking never changes. What changes is how strongly the favourite dominates.

At temperature 0, many systems simply take the top token each time, which is called greedy decoding. Results are then very consistent, though not always perfectly identical between runs.

Scene 1 of 5
Hover to wake the cannons. Drag to move, or use arrow keys when focused. Press Enter to fire a shot.