Skip to lesson
How AI Works , back to all courses

Part 1 · How it writes

Same prompt, different answers

Sampling and temperature: why a reply can change when nothing else did.

Lesson 4 of 4 5 min 5 steps

Key terms: Sampling Picking each next token at random, in proportion to the model's odds., Temperature A setting that sharpens or flattens the odds before sampling., Prompt The instructions and material you give a model.

Step 1 of 5

Watch the video

Why can the same request come back different? The video shows how the model picks each token, and what a setting called temperature changes.

Video, 1 min 37 s
Read the transcript

Send the same request twice, and you can get two different replies. Nothing went wrong. It's how the loop picks.

At each step, the model has odds for every possible next token. It doesn't have to take the top one. It samples: it picks at random, weighted by those odds. A likely token wins most of the time, and a less likely one sometimes.

One different early pick, and the rest of the reply can head down another path.

A setting called temperature changes how spread out the odds are. At zero, the top token is taken every time. Turn it up, and the odds even out, so the picks vary more.

We tried it. We gave GPT-4.1 mini the week's main counts for Pinewick and asked for an email subject line, without saying whether to use the counts. Five times at temperature zero, and five at one.

At zero, all five were the same line, with no counts. At one, there were three different lines, and two of them put the counts in.

The request left that choice open, so the model made it. Some newer models, including Anthropic's newest, don't let you set temperature at all. If a reply must include something, like those counts, ask for it, then check that it's there.

Next: where those odds come from in the first place. How a model is trained.

Step 1 of 5 Watch