Prompt Evolution for Generative AI: A Classifier-Guided Approach

Melvin Wong, Yew-Soon Ong, Abhishek Gupta, Kavitesh Kumar Bali, Caishun Chen

This paper introduces Prompt Evolution, a framework that uses multi-objective evolutionary algorithms to guide generative AI toward outputs that better satisfy complex user preferences. By treating the generative model itself as a mutation operator, the authors produce a diverse set of high-fidelity images that align more closely with target concepts than standard sampling or manual prompt engineering.

What Problem Does This Paper Address?

Text-to-image models like Stable Diffusion are powerful, but they often suffer from a "semantic disconnect." A user might provide a complex prompt with multiple concepts (e.g., "a person studying" + "a lamp" + "a sense of awe"), but the model might only capture one or two of these elements, or fail to relate them correctly.

Current solutions generally fall into two camps: Prompt Engineering (manually tweaking the text) or Fine-Tuning (retraining parts of the model). Both are labor-intensive and typically aim for a single "best" output. This ignores the inherent trade-offs in creative work—where a user might want to explore a variety of images that satisfy different aspects of their intent to varying degrees.

Methods

The authors propose a multi-objective evolutionary approach to bridge this gap:

  1. Fitness Function: They employ pre-trained multi-label classifiers to act as the "selection pressure." These classifiers predict the probability that specific user preferences (entities, scenes, or emotions) are present in a generated image.
  2. Mutation Operator: In a clever twist, the authors don't use standard mathematical noise for mutation. Instead, they use the conditional generative model ($\mathcal{G}$) itself. New "offspring" images are generated by conditioning the model on both the original prompt and an image from the previous generation.
  3. Selection Algorithm: They use NSGA-II, a classic multi-objective evolutionary algorithm, to maintain a population of images. It selects for images that maximize the classifier scores (objectives) while staying within a predefined distance from the original prompt (using CLIP embeddings as a constraint).

The iterative workflow is visualized in Figure 1: Workflow of prompt evolution with multi-label classifier-guided approach

Workflow of prompt evolution with multi-label classifier-guided approach

Datasets

The paper does not train a new generative model from scratch. Instead, it evaluates the framework using:

  • Generative Model: Pre-trained Stable Diffusion.
  • Guidance Models: CLIP for semantic constraints and various pre-trained multi-label classifiers for entity and emotion detection.
  • Evaluation Prompts: A custom set of prompts derived from "inspirational proverbs" (e.g., "Practice makes perfect") designed to test the model's ability to synthesize abstract concepts into concrete visual elements.

Key Insights and Ideas

  • Generative Models as Mutators: The most novel contribution is leveraging the stochastic nature of diffusion models as a built-in mutation operator. This ensures that "mutations" stay within the manifold of realistic-looking images, which standard Gaussian noise might destroy.
  • Pareto Diversity: Instead of converging on one image, the system finds a "Pareto frontier"—a set of images representing different optimal trade-offs between objectives. For example, one image might perfectly capture the "action" requested, while another might better capture the "emotion."
  • Efficiency over Brute Force: The paper demonstrates that evolutionary selection is far more efficient at finding high-quality, diverse images than simply generating thousands of random samples and hoping for the best.

Key Results

  • Quantitative Superiority: Prompt evolution achieved significantly higher Normalized Hypervolume (a metric for both quality and diversity of solutions) compared to brute-force sampling, even when the brute-force method included manual prompt engineering. Comparison of brute force approach versus Prompt Evolution
Comparison of brute force approach versus Prompt Evolution
  • Qualitative Improvement: The authors show how the population evolves over generations. In Figure 3, an initial population fails to capture the "person helping child" objective, but by the final generation, the algorithm finds multiple images that satisfy both "child riding bicycle" and "person helping" with different visual compositions. Evolution of images for the prompt 'family members teaching a child to ride a bicycle'
Evolution of images for the prompt 'family members teaching a child to ride a bicycle'
  • Concept Alignment: Table I illustrates clear wins. For the proverb "Practice makes perfect," the model initially generates just a lamp and a book. After evolution, it successfully incorporates the "person reading" objective into the scene. Examples of images before and after evolution
Examples of images before and after evolution

Limitations and Future Work

  • Computational Cost: The main drawback is the time and compute required. Running 20 generations of a diffusion model for a population of images is much slower than a single inference pass.
  • Classifier Bottleneck: The system is only as good as the classifiers guiding it. If the classifier misidentifies an emotion or object, the evolution will be steered in the wrong direction.
  • Expanding the Paradigm: The authors suggest that "Prompt Evolution" could be applied beyond images to audio or video generation, and could even evolve the text prompts themselves or latent embeddings rather than just the final pixel outputs.

Summary updated

BibTeX
@inproceedings{wong2023prompt,
  author = {Melvin Wong and Yew-Soon Ong and Abhishek Gupta and Kavitesh Kumar Bali and Caishun Chen},
  title = {{Prompt Evolution for Generative AI: A Classifier-Guided Approach}},
  booktitle = {CAI},
  year = {2023},
  url = {https://openreview.net/forum?id=Lej65zoDb8},
}
Figure