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 about this paper
Your agent reads all of it.
Lune indexed this paper to the last equation, along with the top-tier papers that cite it. Ask a question and the answer quotes them.
Your agent calls
Luneget_paper_fulltext
Free to start. No credit card required.
Terminal
Install the CLIlune papers fulltext 901a9338-6201-4643-a489-fa3b4bac694eCited by top-tier papers13
- SketchFlex: Facilitating Spatial-Semantic Coherence in Text-to-Image Generation with Region-Based SketchesHaichuan Lin, Yilin Ye, Jiazhi Xia, Wei ZengCHI 2025 · 25 citations
- SUB: Benchmarking CBM Generalization via Synthetic Attribute SubstitutionsJessica Bader, Leander Girrbach, Stephan Alaniz, Zeynep AkataICCV 2025 · 8 citations
- 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
- Attention to Neural Plagiarism: Diffusion Models Can Plagiarize Your Copyrighted Images!Zihang Zou, Boqing Gong, Liqiang WangICCV 2025 · 2 citations
- Preference-Guided Prompt Optimization for Text-to-Image GenerationZhipeng Li, Yi-Chi Liao, Christian HolzCHI 2026 · 1 citation
Builds on22
- Learning Transferable Visual Models From Natural Language SupervisionAlec Radford, Jong Wook Kim, Chris Hallacy, Aditya Ramesh et al.ICML 2021 · 47,906 citations
- Denoising Diffusion Probabilistic ModelsJonathan Ho, Ajay Jain, Pieter AbbeelNeurIPS 2020 · 35,902 citations
- Training language models to follow instructions with human feedbackLong Ouyang, Jeffrey Wu, Xu Jiang, Diogo Almeida et al.NeurIPS 2022 · 24,707 citations
- Diffusion Models Beat GANs on Image SynthesisPrafulla Dhariwal, Alexander Quinn NicholNeurIPS 2021 · 13,211 citations
- High-Resolution Image Synthesis with Latent Diffusion ModelsRobin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser et al.CVPR 2022 · 13,123 citations
Related papers
- Prompting Hard or Hardly Prompting: Prompt Inversion for Text-to-Image Diffusion ModelsShweta Mahajan, Tanzila Rahman, Kwang Moo Yi, Leonid SigalCVPR 2024 · 12 citations
- 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
- 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
- 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
- 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
