Table of Contents
Fetching ...

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

Michael Toker, Hadas Orgad, Mor Ventura, Dana Arad, Yonatan Belinkov

TL;DR

This paper introduces the Diffusion Lens, a novel, weight-free method to interpret text encoders in text-to-image diffusion pipelines by visualizing intermediate representations through the diffusion process. By conditioning the diffusion model on layer-wise outputs of the text encoder after final-layer normalization, the authors reveal how complex concepts and relations are constructed across layers, and how memory retrieval unfolds from common to uncommon concepts. Applying the method to Stable Diffusion and Deep Floyd, they show that simple prompts form representations early while complex prompts and syntactic dependencies emerge later, with model-specific differences likely influenced by architecture and training objectives. These insights advance understanding of text-to-image generation and offer a tool for diagnosing failures and guiding improvements in text encoders and prompting strategies.

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: Interpreting Text Encoders in Text-to-Image Pipelines

TL;DR

This paper introduces the Diffusion Lens, a novel, weight-free method to interpret text encoders in text-to-image diffusion pipelines by visualizing intermediate representations through the diffusion process. By conditioning the diffusion model on layer-wise outputs of the text encoder after final-layer normalization, the authors reveal how complex concepts and relations are constructed across layers, and how memory retrieval unfolds from common to uncommon concepts. Applying the method to Stable Diffusion and Deep Floyd, they show that simple prompts form representations early while complex prompts and syntactic dependencies emerge later, with model-specific differences likely influenced by architecture and training objectives. These insights advance understanding of text-to-image generation and offer a tool for diagnosing failures and guiding improvements in text encoders and prompting strategies.

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.
Paper Structure (40 sections, 3 equations, 28 figures, 2 tables)

This paper contains 40 sections, 3 equations, 28 figures, 2 tables.

Figures (28)

  • Figure 1: 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.
  • Figure 2: Insights gained from using Diffusion Lens. Conceptual Combination (left): early layers often act as a "bag of concepts", lacking relational information which emerges in later layers. Memory Retrieval (right): uncommon concepts gradually evolve over layers, taking longer to generate compared to common concepts.
  • Figure 3: Percentages of prompt-matching images across various layers. As prompts become more complex, Diffusion Lens has to utilize more layers to extract a correct image.
  • Figure 4: Complex prompts take more computation blocks to emerge.
  • Figure 5: The proportion of images where either the object, the colors, or both were present, and where either the objects or the colors were accurately represented.
  • ...and 23 more figures