# Sampling

- **Canonical URL:** https://getaimath.com/dictionary/sampling/
- **Topics:** [LLM Fundamentals](https://getaimath.com/dictionary/category/llm-fundamentals/), [LLM Inference: Prefill & Decode](https://getaimath.com/dictionary/category/llm-inference-prefill-and-decode/)
- **Also called:** Sampling Decoding
- **Last updated:** 2026-11-25

## 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.

![How ChatGPT & Claude Talk: Super-Powered Autocomplete — Simple cartoon diagram showing a sentence chopped into Lego word blocks (tokens), an AI brain weighing the odds of the next word ("mat" 75%, "couch" 18%, "roof" 5%), and snapping "mat" onto the end of the sentence.](https://getaimath.com/diagrams/llm-fundamentals.png)
*Napkin Diagram (LLM Fundamentals): Language models don’t plan whole essays at once—they play a super-smart game of "guess the very next word" over and over.*

## What is an example of Sampling?

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.

## Related Concepts

- [Next Token Probability](https://getaimath.com/dictionary/next-token-probability/): Next token probability is the chance a model gives to a specific token being the next one in the text.
- [Deterministic Generation](https://getaimath.com/dictionary/deterministic-generation/): Deterministic generation means the model gives the exact same output every time for the same input.
- [Beam Search](https://getaimath.com/dictionary/beam-search/): Beam search keeps several possible sentences going at once and picks the one with the best overall score at the end.
- [Throughput](https://getaimath.com/dictionary/throughput/): Throughput is the total amount of work a system completes over time, like the number of tokens or requests per second across all users.
- [Probability Distribution](https://getaimath.com/dictionary/probability-distribution/): A probability distribution is a list of every possible outcome with the chance of each one happening, adding up to 100%.
- [Greedy Decoding](https://getaimath.com/dictionary/greedy-decoding/): Greedy decoding always picks the single most likely next token at every step.

---
Source: The AI Math Dictionary (https://getaimath.com/dictionary/sampling/)
