PromptForge
AI Glossary

Core concepts

Top-p (nucleus sampling)

Also known as: nucleus sampling, topp

Definition

Top-p limits the model to choosing from the smallest set of tokens whose combined probability exceeds p. At top-p 0.9, the model samples only from options making up the top 90% of probability mass, ignoring the unlikely tail.

Top-p is an alternative to temperature for controlling randomness, and the two are often available together. Where temperature rescales the whole probability distribution, top-p truncates it — cutting off the long tail of implausible tokens entirely.

The advantage is adaptivity. When the model is confident, the nucleus is small and output stays focused. When many options are genuinely plausible, the nucleus widens and output varies. Temperature applies the same scaling regardless of confidence.

Standard advice is to tune one or the other, not both. Most practitioners adjust temperature and leave top-p near its default of 0.9-1.0.

Related terms

Put this into practice

Understanding the term is step one. Our free courses and tools let you actually use it.