Detecting, Explaining, and Mitigating Memorization in Diffusion Models
Yuxin Wen, Yuchen Liu, Chen Chen, Lingjuan Lyu
TL;DR
This work tackles memorization in diffusion-based image generation by proposing a lighting-fast detector that uses the magnitude of text-conditional noise predictions to identify memorized prompts, even from a single generation. It provides an explainable token-level analysis to rank trigger tokens and offers two mitigation strategies: inference-time perturbation of the prompt embedding and training-time exclusion of memorized samples, both designed to preserve generation quality. Empirical results show high detection performance, with $\text{AUC}$ approaching $0.999$ and $\text{TPR}@1\%\text{FPR}$ near $0.99$ under favorable settings, while achieving substantial speedups over prior methods. The practical impact lies in enabling model owners to detect and counter memorization efficiently, with interactive guidance for users to adjust prompts and robust defenses during inference and training. Code is provided to reproduce the results and apply the methods to real-world diffusion models.
Abstract
Recent breakthroughs in diffusion models have exhibited exceptional image-generation capabilities. However, studies show that some outputs are merely replications of training data. Such replications present potential legal challenges for model owners, especially when the generated content contains proprietary information. In this work, we introduce a straightforward yet effective method for detecting memorized prompts by inspecting the magnitude of text-conditional predictions. Our proposed method seamlessly integrates without disrupting sampling algorithms, and delivers high accuracy even at the first generation step, with a single generation per prompt. Building on our detection strategy, we unveil an explainable approach that shows the contribution of individual words or tokens to memorization. This offers an interactive medium for users to adjust their prompts. Moreover, we propose two strategies i.e., to mitigate memorization by leveraging the magnitude of text-conditional predictions, either through minimization during inference or filtering during training. These proposed strategies effectively counteract memorization while maintaining high-generation quality. Code is available at https://github.com/YuxinWenRick/diffusion_memorization.
