ERNIE-Image Prompt Enhancer 3B: Standalone Deployment and Alternatives
ERNIE-Image ships with a built-in 3B-parameter Prompt Enhancer (PE), fine-tuned from Ministral 3B to expand short user prompts into detailed, structured descriptions. What many users don't realize is that this PE model can be used independently — even with other text-to-image models.
This practical guide shows you how to extract the PE model from the ERNIE-Image pipeline, deploy it standalone, and when to choose alternative prompt enhancement approaches.
What is the Prompt Enhancer?
ERNIE-Image's Prompt Enhancer is a standalone language model designed to solve one core problem: most users don't know how to write good prompts. Its workflow is straightforward:
User input "a cat" → PE (3B) → "A black-and-white Chinese田园 cat, crouching on a vintage bookshelf, warm-toned wooden background, soft natural light streaming in from a left window"
The PE output includes structured elements like scene description, lighting conditions, color palette, and composition. It excels at generating Chinese descriptions — even when the input is in English, the PE tends to produce bilingual detailed descriptions.
How to Deploy the PE Model
The PE model is distributed in safetensors format and can be obtained from HuggingFace or the official ComfyUI workflow.
Location: ernie-image-prompt-enhancer.safetensors in the baidu/ERNIE-Image HuggingFace repository.
Method 1: In ComfyUI
The official ERNIE-Image ComfyUI workflow includes a PE node:
- Load the ERNIE-Image workflow from ComfyUI examples
- The workflow includes a "Prompt Enhancer" text encoder node
- You can disable PE by setting
use_pe=Falseto compare results - The PE node output connects to CLIP Text Encode's text input
Method 2: In Diffusers
Control PE through the use_pe parameter:
from diffusers import ErnieImagePipeline
import torch
pipe = ErnieImagePipeline.from_pretrained(
"Baidu/ERNIE-Image",
torch_dtype=torch.bfloat16,
).to("cuda")
With PE enabled (default)
image_with_pe = pipe(prompt="a cat", use_pe=True).images[0]
Without PE
image_without_pe = pipe(
prompt="a black and white cat sitting on a vintage bookshelf...",
use_pe=False
).images[0]
Method 3: Standalone Loading
To use the PE model independently with other generation pipelines:
from transformers import AutoModelForCausalLM, AutoTokenizer
model = AutoModelForCausalLM.from_pretrained(
"baidu/ERNIE-Image",
subfolder="prompt_enhancer",
torch_dtype=torch.bfloat16
).to("cuda")
tokenizer = AutoTokenizer.from_pretrained(
"baidu/ERNIE-Image",
subfolder="prompt_enhancer"
)
prompt = "a cat sitting on a bookshelf"
inputs = tokenizer(prompt, return_tensors="pt").to("cuda")
with torch.no_grad():
outputs = model.generate(
**inputs,
max_new_tokens=256,
temperature=0.7,
do_sample=True
)
enhanced_prompt = tokenizer.decode(outputs[0], skip_special_tokens=True)
print(f"Enhanced: {enhanced_prompt}")
PE with Other Models
The community has explored several ways to pair PE with other models:
PE + Z-Image Turbo: Load both PE and Z-Image Turbo in Forge/Classic Neo. PE handles prompt enhancement, Z-Image handles generation. This combination delivers better Chinese prompt understanding with faster generation.
PE + Qwen3-4B: Use Qwen3-4B GGUF as a PE supplement for richer English descriptions.
PE + Post-processing: Let PE generate an enhanced prompt, then manually edit before feeding into any text-to-image model (SD 3.5, FLUX.2, etc.).
Using LLMs as PE Alternatives
The PE model is only 3B parameters — limited in capability. For complex scenarios, consider larger LLMs:
def enhance_prompt_with_llm(short_prompt, model="gemini"):
"""Use a large language model as a prompt enhancer"""
if model == "gemini":
enhanced = gemini_client.generate_content(
f"Enhance this image generation prompt into a detailed description "
f"including scene, lighting, colors, composition: {short_prompt}"
)
return enhanced.text
When to use LLMs instead of PE?
- Need precise control over output format
- Input contains multilingual or domain-specific terminology
- Need specific style references
- High instruction-following accuracy required (PE may reduce it)
PE On/Off Decision Guide
Based on benchmark data:
| Scenario | PE Recommended | Reason |
|---|---|---|
| Text rendering (posters/logos) | ✅ ON | PE improves text rendering accuracy |
| Complex instruction following | ❌ OFF | PE reduces instruction precision |
| Rapid prototyping | ✅ ON | Saves time writing detailed prompts |
| Batch production | ⚠️ Depends | OFF if prompts are already optimized |
| Multilingual prompts | ✅ ON | PE excels at bilingual scenarios |
| Professional domains (medical/industrial) | ❌ OFF | Needs precise domain-specific output |
PE Strengths and Limitations
Strengths:
- Lightweight (3B), runs on consumer GPUs
- Excellent at Chinese prompt enhancement
- Zero configuration, works out of the box
- Improves text rendering and diversity
Limitations:
- Based on Ministral 3B, not state-of-the-art for language
- May over-rewrite user input, deviating from original intent
- Text-only input (no image input support)
- Bias toward Chinese output even for non-Chinese inputs
Practical Recommendations
- During debugging: Start with
use_pe=Falseand detailed prompts, then decide whether to enable PE - In production: Choose PE strategy per scenario, not one-size-fits-all
- Advanced workflow: Use PE output as a starting point, then refine with LLMs
- Community knowledge: Follow r/StableDiffusion for community PE usage experiences
Summary
ERNIE-Image's Prompt Enhancer is an underappreciated tool. Though just a 3B-parameter model, it excels at Chinese prompt enhancement and text rendering. More importantly, it can be used standalone or paired with other models, giving developers flexible workflow options.
Whether you choose to use PE within the ERNIE-Image pipeline or extract it for use with other models, understanding how PE works and when to apply it will help you make better generation decisions.