Learn AI Math

Sampling

Also called: Sampling Decoding

What is Sampling?

In one sentence: Sampling is how a model picks the next token from its list of possible options, using their probabilities.

Instead of always taking the top choice, the model "rolls weighted dice," so likely tokens get picked more often but not always. Settings like temperature, top-K and top-P change how those dice behave. This is why the same question can get different answers.

What does Sampling look like?

Ask a chatbot for a story twice and get two different stories; that variety comes from sampling.

Why does Sampling matter?

Sampling makes AI writing feel natural and creative instead of repetitive.

Last updated · Fact-checked by The AI Math

Linking to this page from a lesson or article?

Like this explanation? Get one every week.

The AI Math newsletter turns confusing AI news into plain English. No hype, no jargon walls.