AI
New Method Improves Negative Guidance in AI Image Generation
Researchers propose a contrastive learning approach that better removes unwanted features from diffusion model outputs without distorting image quality.
A new technique called ContrastiveCFG offers a more effective way to guide diffusion models—AI systems used in image generation—to exclude unwanted visual concepts while preserving sample quality.
The Problem with Current Negative Prompting#
Traditional image generation uses Classifier-Free Guidance (CFG) to steer models toward desired conditions. To remove unwanted features, practitioners often employ a negated version of this guidance, known as Negative Prompting (NP). However, this simple inversion approach has a significant flaw: it distorts the underlying probability distribution of generated images, often producing samples that deviate from natural visual patterns.
How Contrastive Guidance Works#
Rather than inverting guidance signals, the new method leverages contrastive loss—a technique that learns by comparing similar and dissimilar examples. The approach works by aligning or pushing away the denoising direction (the AI's step-by-step refinement process) based on whether a concept should be included or excluded. This achieves the desired filtering effect for negative conditions while maintaining the sample quality that traditional CFG provides for positive ones.
Broader Applications#
Experimental validation shows that ContrastiveCFG successfully injects or removes specified concepts across multiple scenarios: from simple categorical conditions to intricate, overlapping text-based prompts. The findings suggest the method could improve control in diverse generative AI applications, making it easier to both add desired attributes and cleanly remove unwanted ones.
The research draws inspiration from recent advances in using conditional diffusion models for inverse problems—tasks where the goal is to reconstruct or modify images from partial information.

