# PromptEnhancer

> Prompt-rewriting tool from Tencent Hunyuan that turns short prompts into clearer, structured ones for text-to-image generation and image-editing instructions.

PromptEnhancer is a prompt-rewriting utility from the Tencent Hunyuan team. It rewrites user prompts into clearer, more structured versions for text-to-image generation and refines image-to-image editing instructions using the input image as context. The project is published as an open-source repository with a technical report (arXiv:2509.04545), model weights on Hugging Face, and a benchmark dataset.

## What It Is

PromptEnhancer is a Chain-of-Thought prompt rewriter that sits in front of a text-to-image model. It restructures an input prompt while preserving the original intent, such as subject, action, style, layout and attributes. The framework decouples the rewriter from the generator, so according to the project it can enhance a pretrained T2I model without modifying that model's weights.

## How It Works

The tech report describes a two-stage training process. First, the rewriter is initialized with supervised fine-tuning on (user prompt, reprompt) pairs. Then it is aligned with GRPO-based reinforcement learning, where candidate reprompts are rendered by a frozen T2I model and scored by a reward model called AlignEvaluator. AlignEvaluator uses a taxonomy of 24 key points drawn from common T2I failure modes such as attribute binding, negation and compositional relationships. The authors report evaluations on HunyuanImage 2.1 and release a human-preference benchmark, T2I-Keypoints-Eval.

## Models and Usage

The repository provides Python inference classes for three paths: text-only enhancement with Transformers (7B and 32B), image-editing instruction enhancement with a vision-language model, and quantized GGUF models run through llama.cpp for lower memory use. Models are downloaded through the Hugging Face CLI. Generation parameters such as temperature, top_p and max_new_tokens can be adjusted, and prompts can be in Chinese or English. A multi-level fallback mechanism is described for robust output parsing.

## Licensing Notes

The code is released under the Tencent Hunyuan Community License Agreement, which limits use to a defined territory that excludes the European Union, United Kingdom and South Korea, and includes an acceptable use policy.

## Features
- Text-to-image prompt rewriting
- Image-to-image editing instruction refinement with visual context
- Intent preservation across rewriting
- Chain-of-Thought rewriter trained with SFT and GRPO
- AlignEvaluator reward model with 24 key-point taxonomy
- Multi-level fallback output parsing
- 7B and 32B full-precision models
- Quantized GGUF models (Q8_0, Q6_K, Q4_K_M) via llama.cpp
- T2I-Keypoints-Eval benchmark and evaluation script
- Chinese and English prompt support

## Integrations
Hugging Face, HunyuanImage 2.1, Transformers, llama.cpp, Qwen2.5-VL

## Platforms
LINUX, API, DEVELOPER_SDK, CLI

## Pricing
Free

## Links
- Website: https://hunyuan-promptenhancer.github.io/
- Documentation: https://github.com/Hunyuan-PromptEnhancer/PromptEnhancer
- Repository: https://github.com/Hunyuan-PromptEnhancer/PromptEnhancer
- EveryDev.ai: https://www.everydev.ai/tools/promptenhancer
