What the DAAM: Interpreting Stable Diffusion Using Cross Attention

Raphael Tang, Linqing Liu, Akshat Pandey, Zhiying Jiang, Gefei Yang, Karun Kumar, Pontus Stenetorp, Jimmy Lin, Ferhan Ture

Abstract

Text-to-image diffusion models have achieved remarkable success but remain largely "black boxes" regarding how specific input tokens influence spatial image generation. This paper introduces Diffusion Attentive Attribution Maps (DAAM), a novel interpretability method that utilizes the cross-attention mechanism within the U-Net denoising module. By aggregating and upscaling attention scores across time steps and layers, DAAM produces 2D maps that attribute pixel-level influence to individual words. Our analysis reveals insights into how syntax and semantic entanglement affect generation quality, and demonstrates that DAAM can perform effective unsupervised semantic segmentation.

Introduction

While Stable Diffusion produces high-fidelity imagery, understanding the relationship between input text and output pixels is challenging. Previous saliency-based methods are often computationally expensive or unstable in the iterative denoising context. DAAM addresses this by tapping into the model's internal attention, providing a clear map of how words like "monkey" or "walking" influence specific regions of the generated image. This transparency is vital for debugging compositional errors, such as "adjectival bleeding" or object confusion.

Methodology: Diffusion Attentive Attribution Maps (DAAM)

DAAM operates by extracting information from the cross-attention layers where image representations interact with text embeddings. The process involves three primary stages:

  1. Extraction: Capturing raw attention scores for word-pixel pairs across all heads.
  2. Spatiotemporal Aggregation: Summing and averaging these maps across different resolutions (layers) and denoising time steps.
  3. Upscaling: Using bicubic interpolation to restore low-resolution maps to the original image dimensions.
The DAAM pipeline: extraction from cross-attention layers, spatiotemporal aggregation, and upscaling.

Experimental Results and Insights

The researchers evaluated DAAM using datasets like COCO-Gen and Unreal-Gen, alongside human evaluations. A key finding is the role of syntax: heads of dependencies (e.g., verbs) often subsume their dependents (e.g., subjects) in pixel space. For instance, the attribution for "walking" often encompasses the entire area of the subject performing the action.

DAAM attribution maps for the prompt "a monkey wearing a hat walking," showing word-specific spatial influence.

Furthermore, DAAM identifies "feature entanglement." When semantically similar words (cohyponyms like "giraffe" and "zebra") are used, their attribution maps overlap significantly, leading to a measurable drop in generation quality. The method also highlights "adjectival bleeding," where descriptive terms like "rusty" incorrectly influence surrounding objects. Quantitatively, DAAM achieved 58.8–64.8 mIoU in noun segmentation, proving its spatial accuracy.

Discussion and Conclusion

DAAM provides a powerful lens into the inner workings of diffusion models, though it faces limitations with abstract concepts and reliance on external dependency parsers. Future work involves using DAAM signals during training to encourage disentanglement and improve compositional accuracy. By turning attention into attribution, DAAM moves us closer to transparent and controllable generative AI.

Summary updated

BibTeX
@inproceedings{tang2023what,
  author = {Raphael Tang and Linqing Liu and Akshat Pandey and Zhiying Jiang and Gefei Yang and Karun Kumar and Pontus Stenetorp and Jimmy Lin and Ferhan Ture},
  title = {{What the DAAM: Interpreting Stable Diffusion Using Cross Attention}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2023},
  doi = {10.18653/v1/2023.acl-long.310},
}
Figure