NDM: A Noise-driven Detection and Mitigation Framework against Implicit Sexual Intentions in Text-to-Image Generation

Yitong Sun, Yao Huang, Ruochen Zhang, Huanran Chen, Shouwei Ruan, Ranjie Duan, Xingxing Wei

Introduction

Text-to-Image (T2I) models, such as Stable Diffusion, have demonstrated remarkable creative capabilities but remain vulnerable to generating Not-Safe-For-Work (NSFW) content. While explicit keywords are often filtered, a significant "safety gap" exists regarding implicit sexual intentions. These arise from latent biases in training data (where benign prompts like "Japanese girl" trigger sexualized outputs) or adversarial "jailbreak" attacks that use gibberish or wordplay to bypass text-based filters. Current defenses are often either too slow, requiring full image rendering before detection, or too blunt, degrading overall image quality by over-filtering safe prompts.

Methodology

The Noise-driven Detection and Mitigation (NDM) framework addresses these challenges by intervening at the earliest stage of the diffusion process. NDM operates in two distinct stages: detection and adaptive mitigation.

Stage I: Noise-based Detection

Researchers discovered that the "predicted noise" ($\epsilon_1$) generated in the very first step of the denoising process acts as a semantic fingerprint. This early-stage noise contains sufficient information to distinguish between safe and unsafe intent long before a human-recognizable image is formed. By training a fast classifier (utilizing PCA, LDA, and SVM) on this first-step noise, NDM can identify harmful intent in under a second.

The NDM detection module analyzes the first-step noise from the T2I model to identify implicit sexual intent.

Stage II: Adaptive Mitigation

Once a prompt is flagged, NDM employs two surgical strategies to steer the generation toward safety without modifying the model's weights:

  1. LLM-driven Negative Guidance: A Large Language Model (LLM) analyzes the input to generate context-specific negative instructions (e.g., "fully clothed") rather than generic filters.
  2. Initial Noise Optimization: By analyzing cross-attention maps, NDM identifies specific tokens driving the NSFW generation and optimizes the starting noise seed to suppress their influence.
NDM successfully detects and mitigates explicit sexual intentions that bypass traditional text-based guards.

Experimental Results

NDM was evaluated against challenging datasets including I2P and adversarial sets like SneakyPrompt and MMA-Diffusion.

  • Detection Accuracy: NDM achieved a 95.1% average detection accuracy, significantly outperforming standard text blacklists (43.2%) and the Stable Diffusion Safety Checker (57.4%).
  • Efficiency: Detection occurs in approximately 0.95 seconds, offering a massive speed advantage over post-generation image checkers.
  • Quality Preservation: On the COCO-30k baseline, NDM maintained a low FID score of 0.3, demonstrating that it does not degrade the quality of benign, safe images.

Conclusion

NDM provides a fast, surgical, and highly effective defense against implicit sexual content in T2I models. By treating early-stage noise as a semantic indicator of intent, the framework can "defuse" harmful prompts before they consume significant computational resources. Future work may extend this noise-driven logic to other safety domains, such as the detection of hate speech or extreme violence.

Summary updated

BibTeX
@inproceedings{sun2025ndm,
  author = {Yitong Sun and Yao Huang and Ruochen Zhang and Huanran Chen and Shouwei Ruan and Ranjie Duan and Xingxing Wei},
  title = {{NDM: A Noise-driven Detection and Mitigation Framework against Implicit Sexual Intentions in Text-to-Image Generation}},
  booktitle = {ACM Multimedia},
  year = {2025},
  doi = {10.1145/3746027.3755326},
}
Figure