PurifyGen: A Risk-Discrimination and Semantic-Purification Model for Safe Text-to-Image Generation
Zongsheng Cao, Yangfan He, Anran Liu, Jun Xie, Zhepeng Wang, Feng Chen
Abstract
Recent advances in diffusion models have notably enhanced textto-image (T2I) generation quality, but they also raise the risk of generating unsafe content. Traditional safety methods like text blacklisting or harmful content classification have significant drawbacks: they can be easily circumvented or require extensive datasets and extra training. To overcome these challenges, we introduce Pu-rifyGen, a novel, training-free approach for safe T2I generation that retains the model's original weights. PurifyGen introduces a dual-stage strategy for prompt purification. First, we evaluate the safety of each token in a prompt by computing its complementary semantic distance, which measures the semantic proximity between the prompt tokens and concept embeddings from predefined toxic and clean lists. This enables fine-grained prompt classification without explicit keyword matching or retraining. Tokens closer to toxic concepts are flagged as risky. Second, for risky prompts, we apply a dual-space transformation: we project toxic-aligned embeddings into the null space of the toxic concept matrix, effectively removing harmful semantic components, and simultaneously align them into the range space of clean concepts. This dual alignment purifies risky prompts by both subtracting unsafe semantics and reinforcing safe ones, while retaining the original intent and coherence. We further define a token-wise strategy to selectively replace only risky token embeddings, ensuring minimal disruption to safe content. PurifyGen offers a plug-and-play solution with theoretical grounding and strong generalization to unseen prompts and models. Extensive testing shows that PurifyGen surpasses current methods in reducing unsafe content across five datasets and competes well with training-dependent approaches. The code can refer to https://github.com/AI-Researcher-Team/PurifyGen.
Ask Lune
Know this paper in minutes, not an afternoon.
Lune can read every page of it and the top-tier papers that cite it, and gives you its claims, its evidence and its limits, each one cited to the paper it comes from. No skimming, no AI slop.
3 top-tier papers have cited it since. Know what they found before your reviewers do.
Lune can draw on
the full paper · the top-tier papers that cite it · related work
Free to start. No credit card required.
Lineage
- High-Resolution Image Synthesis with Latent Diffusion Models cites Denoising Diffusion Probabilistic Models
- SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis cites High-Resolution Image Synthesis with Latent Diffusion Models
- SDXL: Improving Latent Diffusion Models for High-Resolution Image Synthesis cites Denoising Diffusion Probabilistic Models
- RaDAR: Relation-aware Diffusion-Asymmetric Graph Contrastive Learning for Recommendation cites Denoising Diffusion Probabilistic Models
- Simple and Controllable Music Generation cites High-Resolution Image Synthesis with Latent Diffusion Models
- VideoTrace-R1: Long Video-based Retrieval-Augmented Generation via Reinforcement Learning cites RaDAR: Relation-aware Diffusion-Asymmetric Graph Contrastive Learning for Recommendation
- VideoTrace-R1: Long Video-based Retrieval-Augmented Generation via Reinforcement Learning cites ViG-RAG: Video-aware Graph Retrieval-Augmented Generation via Temporal and Semantic Hybrid Reasoning
Cited by top-tier papers3
- ViG-RAG: Video-aware Graph Retrieval-Augmented Generation via Temporal and Semantic Hybrid ReasoningZongsheng Cao, Anran Liu, Yangfan He, Jing Li et al.AAAI 2026 · 1 citation
- RaDAR: Relation-aware Diffusion-Asymmetric Graph Contrastive Learning for RecommendationYixuan Huang, Jiawei Chen, Shengfan Zhang, Zongsheng CaoWWW 2026
- VideoTrace-R1: Long Video-based Retrieval-Augmented Generation via Reinforcement LearningZongsheng Cao, Anran Liu, Jun Xie, Feng Chen et al.ICML 2026
Builds on28
- Language Models are Few-Shot LearnersTom B. Brown, Benjamin Mann, Nick Ryder, Melanie Subbiah et al.NeurIPS 2020 · 64,255 citations
- Denoising Diffusion Probabilistic ModelsJonathan Ho, Ajay Jain, Pieter AbbeelNeurIPS 2020 · 35,902 citations
- High-Resolution Image Synthesis with Latent Diffusion ModelsRobin Rombach, Andreas Blattmann, Dominik Lorenz, Patrick Esser et al.CVPR 2022 · 13,123 citations
- SDXL: Improving Latent Diffusion Models for High-Resolution Image SynthesisDustin Podell, Zion English, Kyle Lacey, Andreas Blattmann et al.ICLR 2024 · 4,569 citations
- Simple and Controllable Music GenerationJade Copet, Felix Kreuk, Itai Gat, Tal Remez et al.NeurIPS 2023 · 843 citations
Related papers
- Training-Free Safe Text Embedding Guidance for Text-to-Image Diffusion ModelsByeonghu Na, Mina Kang, Jiseok Kwak, Minsang Park et al.NeurIPS 2025 · 8 citations
- SafeGen: Mitigating Sexually Explicit Content Generation in Text-to-Image ModelsXinfeng Li, Yuchen Yang, Jiangyi Deng, Chen Yan et al.CCS 2024 · 8 citations
- SafeCFG: Controlling Harmful Features with Dynamic Safe Guidance for Safe GenerationJiadong Pan, Liang Li, Hongcheng Gao, Zheng-Jun Zha et al.ACM MM 2025
- ConceptPrune: Concept Editing in Diffusion Models via Skilled Neuron PruningRuchika Chavhan, Da Li, Timothy M. HospedalesICLR 2025 · 2 citations
- RespoDiff: Dual-Module Bottleneck Transformation for Responsible & Faithful T2I GenerationSilpa Vadakkeeveetil Sreelatha, Sauradip Nag, Muhammad Awais, Serge J. Belongie et al.NeurIPS 2025 · 4 citations
