Localizing and Editing Knowledge In Text-to-Image Generative Models

Link
Abstract

Text-to-Image Diffusion Models such as Stable-Diffusion and Imagen have achieved unprecedented quality of photorealism with state-of-the-art FID scores on MS-COCO and other generation benchmarks. Given a caption, image generation requires fine-grained knowledge about attributes such as object structure, style, and viewpoint amongst others. Where does this information reside in text-to-image generative models? In our paper, we tackle this question and understand how knowledge corresponding to distinct visual attributes is stored in large-scale text-to-image diffusion models. We adapt Causal Mediation Analysis for text-to-image models and trace knowledge about distinct visual attributes to various (causal) components in the (i) UNet and (ii) text-encoder of the diffusion model. In particular, we show that unlike large-language models, knowledge about different attributes is not localized in isolated components, but is instead distributed amongst a set of components in the conditional UNet. These sets of components are often distinct for different visual attributes (e.g., style} / objects). Remarkably, we find that the text-encoder in public text-to-image models such as Stable-Diffusion contains {\it only} one causal state across different visual attributes, and this is the first self-attention layer corresponding to the last subject token of the attribute in the caption. This is in stark contrast to the causal states in other language models which are often the mid-MLP layers. Based on this observation of only one causal state in the text-encoder, we introduce a fast, data-free model editing method DiffQuickFix which can effectively edit concepts (remove or update knowledge) in text-to-image models. DiffQuickFix can edit (ablate) concepts in under a second with a closed-form update, providing a significant 1000x speedup and comparable editing performance to existing fine-tuning based editing methods.

Synth

Problem:: 텍스트-이미지 생성 모델에서 다양한 시각적 속성(객체, 스타일, 색상, 행동 등)에 관한 지식이 어디에 저장되어 있는지 이해 부족 / 모델에서 특정 개념을 편집하기 위한 효율적인 방법 필요

Solution:: Causal Mediation Analysis를 통해 UNet과 텍스트 인코더에서 다양한 시각적 속성 지식의 위치 파악 / 텍스트 인코더의 첫 번째 Self-Attention 레이어에 지식이 집중되어 있다는 발견을 활용한 DIFF-QUICKFIX 모델 편집 방법 제안

Novelty:: 텍스트-이미지 모델의 지식이 UNet에서는 분산되어 있고 텍스트 인코더에서는 단일 레이어에 집중되어 있다는 새로운 발견

Note:: 후속 연구중 하나는 Nudity와 같은 개념은 Text Encoder의 여러 층을 학습시켜야 동작함을 보이며 해당 개념이 더 어렵다고 주장 → 논문의 실험은 명확한 주제들을 편집하려고 했기 때문에 첫 번째 레이어만 활성화 된 걸로 볼 수 있을 듯 / Unet의 경우 특정 지식이 여러곳에 분산되어 저장 → 공격의 여지가 많고 방어하기 힘듦을 의미? → 실제로 Text Encoder를 학습시키면 Unet 학습 보다 ASR이 좋아짐

Summary

Motivation

Method

Causal Mediation Analysis

file-20250408234835866.png

Clean Model에서 Causal State를 Corrupted Model로 옮겼더니 제대로 생성 됨

DIFF-QUICKFIX

Method 검증

UNet에서의 지식 위치 발견

file-20250408234930329.png|550

텍스트 인코더에서의 지식 위치 발견

file-20250408235013082.png

DIFF-QUICKFIX 평가