top-p
The top-p setting determines from how large a pool of the most likely candidates the language model can sample the next word.
In plain terms
The language model writes text word by word (more precisely, token by token), and at each step draws one from many possible continuations. Top-p regulates how large a set of candidates can be included in this draw.
Imagine a waiter in a restaurant recommending something to you. If they only choose from the most popular dishes, and only enough of them to account for 90 percent of all orders, then rarely requested, unusual dishes will never come up. Top-p likewise cuts off the long tail of unlikely words.
The method is flexible: if the model is very confident in the continuation, the circle narrows to one or two words; if there are many good continuations, it can expand to several hundred. At low values, the text is more predictable; at high values, it is more varied but more prone to slipping in inappropriate words.
How it works
- The model calculates a probability for every possible next token, for example: 'coffee' 40%, 'tea' 25%, 'water' 15%, and so on.
- It ranks candidates from most likely to least likely.
- It sums probabilities from the top down until the total reaches the specified p value (for example, 0.9, or 90%). The candidates that have appeared up to that point, including the one that caused the sum to reach the threshold, form the 'nucleus'.
- It discards candidates outside the nucleus and proportionally scales up the probability of those remaining so they sum to 100% again.
- From this restricted set, the next token is sampled, then the entire process restarts for the next token.
An everyday example
In the advanced settings of an AI tool, you will find a 'Top P' slider between 0 and 1. If you set it to 0.3, your product descriptions will become more uniform and dry. Around 0.95, you get more varied phrasing, sometimes with surprising word choices.
Who is affected
A common misconception
Limits and risks
- Top-p regulates variety, not factual accuracy: even at low values, the model can confidently state falsehoods.
- Since adjusting it together with temperature makes its effect hard to track, providers usually recommend modifying only one at a time.
- If the value is too low, the text can become repetitive and flat; if too high, irrelevant words may slip in.
- On most chat interfaces, you cannot adjust this, and with some newer models, the provider also restricts or fixes it via the API.
Similar, but not the same
- temperature – Temperature modifies the chances of all candidates: it sharpens or equalizes the differences but does not change their order and excludes no single candidate. Top-p, however, cuts off the unlikely candidates from the end of the list.
- top-k – Top-k always keeps a fixed number of candidates (for example, 40), while in top-p the number of candidates changes step by step depending on the model's confidence.
Related concepts
sampling, text generation, large language model
–
temperature, top-k, token, hallucination, prompt
A brief history
The method was described by Ari Holtzman and co-authors in the paper "The Curious Case of Neural Text Degeneration," published on arXiv in 2019 and presented at the ICLR conference in 2020. They showed that generation always choosing the most probable word yields boring, self-repetitive text, while completely free sampling produces nonsense.
Where things stand
At the end of 2026, top-p is an adjustable parameter in the API of most language models. However, providers increasingly restrict it or fix its value themselves, especially for reasoning models, so users touch it less often.
In the news
- Cat Wu, one of the faces of Claude Code, leaves AnthropicNov 3, 2026 · Code
- UK minister: plan needed for 'unprecedented' AI job lossesSep 28, 2026 · Work & HR
- First Hungarian measurement shows whether Hungarians click through from ChatGPTAug 10, 2026 · Marketing
Also known as
top-p · top_p · Top P · top-p sampling · nucleus sampling · top-p sampling · nucleus sampling · core sampling (model-weight sampling)
Sources
- Holtzman et al.: The Curious Case of Neural Text Degeneration (arXiv, 2019)
- Wikipedia: Top-p sampling
This entry was machine-edited and has undergone machine expert review; the “In the news” section updates automatically from Agent Age stories.