Editing Massive Concepts in Text-to-Image Diffusion Models

Tianwei Xiong, Yue Wu, Enze Xie, Yue Wu 0002, Zhenguo Li, Xihui LiuarXiv 2024 · DOI

Introduction

Large-scale text-to-image (T2I) diffusion models, such as Stable Diffusion, have revolutionized content creation by learning complex mappings from text to pixels. However, these models are essentially static snapshots of the internet at the time of their training. This leads to persistent issues: they harbor outdated facts, inherit societal biases, and often fail to correctly associate rare aliases with their visual counterparts. Retraining these massive models to correct such errors is computationally prohibitive.

Addressing the Knowledge Gap in Diffusion Models

The challenge of "model editing" is to surgically update specific knowledge without degrading the model's general performance or causing "catastrophic forgetting." Previous methods, such as UCE or ReFACT, often struggle when the number of edits exceeds 100, leading to a breakdown in image quality or a failure to retain the new information.

Overview of EMCID editing capabilities across various tasks, including updating facts (Trump to Biden), forgetting styles (Van Gogh), rectifying aliases (Snowbird), and debiasing professions (Doctor).

EMCID (Editing Massive Concepts In Diffusion Models) introduces a scalable framework designed to handle up to 1,000 simultaneous concept edits. It addresses three primary categories of knowledge flaws:

  1. Outdated Knowledge: Updating entities that have changed since training (e.g., the current US President).
  2. Incorrect Associations: Rectifying "concept drift" where the model misinterprets specific terms (e.g., interpreting "Snowbird" as a literal bird in snow rather than a Dark-eyed Junco).
  3. Societal Bias and Copyright: Mitigating gender stereotypes in professions or erasing specific artistic styles to respect copyright.

The EMCID Framework: A Two-Stage Approach

EMCID operates on the premise that the text encoder's MLP layers function as linear associative memories. The framework updates these "key-value" stores in two distinct stages.

Stage 1: Memory Optimization

For every concept targeted for editing, EMCID first identifies an optimized "value" vector ($v^*$). This is achieved through a Dual Self-Distillation loss mechanism:

  • Semantic Alignment: This ensures the text encoder's output for the source prompt aligns with the target concept's embedding.
  • Visual Alignment: Unlike previous text-only methods, EMCID incorporates a diffusion noise prediction loss. This "visually aware" optimization ensures that changes in the text encoder effectively translate to the desired pixel generation in the U-Net.

Stage 2: Massive Model Editing

Once target values for all concepts are determined, EMCID aggregates them using a multi-layer closed-form solution. Rather than updating a single layer—which can quickly become saturated and corrupted—EMCID distributes the weight modifications across multiple layers (typically 11) of the text encoder. This distribution significantly increases the model's capacity for new knowledge, allowing it to scale to 1,000 edits without the quality degradation seen in prior art.

Experimental Setup and Benchmarks

To rigorously test EMCID, the authors introduced the ImageNet Concept Editing Benchmark (ICEB), comprising 3,300 prompts across 666 classes. This benchmark evaluates both arbitrary concept editing and concept rectification. Additionally, the framework was tested on existing benchmarks like TIMED & RoAD for role and appearance updates, and Artists-Forget & Gender-Debias for large-scale style erasure and bias mitigation.

Key Findings and Performance

EMCID demonstrates unmatched scalability and efficiency in large-scale editing tasks. In tests involving the erasure of 1,000 artist styles, EMCID maintained high generation quality where previous state-of-the-art methods failed.

  • Specificity: The model exhibits high specificity, meaning an edit to one concept (e.g., "US President") has minimal collateral damage on unrelated concepts.
  • Efficiency: The optimization stage takes approximately 92 seconds per concept (parallelizable), while the final weight update for 300 concepts takes less than 10 seconds on a consumer-grade RTX 4090.
  • Generalization: Edits performed using simple templates successfully generalize to complex, free-form prompts, demonstrating that the model has truly internalised the new association.

Conclusion and Future Directions

EMCID represents a significant step forward in making large-scale T2I models more adaptable and responsible. While highly effective, the authors note that certain concepts, such as NSFW content, remain difficult to erase completely due to their deeply intertwined nature within the model's vocabulary. Future work may explore combining EMCID's text-encoder editing with cross-attention editing to address these more complex challenges. Furthermore, the ability to easily inject new knowledge necessitates the development of robust detection methods to prevent the potential spread of disinformation.

Summary updated

BibTeX
@misc{xiong2024editing,
  author = {Tianwei Xiong and Yue Wu and Enze Xie and Yue Wu and Zhenguo Li and Xihui Liu},
  title = {{Editing Massive Concepts in Text-to-Image Diffusion Models}},
  year = {2024},
  eprint = {2403.13807},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.13807},
}
Figure