TL;DR
Text-to-image diffusion models can be easily tricked into generating inappropriate content using implicit or adversarial prompts that bypass standard text filters. NDM (Noise-driven Detection and Mitigation) solves this by identifying harmful intent at the very first denoising step and dynamically steering the generation away from explicit content using optimized initial noise and LLM-tailored negative prompts—all without degrading general image quality.
What Problem Does This Paper Address?
While text-to-image (T2I) models like Stable Diffusion excel at generating photorealistic imagery, they suffer from a major safety flaw: vulnerability to implicit sexual intentions. Unlike explicit prompts containing banned words, implicit prompts use seemingly benign phrases (e.g., "Japanese girl") that trigger underlying dataset biases to produce nudity. Worse still, malicious actors can use optimized adversarial tokens (e.g., gibberish words like "wdelhirosel") to completely evade safety filters.
Existing defenses fall into two flawed categories:
- Text-based filters miss implicit meanings and adversarial tokens because the raw text appears harmless.
- Image-based safety checkers (like CLIP-based post-filters) require the image to be fully generated before acting, introducing massive computational delays and a poor user experience.
Model-intrinsic methods (like fine-tuning or concept erasing) exist, but they often trigger an undesirable trade-off, severely degrading the model's ability to generate normal, benign images. NDM aims to bridge this gap by providing an efficient, highly accurate, and training-free framework for both detection and mitigation.
Methods
NDM splits its defense into a two-stage pipeline: Detection and Mitigation.
Stage I: Noise-Based Sexual Detection
Instead of waiting for a full image to generate, NDM looks at the predicted noise ($\epsilon_1$) at the very first denoising step. The authors discovered that the diffusion model's internal trajectory diverges immediately based on the prompt's underlying intent. NDM extracts this first-step noise, applies Principal Component Analysis (PCA) and Linear Discriminant Analysis (LDA) to reduce dimensionality, and uses a classical Support Vector Machine (SVM) classifier to determine if the prompt carries malicious intent.
Stage II: Noise-Enhanced Adaptive Mitigation
If the detector flags a prompt, NDM deploys a two-pronged mitigation strategy:
- Adaptive Negative Guidance: Rather than using generic negative prompts like "nudity," NDM passes the input prompt to a Large Language Model (LLM). The LLM analyzes the nouns, verbs, and adjectives to dynamically generate context-specific negative prompts tailored to what the model should avoid.
- Initial Noise Optimization: The random starting noise ($z_T$) heavily influences the final image structure. NDM optimizes this initial noise by calculating a cross-attention loss ($L_{cross}$) that suppresses the attention weights of dominant, harmful tokens. This provides a safer starting point for the diffusion process.
Datasets
The authors evaluated NDM across five sexual/adversarial datasets and one benign dataset:
- I2P (Implicit Text-to-Image Pornography): 931 prompts designed to trigger inappropriate imagery implicitly.
- SneakyPrompt (SP(N) and SP(P)): 200 natural and 200 pseudo adversarial prompts discovered via reinforcement learning.
- Ring-A-Bell: 79 prompts designed to test concept removal methods.
- MMA-Diffusion: 1,000 multimodal adversarial prompts.
- COCO-30k: 1,000 benign prompts used to evaluate how well the model preserves normal generation quality.
Key Insights and Ideas
- Early-Stage Noise Separability: The most surprising finding is that the diffusion model "knows" it is going to generate something explicit almost immediately. As shown via t-SNE visualizations, the predicted noise distributions for benign vs. harmful prompts are highly separable at Step 1, but this separability fades as denoising progresses.
- Initial Noise is a Safety Lever: The exact same prompt can yield perfectly safe or highly explicit images depending entirely on the random seed (initial noise $z_T$). By optimizing this noise matrix to weaken dominant token attention, the framework effectively steers the generation away from explicit pathways before they manifest.
Key Results
1. Detection Performance
NDM achieves an average detection accuracy of 95.1% across all natural and adversarial datasets, significantly outperforming Latent Guard (55.2%) and the standard Stable Diffusion Safety Checker (57.4%). Crucially, it processes samples in ~0.95 seconds, making it over 12x faster than image-space safety checkers (~12.26 seconds).
2. Mitigation Effectiveness
NDM reduces the Attack Success Rate (ASR) of malicious prompts by an average of over 85% compared to the base model. When paired with a detection-then-refusal setup, it drops the ASR to as low as 5.0%.
Unlike aggressive baselines like SLD-Max, which ruin image quality to ensure safety, NDM maintains a high CLIP Score (30.8) and an incredibly low FID score (0.3) on the benign COCO-30k dataset, proving it preserves creative potential.
Limitations and Future Work
While highly effective, NDM relies on an external LLM to generate adaptive negative prompts, which introduces slight operational overhead. Additionally, its core hyperparameter ($\alpha$), which controls the intensity of the cross-attention suppression, requires slight tuning depending on how explicit the target dataset is.
The authors suggest that future work could expand this noise-driven paradigm to detect and mitigate other critical safety hazards, such as violence, gore, and copyright infringement.
Summary updated