XX_Hunyuan_PromptEnhancer
A local LLM that rewrites your prompt into structured prose — no API, no key
- string
The name is a lie in the best possible way: this node doesn't call any API and needs no key. It runs Tencent's Hunyuan PromptEnhancer - the "reprompt" LLM that ships inside the HunyuanImage 2.1 release - right on your GPU, takes whatever half-baked prompt you type, and hands back a clean, layered, globally-structured version. This is leeooo001's unofficial ComfyUI wrapper around the official PromptEnhancer project.
Why would you want that? Because 2026 image models changed what a prompt is. On the modern LLM-encoded family - Z-Image, Flux 2 Klein, ERNIE, HunyuanImage itself - your prompt isn't a token bag anymore, it's an instruction. Structure wins. Tencent's rewriter bakes in the "global–details–summary" shape those models reward: primary elements first, then secondary and background, then a one-line style/type summary, all while preserving subject, action, quantity, layout, and relations. If your prompts are two words and a prayer, or you're bouncing between Chinese and English, this is the training-wheels-free way to get consistent prose.
How it works
Under the hood it's a plain HuggingFace causal LM. On each run the node loads the model from the path in ckpts.yaml (bfloat16, trust_remote_code=True), wraps your text in a chat template with thinking mode off, generates, then parses with a strict priority: grab <answer>...</answer> if present, otherwise strip the <think>...</think> block, otherwise hand your original text back. Any exception in that chain does the same. So the failure mode is never an empty box - it's "you get your prompt back unchanged," which is the same thing, just quieter.
The inputs that matter
Of the seven required inputs, a beginner realistically touches three:
- text - your actual prompt. This is the thing being rewritten. Despite the name, this is your input, not the system prompt.
- prompt - the system instruction. It defaults to a Chinese "you are a prompt-writing expert" spec, and it works fine as-is. English input gets English output, Chinese gets Chinese, per the README.
- models -
int8orfp16. This maps to which path inckpts.yamlgets loaded, not to which file you download.
temperature, top_p, max_new_tokens, seed also exist on the node, and here's the honest gotcha: in the shipped code they're accepted but ignored. run() hardcodes 0.7 / 0.9 / 256 in the predict call, and the seed's torch Generator is created and never used. Don't expect the seed to reproduce anything - it won't.
The single output, string, is your rewritten prompt. Wire it into a CLIPTextEncode's text input, or the prompt slot of any LLM-encoded model you're using.
Installing it
It's in ComfyUI Manager (search "Hunyuan-PromptEnhancer"), or clone it:
cd ComfyUI/custom_nodes
git clone https://github.com/leeooo001/comfyui-Hunyuan-PromptEnhancer
Restart ComfyUI. No extra Python packages are strictly needed - the node only imports torch, transformers, and omegaconf, all of which ComfyUI already ships; the official repo's heavier requirements (qwen-vl-utils, google-genai) are for other parts of that project, not this node.
The real install is the model. Download one of these anywhere on disk:
# fp16 (24GB VRAM) - official
git lfs clone https://huggingface.co/tencent/HunyuanImage-2.1 # grab the reprompt/ folder
# or int8 (~10GB VRAM) - the author's own quant
git lfs clone https://huggingface.co/leeooo001/Hunyuan-PromptEnhancer-INT8
Then edit custom_nodes/comfyui-Hunyuan-PromptEnhancer/ckpts.yaml - it ships pointing at the author's own X:/AIGC/... paths, which won't exist on your machine. Set modelpath_fp16 and/or modelpath_int8 to your local folders and restart.
Common issues
- It's slow per run. The model loads from disk on every execution - there's no caching. On int8 that's ~10GB to move, on fp16 ~24GB. Batch your edits; don't chain three of these together.
- VRAM. int8 wants about 10GB, fp16 wants 24GB - on top of whatever your image model needs. The community's been asking for a GGUF of this thing precisely because 10–24GB of extra load for a rewriter is a lot.
- You may just not like the output. In the announcement thread, real users reported the rewritten prompt being flat-out worse than what they wrote, and plenty of people distrust prompt-enhancers on principle - you're giving up direct control of the input. The fallback-to-original behavior means trying it costs you nothing, though.
- Licensing. The weights ship under Tencent's Hunyuan Community License, which excludes the EU, UK, and South Korea. In one of those? Non-starter, no matter how good the rewrites are.
One more note: the category and class name both use "XX" - the author shipped it with placeholder naming. Cosmetic, but it tells you the polish level you're getting.
Inputs (7)
| Name | Type | Default | Description |
|---|---|---|---|
| models | COMBO | 2 options: int8, fp16 | |
| temperature | FLOAT | 0.700–100 | — |
| top_p | FLOAT | 0.900–100 | — |
| max_new_tokens | INT | 2560–99999 | — |
| seed | INT | 00–18446744073709550000 | — |
| prompt | STRING | 你是一位图像生成提示词撰写专家,请根据用户输入的提示词,改写生成新的提示词,改写后的提示词要求:1 改写后提示词包含的主体/动作/数量/风格/布局/关系/属性/文字等 必须和改写前的意图一致; 2 在宏观上遵循“总-分-总”的结构,确保信息的层次清晰;3 客观中立,避免主观臆断和情感评价;4 由主到次,始终先描述最重要的元素,再描述次要和背景元素;5 逻辑清晰,严格遵循空间逻辑或主次逻辑,使读者能在大脑中重建画面;6 结尾点题,必须用一句话总结图像的整体风格或类型。 | — |
| text | STRING | — |
Outputs (1)
| Name | Type | Description |
|---|---|---|
| string | STRING | — |