Top-p sampling: how AI picks its words
Top-p, or nucleus sampling, is a way an AI chooses the next word in a sentence. Instead of picking from every possible word in its vocabulary, it narrows the field.
Here is how it works. The AI looks at all the words it thinks could come next and assigns each a probability. Then it adds those probabilities together, starting with the most likely, until the total reaches a set number — usually 0.9 or 90 percent. It keeps only those words. The rest get dropped. The AI then picks from this smaller group.
Think of it like when your tía asks you to help pick a restaurant for Sunday dinner. There are a hundred places in the city. She does not want you to consider every single one. She says, "Los que tienen buena comida y están cerca, los otros no." She is cutting the list to the top 90 percent of options. Then you choose from that short list. That is top-p.
Why this matters for us: if you are writing with an AI and it starts sounding too repetitive or too wild, adjust the top-p number. Lower it to keep things tighter. Raise it for more variety. It is a dial, not a switch. Try it next time you draft something and want the output to stay on track without sounding robotic.