Course contentsShow
← Machine Learning and Deep Learning
Lesson 1592 of 3,53834. Diffusion ModelsFree lesson

Negative Prompts

Using negative text prompts to steer generation away from undesired concepts via classifier-free guidance.

Negative Prompts

What you'll learn: How to use negative text prompts to tell a diffusion model what not to generate, steering it away from unwanted content.

The Core Idea

Remember classifier-free guidance, where you learned to amplify text conditioning? Negative prompts extend that concept. Instead of just saying "make this image match my prompt more," you can now say "match this prompt, but avoid that concept."

Think of it like giving directions: "Go toward the beach" (positive prompt) while also saying "but stay away from the highway" (negative prompt). The model navigates between attraction and repulsion.

How It Works with Classifier-Free Guidance

During sampling, classifier-free guidance already computes two predictions:

  • Conditional prediction: guided by your positive text prompt
  • Unconditional prediction: no text guidance (empty prompt)

Negative prompts add a third element:

  • Negative conditional prediction: guided by text describing what to avoid

The final prediction becomes:

final_noise = unconditional_noise 
            + guidance_scale * (positive_noise - unconditional_noise)
            - negative_scale * (negative_noise - unconditional_noise)

You're pushing away from the negative concept while pulling toward the positive one.

Practical Examples

  • Positive: "portrait of a woman"
    Negative: "blurry, low quality, distorted"
  • Positive: "fantasy landscape"
    Negative: "people, buildings, text"

The negative prompt helps eliminate common artifacts or unwanted elements that might otherwise appear.

Why This Matters

Negative prompts give you fine-grained control without retraining. They leverage the model's existing knowledge to subtract undesired concepts, significantly improving generation quality and user control.

Key Takeaway: Negative prompts use classifier-free guidance mechanics to steer diffusion models away from unwanted concepts, giving you both attraction and repulsion control over generation.