What is Top-p Sampling?
Top-p sampling, also called nucleus sampling, restricts a language model's next-token choice to the smallest set of tokens whose cumulative probability reaches a threshold p, then samples only from that set.
Rather than fixing a hard number of candidate tokens, top-p adapts to the shape of the distribution: when the model is highly confident, the nucleus might contain only one or two tokens; when it is uncertain across many plausible continuations, the nucleus widens to include more of them. A common setting like p=0.9 means the model samples only from tokens that together account for the top 90% of probability mass, discarding the long tail of unlikely options.
Top-p is usually used together with, or instead of, temperature, and the two interact: temperature reshapes the probability distribution first, and top-p then trims which tokens are even eligible to be sampled from that reshaped distribution. Lowering p tightens output toward the most probable continuations and reduces the chance of an odd, low-probability token derailing a response; raising it allows more variety.
In practice with Neotask
Neotask exposes top-p as a tunable generation parameter for advanced users configuring an agent's behavior, letting a team that wants more predictable structured outputs narrow the nucleus while a team building a creative-writing assistant can widen it for more varied phrasing.
Related terms
- temperature-ai
- tokens-ai
- large-language-model
- prompt-engineering
- reasoning-model
Plans
Free
$0/mo
Download without a card and start for free.
Individual
$50/mo
The full personal agent platform for one person.
Business
$100/mo
One company workspace with room to add your team.
Enterprise
$200/mo
Multiple workspaces and capacity for larger teams.
Continue