NSFW-Classifier Guided Prompt Sanitization for Safe Text-to-Image Generation
On the map: LLM safety and security → Vision-language and text-to-image safety
Abstract (arXiv)
The rapid advancement of text-to-image (T2I) models, such as Stable Diffusion, has enhanced their capability to synthesize images from textual prompts. However, this progress also raises significant risks of misuse, including the generation of harmful content (e.g., pornography, violence, discrimination), which contradicts the ethical goals of T2I technology and hinders its sustainable development. Inspired by "jailbreak" attacks in large language models, which bypass restrictions through subtle prompt modifications, this paper proposes NSFW-Classifier Guided Prompt Sanitization (PromptSan), a novel approach to detoxify harmful prompts without altering model architecture or degrading generation capability. PromptSan includes two variants: PromptSan-Modify, which iteratively identifies and replaces harmful tokens in input prompts using text NSFW classifiers during inference, and PromptSan-Suffix, which trains an optimized suffix token sequence to neutralize harmful intent while passing both text and image NSFW classifier checks. Extensive experiments demonstrate that PromptSan achieves state-of-the-art performance in reducing harmful content generation across multiple metrics, effectively balancing safety and usability.
Key facts. Cited by 3 papers in the map (data through 14 Oct 2026). Placed in Vision-language and text-to-image safety, one of 12 directions in LLM safety and security. Builds on 37 of its 44 references that are in the map. First posted on arXiv 23 Jun 2025.
Builds on
37 of 44 references.
Closest ancestors · 4
Same direction, newest first
- 2025Unified Prompt Attack Against Text-to-Image Generation Models23 Feb
- 2025PromptGuard: Soft Prompt-Guided Unsafe Content Moderation for Text-to-Image Models7 Jan
- 2024Jailbreaking Prompt Attack: A Controllable Adversarial Attack against Diffusion Models2 Apr
- 2023Forget-Me-Not: Learning to Forget in Text-to-Image Diffusion Models30 Mar
Other references · 33
- 2021Learning Transferable Visual Models From Natural Language Supervisioncited by 33,744
- 2020Denoising Diffusion Probabilistic Modelscited by 21,076
- 2021High-Resolution Image Synthesis with Latent Diffusion Modelscited by 18,863
- 2014Microsoft COCO: Common Objects in Contextcited by 17,608
- 2022Training language models to follow instructions with human feedbackcited by 15,971
- 2014Explaining and Harnessing Adversarial Examplescited by 7,364
- 2022Hierarchical Text-Conditional Image Generation with CLIP Latentscited by 6,585
- 2017Towards Deep Learning Models Resistant to Adversarial Attackscited by 6,415
- 2022Photorealistic Text-to-Image Diffusion Models with Deep Language Understandingcited by 6,355
- 2013Intriguing properties of neural networkscited by 5,155
- 2023SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesiscited by 4,356
- 2021Zero-Shot Text-to-Image Generationcited by 4,288
21 more
- 2022LAION-5B: An open large-scale dataset for training next generation image-text modelscited by 4,152
- 2021The Power of Scale for Parameter-Efficient Prompt Tuningcited by 3,795
- 2022DreamBooth: Fine Tuning Text-to-Image Diffusion Models for Subject-Driven Generationcited by 3,300
- 2023Universal and Transferable Adversarial Attacks on Aligned Language Modelscited by 3,104
- 2020Learning to summarize from human feedbackcited by 2,588
- 2021LAION-400M: Open Dataset of CLIP-Filtered 400 Million Image-Text Pairscited by 1,555
- 2022Scaling Autoregressive Models for Content-Rich Text-to-Image Generationcited by 1,295
- 2022Imagic: Text-Based Real Image Editing with Diffusion Modelscited by 1,178
- 2022Ignore Previous Prompt: Attack Techniques For Language Modelscited by 832
- 2021GPT Understands, Toocited by 716
- 2023Erasing Concepts from Diffusion Modelscited by 539
- 2022Safe Latent Diffusion: Mitigating Inappropriate Degeneration in Diffusion Modelscited by 513
- 2023Unified Concept Editing in Diffusion Modelscited by 388
- 2023Ablating Concepts in Text-to-Image Diffusion Modelscited by 317
- 2024MACE: Mass Concept Erasure in Diffusion Modelscited by 307
- 2024Jailbreak Attacks and Defenses Against Large Language Models: A Surveycited by 230
- 2023MMA-Diffusion: MultiModal Attack on Diffusion Modelscited by 194
- 2023Selective Amnesia: A Continual Learning Approach to Forgetting in Deep Generative Modelscited by 177
- 2024Attacking Large Language Models with Projected Gradient Descentcited by 94
- 2024Soft Prompt Threats: Attacking Safety Alignment and Unlearning in Open-Source LLMs through the Embedding Spacecited by 91
- 2024Concept Replacer: Replacing Sensitive Concepts in Diffusion Models via Precision Localizationcited by 11
Built on by
Citing papers per year: 2026: 3.
3 papers.
Similar, not cited
Close in wording, no citation either way
- 2025Multimodal Prompt Decoupling Attack on the Safety Filters in Text-to-Image Models
- 2024Universal Prompt Optimizer for Safe Text-to-Image Generation
- 2026MacPrompt: Maraconic-guided Jailbreak against Text-to-Image Models
- 2024Multimodal Pragmatic Jailbreak on Text-to-image Models
- 2025TokenProber: Jailbreaking Text-to-image Models via Fine-grained Word Impact Analysis
- 2024Safe Text-to-Image Generation: Simply Sanitize the Prompt Embedding
- 2025SafeText: Safe Text-to-image Models via Aligning the Text Encoder
- 2025PurifyGen: A Risk-Discrimination and Semantic-Purification Model for Safe Text-to-Image Generation