# Sampling

Concept · [Building with AI](https://ecosystem.samcarlton.com/ai)

Also called: top-p, top p, top-k, top k, nucleus sampling, decoding

How a model chooses each next [token](https://ecosystem.samcarlton.com/token) from its list of likely options. Settings such as [temperature](https://ecosystem.samcarlton.com/temperature) and top-p control how adventurous the choice is.

**For example:** With top-p sampling, the model picks only among the few words that together make up most of the likelihood, ignoring long-shot words.

## Connects to (4)

- [Temperature](https://ecosystem.samcarlton.com/temperature): A setting that controls how random an AI model's word choices are.
- [Next-token prediction](https://ecosystem.samcarlton.com/next-token-prediction): The one job a language model performs.
- [Probabilistic vs deterministic](https://ecosystem.samcarlton.com/probabilistic-vs-deterministic): Deterministic software gives the same output for the same input every time.
- [Token](https://ecosystem.samcarlton.com/token): In AI, a small chunk of text, roughly a word or a piece of a word, that an LLM reads and writes.

Map view: https://ecosystem.samcarlton.com/sampling
