Abstract
Large-scale image generation models, with impressive quality made possible by the vast amount of data available on the Internet, raise social concerns that these models may generate harmful or copyrighted content. The biases and harmfulness arise throughout the entire training process and are hard to completely remove, which have become significant hurdles to the safe deployment of these models. In this paper, we propose a method called SDD to prevent problematic content generation in text-to-image diffusion models. We self-distill the diffusion model to guide the noise estimate conditioned on the target removal concept to match the unconditional one. Compared to the previous methods, our method eliminates a much greater proportion of harmful content from the generated images without degrading the overall image quality. Furthermore, our method allows the removal of multiple concepts at once, whereas previous works are limited to removing a single concept at a time.
Introduction
State-of-the-art text-to-image models like Stable Diffusion are trained on massive, uncurated datasets scraped from the internet (e.g., LAION-5B). Consequently, these models often "memorize" problematic content, including NSFW imagery, copyrighted artist styles, and social biases.
Removing this content is notoriously difficult. Simply filtering training data is often insufficient and can degrade the model's general performance. Conversely, fine-tuning a model to "forget" specific concepts often leads to catastrophic forgetting, where the model loses its ability to generate high-quality images for unrelated prompts. Existing solutions either struggle to remove concepts entirely or fail when attempting to erase multiple concepts (such as "violence" and "nudity") simultaneously.
Safe Self-Distillation (SDD)
The authors propose Safe Self-Distillation (SDD) to address these challenges. The core objective is to guide the model's noise estimate for a "target removal concept" ($c_s$) to match its "unconditional" noise estimate—essentially teaching the model to act as if no prompt was provided when it encounters a forbidden concept.
Key Technical Components
- Self-Distillation Objective: Instead of requiring a separate teacher model, SDD leverages the model's own internal knowledge. It calculates the $L_2$ distance between the noise predicted for a harmful prompt and the noise predicted for an empty string, minimizing this difference via backpropagation.
- EMA Teacher: To prevent model collapse or excessive forgetting, an Exponential Moving Average (EMA) teacher is employed. The teacher model’s weights are a slowly moving average of the student’s. During training, the teacher generates intermediate "latents," providing a stable target for the student.
- Multi-Concept Handling: To erase multiple concepts simultaneously, SDD randomly selects one concept per iteration to generate latents while concatenating all target concepts into a single prompt for the loss calculation. This prevents conflicting concepts from canceling each other out in the noise space.
- Cross-Attention Focus: Research indicated that fine-tuning only the cross-attention layers—the bridge between text and pixels—is sufficient for effective concept removal, making the process highly efficient.
Experimental Evaluation
The paper evaluates SDD using several rigorous benchmarks:
- I2P (Inappropriate Image Prompts): A dataset of ~23,000 prompts known to trigger harmful content.
- MS-COCO (30k): Used to evaluate general image quality (FID, CLIP scores) to ensure the model retains its creative capabilities.
- Artist Prompts: Targeting specific styles (e.g., Van Gogh, Picasso) to test copyright protection.
- Safety Classifiers: NudeNet and the Q16 classifier were used to quantify the presence of inappropriate content.
Key Results
SDD demonstrates a significant improvement over existing baselines in both safety and quality preservation.
- Superior NSFW Removal: In nudity removal tests, SDD reduced the proportion of "nude" images to 1.68% (in specific single-concept tests), significantly outperforming the previous state-of-the-art, ESD (14.32%).
- Multi-Concept Mastery: When tasked with removing 20 different harmful concepts simultaneously (the I2P task), SDD maintained a high level of safety (12.62% NUDE) while baselines like ESD-x-3 struggled at 47.38%.
- Quality Preservation: Despite aggressive concept removal, SDD's performance on MS-COCO remained nearly identical to the original Stable Diffusion model. As shown in the results table, FID and CLIP scores remain competitive, indicating no significant loss in general generative utility.
Conclusion and Limitations
While SDD represents a major step forward, the authors note it is not a complete "silver bullet." Residual content may still appear if prompts are highly engineered to bypass safeguards. Additionally, while minimal, long training runs can lead to minor quality trade-offs. Future work may involve combining SDD with prompt tuning or other pre/post-processing safeguards to create even more robust safety frameworks for internet-scale models.
Summary updated