Nodes/Eric ERNIE-Image Real Diffusers/Eric ERNIE Prompt Rewriter
ComfyUI Node

Eric ERNIE Prompt Rewriter

ERNIE's built-in prompt enhancer, but one you can actually read

By EricRollei·Created 5 months ago·Updated 5 months ago· 3
Eric ERNIE Prompt Rewriter
    • enhanced_prompt
    prompt
    api_urlhttp://localhost:1234/v1
    modelqwen3-8b
    languageEnglish
    width1024
    height1024
    temperature0.60
    passthroughfalse
    custom_instructions

    ERNIE-Image wants long prompts. Every official Baidu gallery image was generated from a 200+ word, PE-expanded description, and the model genuinely follows them - lighting, materials, camera, atmosphere. Feed it "a girl in a park" and you're leaving most of its capability on the table. The model even ships a built-in Prompt Enhancer (PE), a separate 3B LLM that does this rewriting for you. It has three problems: it needs transformers ≥ 5.x (which a standard ComfyUI install doesn't have), it loads a fixed 3B model into your VRAM, and Baidu's own benchmarks show it hurts overall instruction-following by trading attribute-binding precision for elaborative detail.

    Eric ERNIE Prompt Rewriter is the replacement: it expands your short prompt into a rich 150–250 word description using any OpenAI-compatible LLM endpoint - LM Studio, Ollama, whatever's already running - and hands you the result as plain text you can read and edit before it touches the sampler. Zero extra VRAM, works with any language, and the enhanced prompt is fully inspectable.

    How it works

    The node replicates the official PE's behavior exactly. It ships the same system prompt (in English or Chinese - the Chinese version matches the training-data origin, English works equally well per the tooltip) and sends the user message in the same JSON shape the PE uses: {"prompt": "...", "width": W, "height": H}. The LLM returns a fleshed-out description, the node strips the usual chat-model junk (markdown fences, "Here is your enhanced prompt:", wrapping quotes), and you get a clean STRING.

    Under the hood it uses Python's standard-library urllib - no extra dependencies, no API key, just a POST to /chat/completions on your local server. If the LLM call fails, it logs a warning and returns your original prompt, so the node degrades safely instead of erroring your whole graph.

    Inputs that matter

    • prompt - the short description you want expanded.
    • api_url - your endpoint's base URL. LM Studio defaults to http://localhost:1234/v1, Ollama to http://localhost:11434/v1.
    • model - the model name as it appears in LM Studio/Ollama. The qwen3-8b default is a solid choice; any instruct model works.
    • language - English or Chinese.
    • width / height - passed to the LLM so the expansion is aspect-ratio-aware (a poster wants different framing than a portrait).
    • temperature - 0.6 matches the PE defaults; lower = more faithful to your original.
    • passthrough - skip rewriting entirely and forward your prompt unchanged. This is the A/B test switch: same seed, once with the enhancer and once without, to see whether the expansion is actually helping. Given the PE's mixed reputation, you should use it.

    Optional custom_instructions appends extra guidance to the system prompt if you want to bias the style of the descriptions.

    Wiring

    Output enhanced_prompt is a STRING - wire it straight into ErnieImageGenerate's prompt input with use_pe=False (the built-in PE is replaced by this node; don't run both). The loop to iterate: short idea → rewriter → read the expansion → tweak → generate.

    The caveats

    • You need a local LLM server running. The default URL points at your own machine, and the most common failure is "I forgot to start LM Studio." If the server is down you'll see a connection error and the node falls back to your raw prompt.
    • It's a convenience, not a writer. An 8B LLM will happily invent detail you never asked for - which is the whole point of an enhancer, until it isn't. Read the output, and don't be shy about trimming.
    • Prompt enhancement is optional for ERNIE. The KB's verdict on the built-in PE - turn it off when your prompt is already specific - applies equally here. passthrough exists because sometimes the un-rewritten prompt is the better one.

    Install is the pack's one-time setup (Manager search "Eric ERNIE-Image", or clone https://github.com/EricRollei/Ernie_Image_Real_Diffusers into custom_nodes, restart). No per-node dependencies - it talks to a server you already run.

    CategoryEric ERNIE Image

    Inputs (9)

    NameTypeDefaultDescription
    promptSTRINGShort prompt to expand into a detailed description.
    api_urlSTRINGhttp://localhost:1234/v1OpenAI-compatible API base URL. LM Studio default: http://localhost:1234/v1 Ollama default: http://localhost:11434/v1
    modelSTRINGqwen3-8bModel name as shown in LM Studio / Ollama. Qwen3-8B, Llama3-8B, or any instruct model works well.
    languageCOMBOEnglishLanguage for the enhanced prompt. Chinese matches ERNIE-Image's training data origin but English works equally well.
    widthINT1024256–8192Target width - passed to the LLM for aspect-ratio-aware expansion.
    heightINT1024256–8192Target height - passed to the LLM for aspect-ratio-aware expansion.
    temperatureFLOAT0.600–2LLM temperature. 0.6 matches the PE defaults. Lower = more faithful.
    passthroughBOOLEANfalseSkip rewriting and pass the prompt unchanged. Useful for A/B testing.
    custom_instructionsoptSTRINGExtra instructions appended to the system prompt.

    Outputs (1)

    NameTypeDescription
    enhanced_promptSTRING