π Qwen Prompt Expander
A small LLM writes your prompts on your own GPU
- positive_prompt
- negative_prompt
The name undersells it. QwenOfflinePrompt isn't a Qwen wrapper you configure - it's a tiny art-director LLM inside your ComfyUI install that turns "cyberpunk girl" into a full comma-separated prompt with zero API calls and zero keys. After the first model download, nothing leaves your machine. Same idea as asking ChatGPT to improve your prompt, minus the clipboard dance, the per-token bill, and your subject text sitting in someone's telemetry.
The trend it rides is real. LLM-assisted prompting went from browser-tab novelty to routine (corpus mentions of "prompt enhancer" grew from 12 in 2023 to 253 in the first half of 2026), and it fits the new architecture: if a model's text encoder reads your prompt as an instruction, an LLM writing that instruction is translation between two things that speak the same language.
How it works
The node loads a small instruct model through HuggingFace transformers - presets cover Qwen2.5-0.5B/1.5B, SmolLM2-1.7B, Dolphin, TinyLlama, Phi-3-mini and Llama-3.2-1B - quantizes it with bitsandbytes (4-bit nf4 or 8-bit), and runs a fixed system prompt cast as a "Creative Art Director for Stable Diffusion": emit comma-separated tags, no chat, no JSON, stay near max_tokens. Generation runs at temperature 0.8 with a repetition penalty; the output gets headers and duplicates stripped, and a "smart trim" cuts long responses back to budget while preferentially keeping tags that mention your subject. Selected emb_positive/emb_negative embeddings are prepended as embedding:name.
The outputs are two strings: positive_prompt and negative_prompt, wired into a CLIP Text Encode node's positive and negative inputs. No image generation here - it's a prompt-writing front end.
The inputs that matter
Most of the dropdowns you can leave alone. The ones you actually touch:
- subject - your concept, one line ("knight eating pizza"). This is the whole point of the node.
- preset_model and precision - SmolLM2-1.7B at 8-bit is the sane default. 4-bit (~1.2GB VRAM) if you're on 6GB; fp16 if you want max quality and have the headroom. Phi-3-mini wants 12GB.
- max_tokens - 60-80 for SD 1.5, 100-150 for SDXL/Flux-class. Higher just means a longer, often more padded prompt.
- unload_model - the VRAM lever.
False(default) caches the LLM in VRAM for ~instant repeats;Truefrees it after each generation so it doesn't fight your checkpoint. On a 6GB card you wantTrue. - seed - 0 for random, anything else for roughly reproducible output (temperature 0.8 means "roughly", not exactly).
- use_translator_PL_EN - only if you want to write subjects in Polish; it fires an offline MarianMT model on first use (~300MB).
style / lighting / quality are SD-era vocabulary - "8k, Masterpiece", "RAW Photo", "Unreal Engine 5" - exactly right for SD 1.5 or SDXL, which the defaults assume. But the KB's finding stands: quality tags are inert on LLM-encoded models (Flux 2 Klein, Z-Image, Anima), so on those, set quality to Disabled and let the model speak prose. A wasted "masterpiece" token is budget you can't spend on your description.
Installing it
The easy way: ComfyUI Manager β search "Qwen Prompt Expander" β Install β restart. Manual:
cd ComfyUI/custom_nodes
git clone https://github.com/AnonBOTpl/ComfyUI-Qwen-Prompt-Expander.git
cd ComfyUI-Qwen-Prompt-Expander
pip install -r requirements.txt
The requirements are sentencepiece, sacremoses, accelerate, and bitsandbytes>=0.43.1. Here's the trap: transformers isn't in there, and the node can't run without it - if your env lacks it, pip install transformers fixes the ImportError. Models auto-download to ComfyUI/models/LLM/ on first use: 5-10 minutes, ~10GB for every preset, then fully offline.
Where people get burned
On Windows, bitsandbytes often won't import; the README's wheel workaround installs 0.41.1 against a >=0.43.1 pin, so it can conflict with pip. Without it the node silently falls back to fp16 (~3.5GB), quietly undoing the low-VRAM pitch. Watch the console for the "BRAK bitsandbytes" warning before blaming OOM.
If you do OOM: 4-bit precision, unload_model True, max_tokens 60, and only then CPU mode.
One honest caveat: this pack is small and young (Feb 2026), and its launch thread met real pushback - "don't install this, it'll break your ComfyUI", vibecoding accusations, one user who never got downloads working. The mechanism is real and others report it fine, but the ecosystem's malware history means you should treat any fresh node pack as untrusted until you've read its source. And if you already run Ollama or LM Studio, a connector to those is lighter than pulling the whole transformers/bitsandbytes stack in for the same job. But for a self-contained, keyless, offline expander on an SD 1.5/SDXL workflow, this does what it says - run the diagnostics node first.
Inputs (18)
| Name | Type | Default | Description |
|---|---|---|---|
| model_source | COMBO | Preset Models | 3 options: Preset Models, Custom HuggingFace ID, Local Path |
| preset_model | COMBO | HuggingFaceTB/SmolLM2-1.7B-Instruct (~1.7B - Recommended) | 7 options: HuggingFaceTB/SmolLM2-1.7B-Instruct (~1.7B - Recommended), Qwen/Qwen2.5-0.5B-Instruct (~0.5B - Ultra Light), Qwen/Qwen2.5-1.5B-Instruct (~1.5B - Balanced), cognitivecomputations/dolphin-2.9.4-qwen2.5-1.5b (~1.5B - Uncensored), TinyLlama/TinyLlama-1.1B-Chat-v1.0 (~1.1B - Fast), microsoft/Phi-3-mini-4k-instruct (~3.8B - Quality, needs 12GB VRAM), +1 |
| custom_model_id | STRING | β | |
| precision | COMBO | 8-bit (Fast) | 3 options: fp16 (Standard), 8-bit (Fast), 4-bit (Ultra Light) |
| subject | STRING | beautiful scenery nature glass bottle landscape, purple galaxy bottle | β |
| negative_prompt_text | STRING | ugly, deformed, noisy, blurry, low quality, watermark, text, bad anatomy, bad hands, missing fingers, extra limbs | β |
| style | COMBO | 8 options: Disabled, Photorealistic, Cyberpunk, Dark Fantasy, Anime, Oil Painting, +2 | |
| lighting | COMBO | 6 options: Disabled, Cinematic Lighting, Studio Softbox, Golden Hour, Neon Lights, Dark & Moody | |
| quality | COMBO | 5 options: Disabled, 8k, Masterpiece, RAW Photo, Unreal Engine 5, Sharp Focus | |
| max_tokens | INT | 8020β500 | β |
| emb_positive | COMBO | None | 1 options: None |
| emb_negative | COMBO | None | 1 options: None |
| device_mode | COMBO | GPU (Fast) | 2 options: GPU (Fast), CPU (Safe Mode) |
| translator_device | COMBO | CPU (Stable) | 2 options: CPU (Stable), GPU (Faster) |
| use_translator_PL_EN | BOOLEAN | false | β |
| unload_model | BOOLEAN | false | β |
| add_negative | BOOLEAN | true | β |
| seed | INT | 00β18446744073709550000 | β |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| positive_prompt | STRING | β |
| negative_prompt | STRING | β |