Qwen_TE_LLM
Local Qwen3-4B prompt writing, no API key required
- text
- used_seed
Displayed as Qwen_TE_LLM in the node menu, this is a fully local LLM for writing and rewriting prompts, running entirely inside ComfyUI. No API key, no browser tab, no data leaving your machine. You give it a rough idea like "a girl in a coffee shop," it hands back a detailed photography prompt - or whatever the template asks for.
Here's the detail that makes it clever: the model file it runs is qwen_3_4b.safetensors, the same weights the current generation of LLM-encoder models (Z-Image and friends) use as their text encoder. If you already run one of those, you already own the file this node needs. One download, two jobs.
How it works
It scans your models/text_encoders/ and models/clip/ folders for .safetensors files, preferring anything named like qwen_3_4b.safetensors. On first run it downloads the tokenizer and config from Qwen/Qwen3-4B on Hugging Face into a <model_name>_config folder next to the file, then loads the model with transformers (AutoModelForCausalLM). The "intelligent memory management" in the README is real: it checks free VRAM (roughly 6GB threshold) and picks full-GPU loading, a CPU-offload split via device_map="auto" with max_memory, or pure CPU. It strips Qwen3's <think>...</think> reasoning tags from output, and applies your prompt through the proper chat template.
Two optional toggles are worth knowing about but probably not turning on: use_quantization (INT8 via bitsandbytes, lower memory but slower) and use_flash_attention (the tooltip itself says it may not help small-batch inference). Neither is installed by default - if you flip them without the packages, it logs a warning and falls back to standard fp16.
The inputs that matter
user_prompt- your rough description. Handles Chinese and English.prompt_template- dropdown of.mdtemplates shipped in the pack'sPrompt/folder:photography_en.md,photography_zh.md,extract_person_features.md,image_to_prompt.md,simple_prompt_list.md,video_frame_transition.md. Selecting one replaces the system prompt.system_prompt- used when the template isCustom.max_new_tokens- generation length (1–4096, default 2048).temperature- 0.7 default; lower for stricter rewrites.keep_model_loaded- the tooltip is a warning: leave itFalse(default) in low-VRAM setups so the model unloads after each run and frees the card for your diffusion model.
Outputs: text (STRING) and used_seed (INT). One honest caveat: seed only applies if you set it above 0 - seed 0 means non-deterministic.
Setup and expectations
cd ComfyUI/custom_nodes
git clone https://github.com/dseditor/ComfyUI-ListHelper
Then grab qwen_3_4b.safetensors from the Qwen/Qwen3-4B repo and drop it in models/text_encoders/ (or models/clip/). transformers and safetensors ship with ComfyUI's environment, so the pack's own requirements.txt (regex, accelerate, reportlab) won't install them - don't go hunting for a missing dependency.
Keep expectations calibrated. Full-GPU runs around 26–30 tokens/sec, which is fine for prompt work. Under 6GB free it drops to CPU offload at 1–2 tokens/sec - usable for a short rewrite, painful for anything long. A 4B model is plenty for turning "cat on a windowsill" into a photography prompt, but don't expect frontier-level prose. If you're running a heavy diffusion model at the same time, set keep_model_loaded to False and let it unload between runs. "Model file not found" means the file isn't in text_encoders or clip - that's the first thing to check.
Inputs (11)
| Name | Type | Default | Description |
|---|---|---|---|
| user_prompt | STRING | A girl in a coffee shop | — |
| prompt_template | COMBO | Custom | 8 options: Custom, extract_person_features.md, image_to_prompt.md, photography_en.md, photography_zh.md, qwen2512_en.md, +2 |
| system_prompt | STRING | — | |
| max_new_tokens | INT | 20481–4096 | — |
| temperature | FLOAT | 0.70–2 | — |
| seedopt | INT | 00–18446744073709550000 | — |
| keep_model_loadedopt | BOOLEAN | false | WARNING: Set to False to unload model after generation. Required for low VRAM workflows. |
| use_flash_attentionopt | BOOLEAN | false | Enable FlashAttention-2 (may not improve speed for small batch inference) |
| use_quantizationopt | BOOLEAN | false | Enable INT8 quantization for lower memory usage (slower inference) |
| top_popt | FLOAT | 0.900–1 | — |
| top_kopt | INT | 500–100 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| text | STRING | — |
| used_seed | INT | — |