Top-p
Last updated
What is Top-p?
Top-p, also called nucleus sampling, is a setting that guides how an LLM picks its next word. The model lists many possible words and sorts them by probability. It then finds the smallest group of top words whose combined chance adds up to the chosen p value, such as 0.9. Only words inside this group stay in the running; the rest are dropped. The model picks one word from the kept group at random, weighted by their original chances. A lower p keeps only the very likely words, so output is safer and more focused. A higher p lets in less likely words, adding surprise and creativity but also more risk of error.
Free resources to learn Top-p
More in stage 13: Agent Loop
Top-p: common questions
Can I learn Top-p in Hindi?
This lesson is written in English. Once you sign in, open it in the interactive course and ask the AI tutor to explain Top-p in Hindi or Hinglish. The tutor answers from this lesson’s own text, so it stays on the syllabus, and it runs on your own Google, OpenAI or Anthropic key.
Is this Top-p tutorial for beginners?
It is lesson 22 of 101 in the free AI Agents roadmap, in stage 13, Agent Loop. If you are new to AI Agents, start from stage 1 and come back here in order; if you already know the earlier stages, this lesson stands on its own.