When a language model generates text it assigns a probability to every possible next token. Nucleus sampling keeps only the most probable tokens that together reach probability p, then samples among them. If the model is confident, only one or two tokens qualify; if it is uncertain, more do. See our explainer on temperature and sampling.