Erasing Concepts from Diffusion Models

Rohit Gandikota, Joanna Materzynska, Jaden Fiotto-Kaufman, David Bau

Introduction

Large-scale generative models like Stable Diffusion have revolutionized content creation but also introduced significant risks, including the generation of harmful content, copyright infringement, and the unauthorized mimicry of artistic styles. Traditional methods for mitigating these risks—such as dataset filtering or post-generation blocking—are often computationally expensive or easily bypassed by users with access to model weights.

Researchers from Northeastern University and MIT propose Erased Stable Diffusion (ESD), a novel fine-tuning method designed to permanently remove specific concepts from a diffusion model's weights. ESD provides a "surgical" approach to safety and copyright protection, ensuring that once a concept is erased, the model can no longer represent it, even under adversarial prompting.

Erased Stable Diffusion can effectively remove NSFW content, specific artistic styles, and object classes from model outputs.

Methodology: Negative Guidance

The core of ESD is a fine-tuning process called Negative Guidance. Unlike retraining from scratch, which requires massive "clean" datasets, ESD leverages the model's own internal knowledge. By identifying the noise patterns the model uses to generate a specific concept (e.g., "Van Gogh"), the fine-tuning objective pushes the model's weights to move away from those patterns.

The authors introduce two variants of the method:

  • ESD-x (Cross-Attention): This variant targets the layers linking text prompts to visual features. It is highly effective for erasing specific artistic styles triggered by names while preserving the model's general capabilities.
  • ESD-u (Unconditional): This variant modifies general visual layers, making it suitable for "global" concepts like nudity that might appear even without explicit textual triggers.

Evaluation and Results

The effectiveness of ESD was tested across several domains:

  • Nudity Removal: Evaluated on the I2P (Inappropriate Image Prompts) benchmark, ESD reduced nudity-containing images from 796 to 134, outperforming the dataset-filtering approach used in Stable Diffusion 2.0.
  • Style Erasure: Using a custom Artist Style Dataset, the method successfully neutralized specific artistic styles. In user studies, the recognizability of erased styles dropped significantly (from 3.21/5 to 1.12/5) without degrading the quality of other styles.
Detail of the model's output after erasing the Van Gogh style.
  • Object Removal: Tested on the Imagenette dataset, ESD successfully "deleted" entire object classes. For instance, the classification accuracy for "parachutes" plummeted from 98% to 23.8% post-erasure.

Conclusion

Erased Stable Diffusion offers a robust and efficient mechanism for aligning generative models with safety and copyright standards. By modifying the model weights directly, it provides a permanent solution that cannot be easily circumvented. While some challenges remain—such as the complete erasure of structurally complex objects and minor interference with unrelated concepts—ESD represents a significant step toward responsible AI deployment.

Summary updated

Abstract

Motivated by recent advancements in text-to-image diffusion, we study erasure of specific concepts from the model's weights. While Stable Diffusion has shown promise in producing explicit or realistic artwork, it has raised concerns regarding its potential for misuse. We propose a fine-tuning method that can erase a visual concept from a pre-trained diffusion model, given only the name of the style and using negative guidance as a teacher. We benchmark our method against previous approaches that remove sexually explicit content and demonstrate its effectiveness, performing on par with Safe Latent Diffusion and censored training. To evaluate artistic style removal, we conduct experiments erasing five modern artists from the network and conduct a user study to assess the human perception of the removed styles. Unlike previous methods, our approach can remove concepts from a diffusion model permanently rather than modifying the output at the inference time, so it cannot be circumvented even if a user has access to model weights. Our code, data, and results are available at https://erasing.baulab.info/
BibTeX
@inproceedings{gandikota2023erasing,
  author = {Rohit Gandikota and Joanna Materzynska and Jaden Fiotto-Kaufman and David Bau},
  title = {{Erasing Concepts from Diffusion Models}},
  booktitle = {IEEE/CVF International Conference on Computer Vision},
  year = {2023},
}
Figure