Top-p

Also called nucleus sampling, top p

A setting that limits the AI’s word choices to the most likely options that together add up to a set probability.

Top-p, also called nucleus sampling, is another way to control randomness in a model's output. Instead of considering every possible next token, the model sorts tokens by probability and keeps only the smallest group whose probabilities add up to p. If top-p is 0.9, it samples from the tokens that make up the top 90% of the probability, ignoring the long tail of unlikely options.

The effect is adaptive. When the model is confident, the group might be just one or two tokens. When many words are plausible, the group grows. This cuts off strange, low-probability choices while still allowing variety where variety makes sense.

Temperature and top-p both shape randomness, and providers usually recommend adjusting one and leaving the other at its default. A related setting, top-k, keeps a fixed number of the most likely tokens instead of a probability share. Most people never need to change top-p; temperature is easier to reason about.

Example

With top-p at 0.1, a model writing "The capital of France is" considers only "Paris". With top-p at 0.95 in a story, the next word after "The forest was" might be "silent", "dark", "ancient" or "humming", all reasonable choices.

Common mistake

Tuning temperature and top-p at the same time and then not knowing which caused a change. Pick one, usually temperature, adjust it in small steps on a fixed set of test prompts, and leave the other at the provider's default.

Find a prompt for the task in front of you.

96 prompts in 8 categories. Copy one, fill in the blanks, paste it into any model.

Browse prompts

Promptlexity is a free library of 96 AI prompts and 8 downloadable AI skills across 8 categories, plus a glossary of 64 AI and prompting terms. Each prompt shows the exact text to paste, the variables to fill in, an example of what comes back, and why it works. Each glossary term has a plain-English definition, an example and a common mistake. 6 step-by-step guides cover the basics. No signup, works with ChatGPT, Claude, Gemini and other models.

Press Esc to close