Nodes/ComfyUI-TextGenerateQwen3Prompt/Text Generate Qwen3 Prompt
ComfyUI Node

Text Generate Qwen3 Prompt

Your Z-Image Qwen3 Encoder Is Also a Prompt Expander

By knishika62·Created 6 months ago·Updated 6 months ago· 4
Text Generate Qwen3 Prompt
  • clip
  • generated_text
prompt
system_promptYou are a professional image generation prompt expert. Output in English.
max_length256
do_sampletrue
temperature0.70
top_k64
top_p0.95
min_p0.05
repetition_penalty1.05
seed0
enable_thinkingfalse

The one-line pitch

Your Z-Image workflow already loads a Qwen3-4B LLM - it's the model that reads your prompt and turns it into conditioning. This node borrows that same loaded CLIP object and gives it a second job: writing the prompt itself. Feed it a rough idea ("cyberpunk noodle bar at night, neon rain"), it runs the LLM in chat mode, and hands back a polished prose prompt you can wire into a text-encode node.

The name is honest. No API call, no key, no cloud - everything runs locally through ComfyUI's built-in text generation path, and the only model it needs is the one you're already holding.

Why you'd reach for it

Models that encode with an LLM - Z-Image and friends - read your prompt like an instruction, not a bag of tags. Full sentences with clear ownership beat comma-separated keywords, which is exactly where a prompt expander earns its keep: you say the skeleton, the LLM fills in the prose. And here's the nice part - you only install this pack if you're already running a Qwen3-encoder model (Z-Image, Klein 4B, the Anima family), so the model cost is already paid. Same checkpoint, double duty. That's the closest thing to a free upgrade this ecosystem hands out.

One honest caveat: ComfyUI ships a generic TextGenerate node that does much the same thing. This node's value is that it's Qwen3-specialized - it builds the official chat template for you, adds thinking-mode control, and strips the <think> blocks automatically. If you're on a Qwen3-encoder model and you want a prompt expander that just behaves, that specialization is worth it.

How it works

It wraps your prompt in Qwen3's chat format (<|im_start|>system<|im_start|>assistant), tokenizes via clip.tokenize, and generates via clip.generate - the same native LLM path the standard node rides on. Then it decodes, chops off the prompt prefix, removes any <think>...</think> block, and cleans the special tokens out of what's left. Thinking mode off just appends /no_think to your message, Qwen3's official soft switch; thinking mode on produces reasoning you never see, because it's deleted before the string reaches you.

Inputs and output

You only really set a few of these.

  • clip (CLIP, required) - the Load CLIP'd Qwen3-4B. Wire in the exact same CLIP object you already feed your conditioning node.
  • prompt (STRING, multiline) - your rough idea. The seed phrase that gets expanded.
  • system_prompt (STRING, multiline) - defaults to "You are a professional image generation prompt expert. Output in English." Change it if you want a different style or language.
  • enable_thinking (BOOLEAN, default False) - flip on for deeper reasoning; if you do, raise max_length to 1024+ or your output gets cut off mid-thought.

The rest - temperature, top_k, top_p, min_p, repetition_penalty, seed, do_sample - is a standard sampling cluster with sane defaults. The README's recommended knobs: non-thinking temp 0.7 / top_p 0.8 / top_k 20 / min_p 0, thinking temp 0.6 / top_p 0.95 / top_k 20 / min_p 0.

The single output, generated_text (STRING), plugs straight into the prompt input of a CLIP Text Encode node. Note it's a string, not conditioning - the node doesn't touch the sampler.

Installing it

ComfyUI Manager → search "ComfyUI-TextGenerateQwen3Prompt", or:

cd ComfyUI/custom_nodes
git clone https://github.com/knishika62/ComfyUI-TextGenerateQwen3Prompt

then restart ComfyUI. There's no requirements.txt - the pack is just Python stdlib plus torch, so no dependency hell for once. The real download is the Qwen3-4B checkpoint itself, loaded through the standard Load CLIP node (quantized, it's a couple of GB; full precision is bigger).

Where people get burned

  • Old ComfyUI: clip.generate is a relatively new addition. If the node errors on run, you're on a stale build - update ComfyUI first.
  • Thinking mode with a tiny max_length: output truncates mid-thought. The README is right; give it 1024+.
  • Expecting vision: there's no image input - Qwen3-4B isn't a vision model. This is text-to-text prompt expansion, not image-to-prompt captioning.
  • It's a forward pass every time: instant, but not free - the LLM has to actually run, so budget a moment of VRAM and compute per expansion.

Simple idea, small pack, genuinely handy if you're already on Z-Image. Install it, wire your existing CLIP in, and let the model write your own prompts for once.

CategoryLLM

Inputs (12)

NameTypeDefaultDescription
clipCLIP
promptSTRING
system_promptSTRINGYou are a professional image generation prompt expert. Output in English.
max_lengthINT2561–4096
do_sampleBOOLEANtrue
temperatureFLOAT0.700–2
top_kINT640–1000
top_pFLOAT0.950–1
min_pFLOAT0.050–1
repetition_penaltyFLOAT1.051–2
seedINT00–18446744073709550000
enable_thinkingBOOLEANfalse

Outputs (1)

NameTypeDescription
generated_textSTRING