BeautifulPrompt: Towards Automatic Prompt Engineering for Text-to-Image Synthesis

Tingfeng Cao, Chengyu Wang, Bingyan Liu, Ziheng Wu, Jinhui Zhu, Jun Huang

Introduction

Generating high-quality images with diffusion models like Stable Diffusion or Midjourney remains a significant challenge for non-expert users. The process typically requires "prompt engineering"—the manual addition of specific modifiers such as "8k," "highly detailed," or "trending on Artstation" to achieve professional-grade results. Without these modifiers, simple descriptions often yield flat and uninspired imagery.

Figure 4: A flat, uninspired image generated from a simple prompt like "a majestic sailing ship."

This "surprise box" effect forces users into a costly cycle of trial-and-error. While Large Language Models (LLMs) like ChatGPT can expand prompts, they are not inherently optimized for the visual nuances of image generators and may introduce irrelevant details that confuse the diffusion model.

Methodology: Reinforcement Learning with Visual AI Feedback (RLVAIF)

BeautifulPrompt addresses these issues by automatically transforming simple text descriptions into sophisticated prompts. The system employs a three-stage pipeline:

  1. Dataset Bootstrapping: Utilizing DiffusionDB, the researchers created 143,000 "low-quality to high-quality" prompt pairs. Tools like BLIP were used to generate captions for complex images, while ChatGPT summarized long prompts into simplified versions.
  2. Supervised Fine-Tuning (SFT): A BLOOM (1.1B) model was fine-tuned on this dataset to learn the basic syntax and grammar of high-quality prompts.
  3. RLVAIF Optimization: The core innovation is the use of Reinforcement Learning with Visual AI Feedback. Instead of human feedback, the model is optimized using two visual reward signals: PickScore (human preference alignment) and Aesthetic Score (visual beauty). The prompt generator is trained via Proximal Policy Optimization (PPO) to maximize these scores by generating images through a text-to-image model in the training loop.

Dataset and Transferability

The authors introduced the BeautifulPrompt Dataset, featuring 143k prompt pairs across categories like captions and summaries. A key finding is the model's transferability; although trained using Stable Diffusion 1.5 as the visual judge, the optimized prompts perform exceptionally well on other architectures like Deliberate or Realistic Vision, suggesting a universal quality to effective prompting.

Experimental Results

BeautifulPrompt significantly outperforms baselines such as MagicPrompt and ChatGPT-enhanced prompts.

Figure 6: A high-quality, detailed image generated using a prompt optimized by BeautifulPrompt.

Quantitatively, the model achieved superior scores in PickScore (20.84) and Aesthetic Score (6.52). In human evaluations, experts preferred BeautifulPrompt's outputs over original simple prompts 70% of the time and over ChatGPT-enhanced prompts 59% of the time. This efficiency reduces computational waste by providing high-quality results in fewer iterations.

Limitations and Conclusion

Despite its success, the model faces challenges such as semantic drift, where the LLM may add details that deviate from the user's original intent. Additionally, the reliance on multiple AI models (BLIP, ChatGPT, PickScore) can lead to bias accumulation. Future research will focus on improving "prompt faithfulness" to ensure that aesthetic enhancements do not compromise the core meaning of the user's original request.

Summary updated

BibTeX
@inproceedings{cao2023beautifulprompt,
  author = {Tingfeng Cao and Chengyu Wang and Bingyan Liu and Ziheng Wu and Jinhui Zhu and Jun Huang},
  title = {{BeautifulPrompt: Towards Automatic Prompt Engineering for Text-to-Image Synthesis}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-industry.1},
}
Figure