Erasing Undesirable Influence in Diffusion Models

Jing Wu, Trung Le, Munawar Hayat, Mehrtash Harandi

Abstract

Diffusion models have revolutionized image generation but face significant challenges regarding data memorization, copyright infringement, and the generation of NSFW content. Retraining these models from scratch to remove specific data is computationally prohibitive. We present EraseDiff, an efficient algorithm that formulates machine unlearning as a constrained optimization problem. EraseDiff achieves a superior balance between erasing targeted information and preserving overall image quality, running up to 11x faster than previous state-of-the-art methods.

Introduction

Large-scale diffusion models like Stable Diffusion often memorize specific training images, raising privacy and copyright issues. Additionally, they can be prompted to generate undesirable or harmful content. Regulations such as the GDPR's "right to be forgotten" necessitate methods to remove specific data without the massive cost of retraining (approximately 150,000 GPU hours for Stable Diffusion). Existing "machine unlearning" techniques often suffer from "gradient conflict," where erasing target data degrades the model's performance on unrelated tasks.

Methods: EraseDiff

EraseDiff addresses unlearning through a bi-level optimization framework:

  1. Inner Loop (Erasure): Guides the model to deviate from the ground-truth denoising trajectory for the data to be forgotten.
  2. Outer Loop (Preservation): Ensures the model maintains high performance on "safe" or remaining data.

To overcome the computational burden of nested loops, EraseDiff employs a value function approach, reformulating the problem into a single-constrained optimization task. This allows for a first-order algorithm that identifies an update vector aligned with both erasure and preservation goals, effectively resolving the "tug-of-war" between objectives.

Experimental Evaluation

The authors evaluated EraseDiff on several benchmarks, including CIFAR-10 and Imagenette for class-wise forgetting (e.g., removing the "airplane" class), and the I2P (Inappropriate-to-Prompt) dataset for scrubbing NSFW content.

Key Results

EraseDiff demonstrates significant improvements in both efficiency and quality:

  • Efficiency: It is 11x faster than Selective Amnesia (SA) and 2x faster than SalUn.
  • Utility Preservation: On Imagenette, the model maintained 99.91% accuracy for non-forgotten classes, outperforming all baselines.
Figure 6: Comparison of generated images across different classes, demonstrating the model's ability to preserve high-quality generation for safe concepts while undergoing unlearning.
  • Concept Erasure: In nudity erasure tests using the I2P dataset, EraseDiff successfully reduced the generation of inappropriate content while maintaining artistic integrity.
Figure 3: Example of concept erasure in a complex scene. The model is guided to remove undesirable elements while preserving the overall composition and quality.

Discussion and Insights

A critical insight of EraseDiff is its ability to resolve gradient conflicts. By visualizing the cosine similarity between update vectors, the authors show that EraseDiff finds a "middle ground" that supports both erasure and preservation. Unlike previous methods, it avoids the expensive computation of the Fisher Information Matrix (FIM), making it practical for large-scale models.

However, challenges remain. Incomplete erasures can occur if the replacement strategy is imperfect, potentially leaving subtle textures or shapes of the forgotten data. Furthermore, the authors highlight the ethical responsibility associated with unlearning tools, as they could be misused for censorship.

Conclusion

EraseDiff provides a robust and efficient solution for the "right to be forgotten" in generative AI. By framing unlearning as a constrained optimization problem, it offers a scalable way to maintain safe and compliant diffusion models without sacrificing performance.

Summary updated

BibTeX
@inproceedings{wu2025erasing,
  author = {Jing Wu and Trung Le and Munawar Hayat and Mehrtash Harandi},
  title = {{Erasing Undesirable Influence in Diffusion Models}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2025},
  doi = {10.1109/cvpr52734.2025.02632},
}
Figure