Top-p
Definition
A sampling setting that restricts the model to the smallest set of likely tokens whose probabilities add up to p, then samples from that set.
In more detail
Top-p of 0.9 means the model picks only among tokens that together make up 90 per cent of the probability. Providers generally advise adjusting temperature or top-p, not both.
Top-p is also called nucleus sampling. A low value makes output more predictable by cutting off unlikely tokens; a value of 1 disables the cut-off. For extraction, classification and code, low temperature with default top-p is the usual starting point. Some reasoning models ignore or reject sampling parameters, so check the model's documentation.
Related terms
Log probabilities (logprobs)
The log of the probability a model gave each token it generated, returned by some APIs to show how confident the model was.
Temperature
A sampling setting that controls randomness: lower values favour the most likely tokens, higher values spread probability more evenly.
Read more about Top-p
- LLM API parameters cheat sheet
Temperature, top_p, max tokens, stop, seed, logprobs, JSON output and reasoning effort, with exact names for OpenAI, Claude and Gemini, checked on the API docs.
- Prompt engineering
Writing clear, testable instructions for models and checking them on real inputs.
- Temperature
A sampling setting that controls randomness: lower values favour the most likely tokens, higher values spread probability more evenly.
- Prompting fundamentals: clear tasks, examples and formats
How to write a good prompt: frame the task, say who the output is for, show an example and specify the format, so a model's answers are useful and repeatable.