Top-p: LLM Nucleus Sampling

“The sky is seldom wealthy.” 😱 This nonsense is what I got from the LLM after dialing up the Temperature! (see demo below)

All I wanted was creativity, but all I got was chaos!

✨ Part 3/5 of The Creative Shell – What Makes LLMs “Creative”? (see part 2 here)

In the previous parts of this series, we explored how temperature loads the dice 🎲. We dial it up… and our LLM goes wild.

Here’s what’s really going on … and the setting that fixes it:
🔥 High temperature = creativity + chaos.

That “seldom wealthy” line happens because the model rolled a word with a very low probability (low but not impossible).

…


This is where Top-p (Nucleus Sampling) comes to the rescue.
Top-p says: “Only let the dice include faces whose total probability adds up to p%.”
It literally removes sides from the dice before you roll! 🎲✂️

Example (temperature = 0.5), the probabilities are as follow – check image below for reference 👇 the blue bars = available, grey = filtered out):

  • “the” ➡️ (57.30%)
  • “blue” ➡️(18.20%) 🛑 (Top-p = 0.75 stops here)
  • “falling” ➡️(13.09%)
  • “a” ➡️(6.36%) 🛑 (Top-p = 0.95 includes all)

🔑 Why Top-p Is Brilliant?
It’s dynamic…
When the model is confident → small dice (few faces)
When it’s uncertain → large dice (many faces)

Think of it like this:
Temperature loads the dice 🎲
Top-p carves away the unlikely faces ✂️

💡 Secret sauce: High temperature + low top-p = controlled creativity.
You get a balanced dice… but only with the best sides still on it.

💬 What’s your go-to top-p setting? Drop it in the comments 👇

One thought on “Top-p: LLM Nucleus Sampling”

Leave a Reply