# LLM Sampling

> How a model picks the next token from its list of chances.

**Field:** Artificial Intelligence  
**Category:** LLMs  
**Also known as:** Decoding, Token Sampling, Sampling

## Think of it like

Think of it like a bag with lots of word cards. You pull one out, and likely words have more cards.

## Definition

Sampling is how a language model picks the next token from the chances it gave. Always taking the most likely token gives safe but dull and repetitive text. Picking at random, weighted by the chances, gives more varied text. Settings like temperature, top-k and top-p shape that draw. This is why the same question can get a different answer each time.

## Example

Lucy asks for a story opener three times and gets three different first lines. Each time, sampling drew a different token at the start.

## Why it matters

It explains why answers change from run to run. It also shows which settings make them steady or varied.

## Common mistake

Thinking a new answer to the same question means the model changed. It is the same model drawing a different token.

## Three principles

- **Pick from the chances.** One token each step.
- **Weighted draw.** Likely tokens win more.
- **Settings shape it.** Temperature, top-k, top-p.

## Related terms

- [LLM Temperature](https://learn.benibix.com/term/ai/temperature)
- [Top-p Sampling](https://learn.benibix.com/term/ai/top-p-sampling)
- [Top-k Sampling](https://learn.benibix.com/term/ai/top-k-sampling)
- [Next-Token Prediction](https://learn.benibix.com/term/ai/next-token-prediction)
- [Log Probabilities (Logprobs)](https://learn.benibix.com/term/ai/logprobs)
- [Greedy Decoding](https://learn.benibix.com/term/ai/greedy-decoding)
- [Beam Search](https://learn.benibix.com/term/ai/beam-search)

## Taught in

- [Temperature and Sampling](https://learn.benibix.com/learn/ai-llms/temperature-and-sampling): LLMs, 3/15

![Three bar charts of the same next-word chances. At low temperature one bar towers over the rest. At medium temperature the bars are as the model gave them. At high temperature the bars are almost flat.](https://learn.benibix.com/diagrams/llm-temperature.svg)

---

Source: https://learn.benibix.com/term/ai/sampling
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-18
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
