ComfyUI Node

⛱️Qwen2

Turn a half-baked idea into a real prompt, locally, for free

By ZHO-ZHO-ZHO·Created 2 years ago·Updated 2 years ago· 116
⛱️Qwen2
  • model
  • tokenizer
  • text
promptWhat is the meaning of life?
system_instructionYou are creating a prompt for Stable Diffusion to generate an image. First step: understand the input and generate a text prompt for the input. Second step: only respond in English with the prompt itself in phrase, but embellish it as needed but keep it under 200 tokens.

⛱️Qwen2 is the single-turn workhorse of this pack: you type a rough idea, it hands back a polished prompt. That's the whole job, and it's the node most people actually want. The Qwen2.5 Instruct models behind it are genuinely good at the prompt-generation game - Alibaba's Qwen line is the open-weights default for a reason - and they handle Chinese input natively, which is a big deal if you think in a language other than English and want English prompts out.

The intended workflow is spelled out right in the node's defaults. The system_instruction input ships preloaded with a prompt-engineering persona: "understand the input and generate a text prompt … only respond in English … embellish it as needed but keep it under 200 tokens." That's the author's own framing and it's exactly right - use it, or swap in your own system prompt if you want a different flavor of output. You feed your garbage-in idea to prompt, hit run, and the node returns a ready-to-use image prompt.

Here's where it sits in the bigger picture: a 2026 checkpoint like Flux or Z-Image reads your prompt as an instruction through an LLM encoder, not as a bag of tags - so a well-written, embellished sentence genuinely moves the image quality needle. This node is the "get that good sentence in the first place" step, sitting in front of whatever text encoder your workflow already has.

How it works

Under the hood it builds the message list (system_instruction + prompt), runs it through the model's chat template, generates up to 512 new tokens, and returns just the response - no history, no context from earlier runs. Two details worth knowing: max_new_tokens is hardcoded at 512 (plenty for a prompt, not for an essay), and there's no temperature or sampling control exposed. You get what the model gives you, and for prompt-writing that's fine.

Inputs and outputs

Four inputs, all required:

  • model and tokenizer - come straight from the ⛱️Qwen2 ModelLoader's two outputs. This is the part people fumble: both need to be connected, or the node errors out before generating anything.
  • prompt - your raw idea or request. Multiline, so go ahead and be sloppy with it.
  • system_instruction - the persona. The default already does the Stable Diffusion prompt-embellishment thing.

The single output is text - a plain STRING. Wire it into anything that accepts text: a CLIPTextEncode prompt input, or a display node like DisplayText_Zho from the same author's ComfyUI-Gemini pack if you just want to see what it wrote.

Install and model sizes

This is a custom node in ZHO-ZHO-ZHO/ComfyUI-Qwen, installable via ComfyUI Manager (search "ComfyUI-Qwen") or manually:

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

Then restart. The only real dependency is transformers>=4.40.0. Model-wise, the loader auto-downloads whatever size you pick on first run - the 0.5B and 1.5B Qwen2.5 Instruct models are plenty snappy for prompt work on modest GPUs, while 7B is the quality sweet spot on a 16–24GB card. Generation takes a few seconds to maybe half a minute on consumer hardware, and it's all local.

Where people get burned

The most common fail is connecting the model output but forgetting the tokenizer, or wiring text into a node that expects an image. Double-check both wires. And remember: this is single-turn. If you prompt it, then ask a follow-up, it has no memory of the first exchange - that's what the ⛱️Qwen2 Chat node is for.

Category⛱️Qwen2

Inputs (4)

NameTypeDefaultDescription
modelQWEN2
tokenizerTK
promptSTRINGWhat is the meaning of life?
system_instructionSTRINGYou are creating a prompt for Stable Diffusion to generate an image. First step: understand the input and generate a text prompt for the input. Second step: only respond in English with the prompt itself in phrase, but embellish it as needed but keep it under 200 tokens.

Outputs (1)

NameTypeDescription
textSTRING