Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

top-p sampling (nucleus sampling)

Restricting sampling to the smallest set of top tokens whose probabilities add up to at least p, then drawing from that set.

Top-p sampling (nucleus sampling) truncates the next-token distribution to the smallest set of highest-probability tokens whose cumulative probability reaches a threshold p, then samples from that set. Unlike top-k's fixed shortlist size, top-p's shortlist grows or shrinks with how peaked or flat the distribution is at each step.

Examples

  • With p=0.9, a very peaked distribution might keep just 3 tokens in the sampling pool, while a flatter distribution at another step might need 200 tokens to reach that same 0.9 cumulative probability.

Read the full section →
Graph settings

Calculator