Diffusion Lens: Interpreting Text Encoders in Text-to-Image Pipelines

Technion - Israel Institute of Technology

Abstract

Text-to-image diffusion models (T2I) use a latent representation of a text prompt to guide the image generation process. However, the process by which the encoder produces the text representation is unknown. We propose the Diffusion Lens, a method for analyzing the text encoder of T2I models by generating images from its intermediate representations. Using the Diffusion Lens, we perform an extensive analysis of two recent T2I models. Exploring compound prompts, we find that complex scenes describing multiple objects are composed progressively and more slowly compared to simple scenes; Exploring knowledge retrieval, we find that representation of uncommon concepts requires further computation compared to common concepts, and that knowledge retrieval is gradual across layers. Overall, our findings provide valuable insights into the text encoder component in T2I pipelines.

Diffusion Lens

Giraffe

Visualization of the text encoder's intermediate representations using the Diffusion Lens. At each layer of the text encoder (in blue), the Diffusion Lens takes the full hidden state, passes it through the final layer norm, and feeds it into the diffusion model.

Insights from Diffusion Lens

Examples

Early layers often act as a "bag of concepts", lacking relational information which emerges in later layers.

Examples

Uncommon concepts gradually evolve over layers, taking longer to generate compared to common concepts. Fine details, like human facial features, materialize at later layers

All Layers Visualization

All Layers

Images generated from all layers using Diffusion Lens.

Related Work

Tang et al. (2023) What the DAAM: Interpreting Stable Diffusion Using Cross Attention. (ACL 2023) [Paper]

Chefer et al. (2023) The Hidden Language of Diffusion Models. (ICLR 2024) [Paper]

Nostalgebraist (2020) interpreting GPT: the logit lens. (LESSWRONG Blog) [Blog]

BibTeX


        @article{toker2024diffusion,
          title={Diffusion Lens: Interpreting Text Encoders in Text-to-Image Pipelines},
          author={Toker, Michael and Orgad, Hadas and Ventura, Mor and Arad, Dana and Belinkov, Yonatan},
          journal={arXiv preprint arXiv:2403.05846},
          year={2024}
        }