NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Understanding the Impact of Negative Prompts: When and How Do They Take Effect?

Yuanhao Ban, Ruochen Wang, Tianyi Zhou, Minhao Cheng, Boqing Gong, Cho-Jui Hsieh

TL;DR

This paper provides the first comprehensive study into how and when negative prompts, used to exclude elements in AI image generation, actually work. They discover negative prompts have a "delayed effect" and work by "neutralizing" positive prompts in the latent space, leading to a novel approach for controllable object removal in images.

What Problem Does This Paper Address?

Text-to-image diffusion models like Stable Diffusion have revolutionized image generation, but often produce outputs that don't perfectly match user intent. Negative prompts offer a way to guide these models by specifying what not to generate. While widely used, the underlying mechanisms of negative prompts remain poorly understood. This lack of understanding hinders the ability to design effective negative prompts and fully leverage their potential. This paper aims to demystify these mechanisms, answering the crucial questions: "When do negative prompts start to influence generation, and how do they achieve their effect?"

Methods

The authors conduct a systematic empirical study focusing on the dynamics of diffusion steps. They analyze cross-attention maps to pinpoint when negative prompts begin to influence the generation process, identifying a "critical step." To understand how they work, they investigate the interaction between positive and negative prompt signals within the diffusion model's architecture, particularly in the latent space. They propose a "Neutralization Hypothesis," suggesting negative prompts cancel out positive prompt signals. They also observe and explain a phenomenon called "Reverse Activation," where negative prompts introduced too early can paradoxically cause the undesired object to appear. Based on these insights, they develop a novel, training-free controllable inpainting method that strategically applies negative prompts after the critical step to remove objects while preserving background integrity.

Datasets

The paper mentions using standard text-to-image diffusion models, specifically Stable Diffusion v2. For evaluation and dataset construction, they adapt existing datasets: COCO, CC, MSVD, Places, Vatex, and Nocaps. They generate images from text prompts and then use GPT-4V to identify contained objects, which are then targeted for removal.

Key Insights and Ideas

  • Delayed Effect: Negative prompts don't immediately influence generation. There's a significant delay compared to positive prompts, with their impact often observed after the positive prompt has already started rendering the content.
  • Neutralization Through Cancellation: Negative prompts work by creating a "mutual cancellation effect" in the latent space with positive prompts. Essentially, they neutralize the signals from positive prompts that would otherwise lead to the generation of the undesired element.
  • Critical Step: There's a specific diffusion step (around step 5 for noun-based removal) where negative prompts become most effective. Applying them too early can lead to undesirable side effects like "Reverse Activation."
  • Reverse Activation: Introducing negative prompts very early in the diffusion process can paradoxically lead to the generation of the very object you're trying to exclude. This is explained by an "Inducing Effect" and "Momentum Effect" in the diffusion dynamics.
  • Strategic Application is Key: The timing of negative prompt application is crucial. Applying them too early can disrupt the image, while applying them after the "critical step" allows for effective object removal with minimal background alteration.

Key Results

  • Quantitative: The study identifies a critical step for noun-based negative prompts around step 5, where their effectiveness peaks. For adjective-based prompts, a plateau around step 10 indicates their influence after the object is formed. Their proposed inpainting method achieves high similarity to original images (up to 82.64% on average) and effective object removal without model retraining.
  • Qualitative: Visualizations of cross-attention maps clearly demonstrate the delayed effect of negative prompts. Successful object removal examples show earlier attention to target areas by negative prompts compared to failed attempts. The paper showcases their controllable inpainting method's ability to remove objects like "glasses," "potted plants," and "umbrellas" while preserving the main scene concept.

Limitations and Future Work

  • Limitations: The current study primarily focuses on noun-based removal and adjective-based refinement. The authors acknowledge that the "information lag" between positive and negative prompts is a challenge.
  • Future Work: The authors suggest exploring other parts of speech and tasks beyond object removal. They propose increasing interactions during the noise generation phase to mitigate the information lag. Additionally, they suggest investigating the use of negative prompts during the training process as a form of data augmentation to potentially enhance performance.

Summary updated

BibTeX
@misc{ban2024understanding,
  author = {Yuanhao Ban and Ruochen Wang and Tianyi Zhou and Minhao Cheng and Boqing Gong and Cho-Jui Hsieh},
  title = {{Understanding the Impact of Negative Prompts: When and How Do They Take Effect?}},
  year = {2024},
  eprint = {2406.02965},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.02965},
}
Figure