---
title: "Top-p"
type: "glossary term"
url: "https://aifordevs.org/glossary#top-p"
markdown: "https://aifordevs.org/glossary/top-p.md"
publisher: "AI for Devs"
license: "https://aifordevs.org/reuse"
attribution: "Credit AI for Devs and link to https://aifordevs.org/glossary#top-p"
also_known_as: "Nucleus sampling"
---

# Top-p (Nucleus sampling)

Top-p, or nucleus sampling, is a sampling method that keeps only the smallest set of most likely tokens whose probabilities add up to at least p, then samples from that set. The candidate count adapts to how concentrated the distribution is at each step.

Holtzman et al. (2019) proposed it to trim the unreliable low-probability tail while keeping diversity. As of November 8, 2026, API version 2026-10-21 of the Claude API rejects requests that send top_p, so check your provider's docs before you depend on it.

## Example

With token probabilities 0.50, 0.30, 0.15, and 0.05 and p = 0.9, the first three tokens stay (cumulative 0.95). Renormalized, they become about 0.53, 0.32, and 0.16.

## Source

[Holtzman et al., The Curious Case of Neural Text Degeneration (2019)](https://arxiv.org/abs/1904.09751)

## Related terms

- [Temperature](https://aifordevs.org/glossary#temperature)

## Cite this term

AI for Devs. "Top-p." https://aifordevs.org/glossary#top-p

- Page: https://aifordevs.org/glossary#top-p
- Markdown: https://aifordevs.org/glossary/top-p.md
- Reuse: Quote or summarize with a link to this page. Terms: https://aifordevs.org/reuse
- Publisher: AI for Devs
