Chapter 5 of 36 · ~1 min

Sampling and Temperature

The model does not always pick its most probable token. It samples: higher-probability tokens are chosen more often, but lower ones get their turn. Temperature controls how adventurous this is. Near zero, the model almost always takes the top choice and becomes repetitive and predictable. Higher, and it explores, which reads as creativity until it reads as nonsense.

This is why the same prompt gives different answers on different runs, and why "the model said X" is a weaker statement than it sounds. It also gives you a knob: low temperature for extraction and classification, higher for brainstorming.

Sampling at two temperaturestemperature 0always the top choicecat100%ball0%boy0%car0%bird0%postman0%wind0%temperature 1.5the long tail gets its turncat28%ball22%boy18%car12%bird9%postman7%wind4%
One set of candidates, two temperatures. Low sharpens the choice, high flattens it.

Experiment 1 of 2

Runs in your browser

The maths first, on an illustrative distribution: slide the temperature and sample from it.

spread: 2.35 bits

The dog chased the ___

  1. cat35%
  2. ball25%
  3. boy18%
  4. car10%
  5. bird6%
  6. postman4%
  7. wind2%

The starting probabilities are illustrative; the temperature maths and the sampling are real. Low temperature repeats the favourite; high temperature lets the tail through.

Experiment 2 of 2

Live model

The same opening continued by a live model at a normal temperature and at a very high one. Generate again and watch how far each side wanders.

High temperature:

Runs against a live model through Chatterfly's server. Your text is sent to the model provider and not stored. A completion model continues the text for up to sixty tokens at each temperature.

Big question

Is variability a defect to remove, or a property to design around?