Extracting Training Data from Diffusion Models

Nicholas Carlini, Jamie Hayes, Milad Nasr, Matthew Jagielski, Vikash Sehwag, Florian Tramèr, Borja Balle, Daphne Ippolito, Eric Wallace · DOI

Abstract

State-of-the-art diffusion models, such as Stable Diffusion and Imagen, have set new benchmarks for high-fidelity image generation. However, the assumption that these models only learn abstract data distributions is increasingly under scrutiny. This paper investigates the phenomenon of memorization in denoising diffusion models, demonstrating that they can be forced to regenerate specific, high-resolution images from their training sets. By employing a novel "generate-and-filter" attack alongside membership inference techniques, researchers extracted over a thousand training examples, including private photos and trademarked logos. The findings reveal that diffusion models are significantly more prone to data leakage than the Generative Adversarial Networks (GANs) that preceded them, posing a substantial challenge for privacy-preserving machine learning.

Introduction

For years, the prevailing wisdom in generative modeling suggested that these systems "learn the distribution" of data to create novel, synthetic content. This led to the proposal of using generative models to create "privacy-preserving" synthetic datasets. However, such a premise relies on the assumption that models do not memorize their training inputs. This study tackles the "memorization" problem in denoising diffusion models, investigating whether these industry-standard tools violate privacy by emitting exact replicas of training data. We explore the mechanisms of this leakage, methods for detection, and the efficacy of current defenses like data deduplication and Differential Privacy (DP).

Methodology

The researchers developed a multi-pronged approach to evaluate data extraction risks:

  1. Generate-and-Filter (Black-box Attack): The team prompted the model to generate 500 images for specific text captions. They then identified "cliques"—groups of generated images that were nearly identical. The rationale is that if a model produces the same complex image multiple times from different random seeds, it has likely memorized a specific training example rather than synthesizing a novel one.
  2. Membership Inference Attacks (White-box Attack): Using the Likelihood Ratio Attack (LiRA), the researchers compared the loss of a target image on the trained model against "shadow models" trained on different data subsets. They identified a "Goldilocks zone" for these attacks: evaluating the model's error at middle-range noise timesteps (approximately $t=100$) yielded the highest accuracy.
  3. Inpainting Attacks: To simulate a scenario where an attacker possesses partial information, the researchers masked half of a training image and tasked the model with completing it. For images present in the training set, the reconstructions were often pixel-perfect.

Experimental Setup

The study evaluated both massive, "in-the-wild" models and controlled laboratory environments:

  • LAION-400M / LAION-2B: Public datasets used to train Stable Diffusion.
  • Imagen’s Internal Dataset: A private dataset utilized by Google for its Imagen model.
  • CIFAR-10: A standard benchmark used for controlled, head-to-head privacy comparisons between diffusion models and GANs.

Key Insights and Results

The Duplication and Outlier Trap

The strongest predictor of memorization is the frequency of an image in the training set. Images duplicated more than 100 times are extremely likely to be extracted. However, the researchers also observed "eidetic memorization," where unique, non-duplicated images were leaked. In models like Imagen, the most "unusual" images—outliers in the CLIP embedding space—were the most vulnerable to leakage, even without duplication.

Diffusion vs. GANs

Diffusion models were found to be significantly less private than GANs. In head-to-head tests on CIFAR-10, diffusion models leaked more than twice as much training data as GANs, even when both architectures achieved similar image quality. This suggests that the diffusion process itself may be more inherently prone to memorization.

The Utility-Privacy Tension

There is a direct correlation between model quality and memorization. As models improve (indicated by lower FID scores), they tend to memorize more data. This implies that the more realistic a model's output becomes, the higher the risk it poses to the privacy of its training data.

Quantitative Extraction Results

  • Massive Extraction: Researchers successfully extracted over 1,000 near-identical replicas of training images from Stable Diffusion.
  • High-Precision Attacks: The membership inference attack on CIFAR-10 achieved a 71% True Positive Rate at a 1% False Positive Rate.
  • Deduplication Limits: While removing duplicate images reduced memorization, it did not eliminate it. A model trained on a deduplicated CIFAR-10 set still regenerated nearly 1,000 training images.

Limitations and Future Work

The study highlights several hurdles for future defense mechanisms. Applying Differential Privacy (DP-SGD) to diffusion models currently causes training instability or failure, even with high privacy budgets. Furthermore, while $\ell_2$ distance is effective for identifying pixel-perfect copies, it fails to capture "style-copying" or semantic memorization, which are critical for copyright and artistic integrity.

Ultimately, this research serves as a critical wake-up call for the AI community. As generative models become more powerful, the "heuristic privacy" of the past is no longer sufficient. Responsible deployment will require significant advances in privacy-preserving training techniques to ensure that AI does not become a high-tech copycat.

Summary updated

BibTeX
@inproceedings{carlini2023extracting,
  author = {Nicholas Carlini and Jamie Hayes and Milad Nasr and Matthew Jagielski and Vikash Sehwag and Florian Tramèr and Borja Balle and Daphne Ippolito and Eric Wallace},
  title = {{Extracting Training Data from Diffusion Models}},
  booktitle = {USENIX Security},
  year = {2023},
  url = {https://openreview.net/forum?id=eXLpntjX5D},
}
Figure