AI CompendiumA public chart of the language
Training & Inference

Sampling

How the model picks one token out of the distribution.

Definition

The rule that chooses the next token from the model’s predicted probabilities. Greedy sampling always takes the top token; top-p and top-k restrict the choices; temperature reshapes how peaked the distribution is.

Sampling is why two identical requests can give two different answers even with no randomness in the network itself.

Sampling rules are where determinism goes to die, and they interact with everything else: a temperature change invalidates your evaluation baseline, and decoding settings are part of the system you have to version alongside the prompt.

How people use it
A product owner asking for reproducible output.
"Set temperature to zero and it is as deterministic as it gets — but do not build on that being guaranteed."
Worked example

Sampling as a retry strategy

A code-generation step fails on the first attempt.

Do not raise the temperature and hope. Sample several candidates at a low temperature and run the tests against each — that is what pass@k measures, and it converts variance into a controlled retry mechanism rather than a quality gamble.

Sources
Related terms