Concept
aka nucleus sampling
Top-P Sampling
Sampling from the smallest token set whose cumulative probability exceeds threshold p.
Definition
Top-p (nucleus) sampling dynamically truncates the distribution: it includes only the most likely tokens that together account for probability mass p. Unlike fixed top-k, it adapts to the distribution's shape — fewer tokens when the model is confident, more when it's uncertain.
Common use cases
- Creative writing
- Open-ended chat
- Brainstorming