Nodes/Comfy DV Nodes/Ollama Option — Top P
ComfyUI Node

Ollama Option — Top P

Nudge how 'creative' your model's sampling gets

By darth-veitcher·Created 2 years ago·Updated about a month ago· 2
Ollama Option — Top P
  • options
  • options
top_p0.90

Top P - also called nucleus sampling - is the sampler knob that says "only consider the most probable tokens whose combined probability adds up to this fraction." Set it to 0.9 and the model picks from the narrow slice of very-likely tokens; crank it toward 1 and it opens the door to long-tail tokens you'd never normally see. Ollama Option - Top P is just a comfortable slider for that one parameter, feeding it into your local LLM calls.

If you've spent time in image sampling you've already met this family of ideas - the same top-p knob lives on many samplers and schedulers, and it does similar work here: a lower value makes output more conservative, a higher value makes it more varied.

How it works

Like every comfydv option node, it's a one-key dict builder. It takes an optional options input (the OLLAMA_OPTIONS bundle from another option node), merges in top_p, and hands the bundle on. Wire the last option node in your chain into Chat Completion's options input and the value rides along with every chat request.

The one input that matters is top_p - a FLOAT from 0 to 1, default 0.9, stepped at 0.01. Ollama's own default is also 0.9, so if you're happy with default behavior you can honestly skip this node entirely. Reach for it when you want output that's noticeably tamer (push toward 0.8 or below) or noticeably looser (push toward 0.99).

How it relates to temperature

Top P and temperature both widen or narrow sampling, but they do it differently - temperature reshapes the whole probability distribution, top P slices it. Many people treat them as interchangeable dials ("lower either one for more determinism") and that's roughly right in practice. Where people get burned: cranking both high at once produces pure word salad, and cranking both low can make the model repetitive and boring. Change one at a time, keep the other at its default.

Install

Via ComfyUI Manager (search "comfydv"), or:

cd ComfyUI/custom_nodes
git clone https://github.com/darth-veitcher/comfydv.git

Restart and run Ollama or llama.cpp. The node lives under dv/ollama/options, and you need an Ollama Client + Chat Completion upstream to actually use it.

Gotchas

  • It only does something if a model actually honors it. Both backends accept the parameter, but small or heavily-quantized models sometimes produce near-identical output no matter what you set - sampling params are a nudge, not a guarantee.
  • Chain, don't fan out. Each option node wants the previous one's options input, not a separate wire per node. Keep it in a line: Temperature → Seed → Top P → ... → Chat Completion.
Categorydv/ollama/options

Inputs (2)

NameTypeDefaultDescription
top_pFLOAT0.900–1
optionsoptOLLAMA_OPTIONS

Outputs (1)

NameTypeDescription
optionsOLLAMA_OPTIONS