ComfyUI Node

Prompt Refiner

Polish a prompt you already wrote — or that the generator butchered

By Limbicnation·Created 9 months ago·Updated 2 months ago· 10
Prompt Refiner
    • refined_prompt
    prompt
    modelqwen3:8b
    passes1
    temperature0.5
    top_p0.9
    seed-1
    timeout120
    unload_modeltrue

    Prompt Refiner is the editor to Prompt Generator's writer. You hand it a prompt you already have - rough idea, a sentence you scrawled, or the first draft the generator spat out - and it hands back an improved version. Same local Ollama setup, no API key, nothing fancy. It slots naturally into the chain the pack's own roadmap draws: generate → refine → combine → encode.

    How it works

    The node wraps your prompt in a fixed system prompt that instructs the model to act as an expert Stable Diffusion prompt engineer: keep the core subject, add descriptive detail (textures, lighting, atmosphere), composition and framing cues, color hints, and technical quality markers. That instruction goes to your local Ollama model (default qwen3:8b), and the cleaned-up response comes out of refined_prompt.

    The interesting knob is passes (1-3). With more than one pass, the output of each pass becomes the input of the next - the prompt gets rewritten again and again. There's a subtlety worth knowing: the code derives a per-pass seed from your seed (so a fixed seed + 2 passes is reproducible), and each pass re-runs the same refinement instruction. That's deliberate, but it has a practical consequence: more passes drift further from your original. A 3-pass run can turn "a cat on a windowsill" into a heavily dressed cinematic scene. One pass polishes; two re-imagines; three is for when you genuinely want the model to take over. Most people end up at 1.

    Inputs and outputs

    • prompt (required) - the raw prompt to refine.
    • model - Ollama model name, default qwen3:8b.
    • passes (1-3, default 1) - how many rewrite iterations.
    • temperature (default 0.5) - the pack's refiner runs cooler than the generator, which is the right call for an editing job.
    • seed (default -1 = random) - set it to reproduce a refinement exactly.
    • timeout (default 120s), and unload_model (default on).

    That last one, unload_model, deserves a mention: when it's on, the model is evicted from Ollama's VRAM immediately after the call so your diffusion model can load without OOM (the pack fixed a real "VRAM grow failed" bug around exactly this). If you're running a batch of refinements back to back, flip it off so the model stays warm between calls - you trade a few hundred MB of VRAM for much faster sequential runs.

    The single output, refined_prompt (STRING), feeds the same places the generator's output does: a CLIP Text Encode node or a Show Text so you can eyeball the diff.

    Install and gotchas

    Identical to the rest of this pack:

    cd ComfyUI/custom_nodes
    git clone https://github.com/Limbicnation/ComfyUI-PromptGenerator.git
    cd ComfyUI-PromptGenerator
    pip install -r requirements.txt
    

    or install "Prompt Generator" via ComfyUI Manager. Prerequisites: Ollama running and ollama pull qwen3:8b. Then find Prompt Refiner under text/generation.

    Two real-world gotchas, both grounded in how the code behaves:

    • It adds quality boilerplate ("8k, masterpiece") by design - that's literally in the refinement instruction. On SDXL-lineage models those tags still work; on LLM-encoded models (Flux, Z-Image, Anima) they're inert filler. If your refiner output suddenly reads like a keyword list got welded to a sentence, that's the template, not a bug.
    • If temperature/top-p don't change anything, the ollama Python package isn't installed and the node is falling back to the CLI subprocess, which ignores those settings. pip install ollama and restart.

    And the boring but important one: the node needs the prompt box filled. An empty prompt returns a polite error string instead of doing something weird - annoying the first time you wire it before typing anything, but far better than a crash.

    Categorytext/generation

    Inputs (8)

    NameTypeDefaultDescription
    promptSTRING
    modelSTRINGqwen3:8b
    passesoptINT11–3
    temperatureoptFLOAT0.50.1–1
    top_poptFLOAT0.90.1–1
    seedoptINT-1-1–2147483647
    timeoutoptINT12030–600
    unload_modeloptBOOLEANtrue

    Outputs (1)

    NameTypeDescription
    refined_promptSTRING