Lune

ICML2024Top-tier venue

On Discrete Prompt Optimization for Diffusion Models

Ruochen Wang, Ting Liu, Cho-Jui Hsieh, Boqing Gong

Abstract

This paper introduces the first gradient-based framework for prompt optimization in text-to-image diffusion models. We formulate prompt engineering as a discrete optimization problem over the language space. Two major challenges arise in efficiently finding a solution to this problem: (1) Enormous Domain Space: Setting the domain to the entire language space poses significant difficulty to the optimization process. (2) Text Gradient: Efficiently computing the text gradient is challenging, as it requires backpropagating through the inference steps of the diffusion model and a non-differentiable embedding lookup table. Beyond the problem formulation, our main technical contributions lie in solving the above challenges. First, we design a family of dynamically generated compact subspaces comprised of only the most relevant words to user input, substantially restricting the domain space. Second, we introduce"Shortcut Text Gradient"-- an effective replacement for the text gradient that can be obtained with constant memory and runtime. Empirical evaluation on prompts collected from diverse sources (DiffusionDB, ChatGPT, COCO) suggests that our method can discover prompts that substantially improve (prompt enhancement) or destroy (adversarial attack) the faithfulness of images generated by the text-to-image diffusion model.

Ask Lune

Know this paper in minutes, not an afternoon.

Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.

13 top-tier papers have cited it since. Know what they found before your reviewers do.

Questions to start from

Lune can draw on

the full paper · the top-tier papers that cite it · related work

Get the answer

Free to start. No credit card required.

Lineage

  • High-Resolution Image Synthesis with Latent Diffusion Models cites Diffusion Models Beat GANs on Image Synthesis
  • High-Resolution Image Synthesis with Latent Diffusion Models cites Denoising Diffusion Probabilistic Models
  • Prompt-A-Video: Prompt your Video Diffusion Model via Preference-Aligned LLM cites High-Resolution Image Synthesis with Latent Diffusion Models
  • Prompt-A-Video: Prompt your Video Diffusion Model via Preference-Aligned LLM cites Learning Transferable Visual Models From Natural Language Supervision
  • SketchFlex: Facilitating Spatial-Semantic Coherence in Text-to-Image Generation with Region-Based Sketches cites High-Resolution Image Synthesis with Latent Diffusion Models
  • SUB: Benchmarking CBM Generalization via Synthetic Attribute Substitutions cites High-Resolution Image Synthesis with Latent Diffusion Models
  • SUB: Benchmarking CBM Generalization via Synthetic Attribute Substitutions cites Learning Transferable Visual Models From Natural Language Supervision
  • Diffusion Models Beat GANs on Image Synthesis cites Learning Transferable Visual Models From Natural Language Supervision
  • Diffusion Models Beat GANs on Image Synthesis cites Denoising Diffusion Probabilistic Models
  • Preference-Guided Prompt Optimization for Text-to-Image Generation cites High-Resolution Image Synthesis with Latent Diffusion Models
  • Preference-Guided Prompt Optimization for Text-to-Image Generation cites Diffusion Models Beat GANs on Image Synthesis
  • Preference-Guided Prompt Optimization for Text-to-Image Generation cites Learning Transferable Visual Models From Natural Language Supervision
  • Attention to Neural Plagiarism: Diffusion Models Can Plagiarize Your Copyrighted Images! cites High-Resolution Image Synthesis with Latent Diffusion Models
  • Attention to Neural Plagiarism: Diffusion Models Can Plagiarize Your Copyrighted Images! cites Learning Transferable Visual Models From Natural Language Supervision
  • Attention to Neural Plagiarism: Diffusion Models Can Plagiarize Your Copyrighted Images! cites Denoising Diffusion Probabilistic Models
Builds onCited byLeft to right by year; the more cited, the higher.

Cited by top-tier papers13

  1. SketchFlex: Facilitating Spatial-Semantic Coherence in Text-to-Image Generation with Region-Based SketchesHaichuan Lin, Yilin Ye, Jiazhi Xia, Wei ZengCHI 2025 · 25 citations
  2. SUB: Benchmarking CBM Generalization via Synthetic Attribute SubstitutionsJessica Bader, Leander Girrbach, Stephan Alaniz, Zeynep AkataICCV 2025 · 8 citations
  3. Prompt-A-Video: Prompt your Video Diffusion Model via Preference-Aligned LLMYatai Ji, Jiacheng Zhang, Jie Wu, Shilong Zhang et al.ICCV 2025 · 3 citations
  4. Attention to Neural Plagiarism: Diffusion Models Can Plagiarize Your Copyrighted Images!Zihang Zou, Boqing Gong, Liqiang WangICCV 2025 · 2 citations
  5. Preference-Guided Prompt Optimization for Text-to-Image GenerationZhipeng Li, Yi-Chi Liao, Christian HolzCHI 2026 · 1 citation

Builds on22

  1. Learning Transferable Visual Models From Natural Language SupervisionAlec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh et al.ICML 2021 · 47,906 citations
  2. Denoising Diffusion Probabilistic ModelsJonathan Ho, Ajay Jain, Pieter AbbeelNeurIPS 2020 · 35,902 citations
  3. Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida et al.NeurIPS 2022 · 24,707 citations
  4. Diffusion Models Beat GANs on Image SynthesisPrafulla Dhariwal, Alexander Quinn NicholNeurIPS 2021 · 13,211 citations
  5. High-Resolution Image Synthesis with Latent Diffusion ModelsRobin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser et al.CVPR 2022 · 13,123 citations

Related papers

  1. Prompting Hard or Hardly Prompting: Prompt Inversion for Text-to-Image Diffusion ModelsShweta Mahajan, Tanzila Rahman, Kwang Moo Yi, Leonid SigalCVPR 2024 · 12 citations
  2. Hard Prompts Made Easy: Gradient-Based Discrete Optimization for Prompt Tuning and DiscoveryYuxin Wen, Neel Jain, John Kirchenbauer, Micah Goldblum et al.NeurIPS 2023 · 454 citations
  3. Prompt-Free Diffusion: Taking "Text" Out of Text-to-Image Diffusion ModelsXingqian Xu, Jiayi Guo, Zhangyang Wang, Gao Huang et al.CVPR 2024 · 45 citations
  4. Interpretable Prompts made Edit-Friendly: Token-to-Token Similarity Reduction in dLLMs for Edit-Friendly Hard Prompt InversionNaresh Kumar Devulapally, Shruti Agarwal, Vishal Asnani, Vishnu Suresh LokhandeCVPR 2026
  5. DiffusionDB: A Large-scale Prompt Gallery Dataset for Text-to-Image Generative ModelsZijie J. Wang, Evan Montoya, David Munechika, Haoyang Yang et al.ACL 2023 · 149 citations
Dusk over the sea between two cliffs drawn in fine vertical lines