Memorization In Stable Diffusion Is Unexpectedly Driven by CLIP Embeddings

Bumjun Kim, Albert NoCVPR 2026 Findings 2026

TL;DR

Stable Diffusion models often unintentionally memorize and replicate specific images from their training data, creating significant privacy and copyright risks. This paper reveals a surprising culprit: the model's over-reliance on padding embeddings that structurally duplicate the <endoftext> token, amplifying its influence and triggering data replication. By simply changing the padding token or partially masking these padding embeddings at inference time, the authors eliminate memorization without requiring model retraining or degrading image quality.

What Problem Does This Paper Address?

When you ask a text-to-image model to generate an image, you expect a novel creation. However, diffusion models suffer from a privacy vulnerability known as memorization, where they deterministically recreate exact copies of training images.

Prior research primarily blamed dataset duplication or specific "trigger tokens" within the prompt. This paper looks at a different, overlooked interface: the text embedding space provided by CLIP. The authors identify a fundamental misalignment between how CLIP is trained and how diffusion models use it. While CLIP's contrastive training objective optimizes a single token—the <endoftext> (<eot>) token—to represent the semantics of an entire sentence, Stable Diffusion conditions its generation on the entire sequence of embeddings, including the prompt and the padding tokens. The authors investigate how this structural discrepancy inadvertently drives the model to memorize.

A text prompt is tokenized and encoded into embeddings, all of which condition the cross-attention layers in Stable Diffusion.

Methods

The authors first perform controlled embedding interventions to isolate the impact of different token types: prompt embeddings ($v^{pr}$), end-of-text embeddings ($v^{eot}$), and padding embeddings ($v^{pad}$).

After discovering that repeated padding tokens amplify the memorization signal, they propose two simple, training-free, inference-time mitigation strategies:

  1. Tokenizer-Level Fix (<pad> → ! & v^{eot} → 0): They modify the tokenizer to replace the default padding token (which defaults to <eot>) with a semantically neutral exclamation mark (!) token, decoupling the padding from the dominant $v^{eot}$ signal. They then mask the remaining single $v^{eot}$ token by setting it to zero.
  2. Partial Padding Masking (v^{pad} → 0 (70%)): Instead of changing the tokenizer, they directly mask a fixed percentage (empirically optimized at 70%) of the padding embeddings adjacent to the <eot> token.

Datasets

To evaluate their methods, the authors curated a benchmark of 458 highly consistent memorized prompts by filtering candidate prompts from Webster and MemBench. To qualify, a prompt had to consistently replicate a single training image across 10 different random seeds with a high self-supervised copy detection (SSCD) similarity score ($\ge 0.5$).

To ensure their mitigations didn't ruin standard text-to-image performance, they also evaluated 1,500 non-memorized prompts split equally across the LAION, COCO, and Lexica datasets.

Key Insights and Ideas

  • Prompt tokens matter surprisingly little in memorized cases: In one of the paper's most striking experiments, the authors masked out the actual prompt embeddings ($v^{pr}$) entirely or replaced them with $v^{eot}$. Remarkably, the model still generated the memorized image. The actual text of the prompt is largely absorbed into the surrounding embedding structure.
  • Padding acts as an unintended amplifier: Because Stable Diffusion v1.4 pads short prompts by repeating the <eot> token up to the 77-token limit, a short prompt results in dozens of near-identical vectors. This structural duplication unintentionally magnifies the influence of $v^{eot}$, forcing the cross-attention layers to over-rely on it and trigger memorized outputs.
  • The accidental fix in Stable Diffusion v2.1: The authors note that exact-match memorization largely disappeared in SD v2.1. While previously attributed to dataset cleaning, this paper reveals it was actually an architectural side-effect: SD v2.1 switched to OpenCLIP, which incidentally stopped using <eot> as a padding token, validating the authors' core hypothesis.

Key Results

The proposed mitigation strategies successfully break the deterministic replication of memorized content while restoring normal image variation across different random seeds.

  • Suppression of Memorization: For memorized prompts, the baseline SSCD score (where $\ge 0.5$ indicates replication) dropped from a highly memorized state to 0.08 using the tokenizer fix and 0.10 using the 70% padding mask.
  • Restoring Diversity: Cross-seed perceptual diversity (measured via LPIPS) skyrocketed from a near-identical 0.04 in the baseline to 0.67, meaning the model behaves normally again, generating distinct images for different seeds.
  • Preserving Quality: Evaluated on 1,500 non-memorized prompts, the CLIPScore (text alignment) and Aesthetic Score remained virtually identical to the original model, proving the fix is safe to leave on by default.
Figure 1. Mitigating memorization via <pad> replacement and veot masking. We identify <pad> embeddings (vpad) as a major contributor to memorization, as they are implicit duplications of the <endoftext> embedding (veot). To mitigate this, we replace the tokenizer’s default <pad> (<eot>) with the ! token, and mask veot. This method effectively suppresses memorization while preserving image quality and prompt alignment. Each row shows results from the same prompt across different seeds: the first column (Original) is generated with default embeddings and consistently reproduces the same image regardless of the seeds. The remaining five columns (Ours) are generated with our proposed mitigation under five different seeds. Additional results are provided in Appendix A.

Limitations and Future Work

The primary limitation acknowledged by the authors is their focus on Stable Diffusion v1.4 as the canonical benchmark for evaluation, as it is the standard model used in prior memorization literature. While they draw connections to OpenCLIP in SD v2.1, newer state-of-the-art architectures like Stable Diffusion 3 and FLUX utilize different text encoders (like T5) and flow-matching frameworks. The authors note that these newer models have not yet been systematically examined for embedding-level memorization dynamics, leaving a promising direction for future safety research.

Summary updated

BibTeX
@inproceedings{kim2026memorization,
  author = {Bumjun Kim and Albert No},
  title = {{Memorization In Stable Diffusion Is Unexpectedly Driven by CLIP Embeddings}},
  booktitle = {IEEE/CVF Conference on Computer Vision and Pattern Recognition},
  year = {2026},
  url = {https://openreview.net/forum?id=63gCS6UU8H},
}
Figure