LLM Top-P
Nucleus sampling as a chainable node, and why 0.95 is the sensible default
- previous
- llm_sampler
LLM Top-P is the nucleus-sampling knob in the YALLM sampler chain. Instead of cutting off the token list at a fixed count like top-k, top-p keeps adding tokens from the probability distribution until their combined mass reaches the threshold you set. It's a more adaptive way to trim the tail of nonsense tokens, and at 0.95 it's the default most local llama.cpp setups ship with - because it's a good default.
How it fits the chain
Like every sampler in this pack, it's a link in a chain, not a standalone control. You wire LLM Top-P after whatever sampler came before (or nothing at all, if it's first), set the value, and the node appends ("top_p", value) to the running list of sampler settings. The llm_sampler output feeds the pack's LLM Chat node, which sends the whole ordered list to the provider.
The order you chain matters if you're on llama.cpp - it accepts a samplers array that controls the order of application. So LLM Temperature → LLM Top-P runs top-p after temperature, and the reverse runs them the other way. It's one of those details that only shows up when you're chasing a weird output, but it's there if you need it. Notably, top-p is one of the two samplers in this pack that the official OpenAI API spec actually supports (temperature is the other), so unlike min-p and top-k it travels in the standard request body - meaning it works on hosted providers too, not just local llama.cpp.
The inputs and output
top_p- a float from0to1, default0.95. Lower values (0.7–0.9) make output more focused and deterministic; near 1.0 you get full variety. Below about 0.5 things start reading as robotic.previous(optional) - thellm_sampleroutput of an earlier sampler node.- Output:
llm_sampler, intoLLM Chat.
Installing it
Part of the ComfyUI-YALLM-node pack - Manager searching "ComfyUI-YALLM-node", or:
cd ComfyUI/custom_nodes
git clone https://github.com/asaddi/ComfyUI-YALLM-node
cd ComfyUI-YALLM-node
pip install -r requirements.txt
Restart and it's under YALLM/samplers.
Gotchas
The honest take: top-p is a gently-acting knob, so if you're cranking it and "nothing happens," that's normal - it's shaving the tail, not reshaping the distribution. Where people actually get confused is stacking top-p and top-k at aggressive values simultaneously; the two trims compound and output can collapse into repetition. If you're going to lean on one, top-p is the better-behaved choice for the chat-completion API. And remember the provider caveat from the pack README: only temperature and top-p are guaranteed to be honored by arbitrary OpenAI-compatible endpoints, so this is the sampler most likely to survive a move from llama.cpp to a hosted provider.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| top_p | FLOAT | 0.950–1 | — |
| previousopt | LLMSAMPLER | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| llm_sampler | LLMSAMPLER | — |