Abstract
Diffusion models are capable of generating photo-realistic images that combine elements which likely do not appear together in the training set, demonstrating the ability to compositionally generalize. Nonetheless, the precise mechanism of compositionality and how it is acquired through training remains elusive. Inspired by cognitive neuroscientific approaches, we consider a highly reduced setting to examine whether and when diffusion models learn semantically meaningful and factorized representations of composable features. We performed extensive controlled experiments on conditional Denoising Diffusion Probabilistic Models (DDPMs) trained to generate various forms of 2D Gaussian bump images. We found that the models learn factorized but not fully continuous manifold representations for encoding continuous features of variation underlying the data. With such representations, models demonstrate superior feature compositionality but limited ability to interpolate over unseen values of a given feature. Our experimental results further demonstrate that diffusion models can attain compositionality with few compositional examples, suggesting a more efficient way to train DDPMs. Finally, we connect manifold formation in diffusion models to percolation theory in physics, offering insight into the sudden onset of factorized representation learning. Our thorough toy experiments thus contribute a deeper understanding of how diffusion models capture compositional structure in data.
Introduction
Large-scale generative models like Stable Diffusion exhibit an impressive capacity for "compositional generalization"—the ability to synthesize novel combinations of concepts. However, the internal mechanisms that enable this are not well understood. This research addresses whether diffusion models learn independent representations of features and the data density required for such learning. By utilizing a "reductionist" framework with synthetic 2D Gaussian datasets, the authors investigate the minimal conditions for factorization and composition.
Methodology and Topological Analysis
The study employs conditional Denoising Diffusion Probabilistic Models (DDPMs) trained on $32 \times 32$ grayscale images of 2D Gaussian bumps. To probe the internal geometry of the model, the researchers used periodic boundary conditions, effectively mapping the data space onto a torus. They analyzed the UNet's intermediate layer activations using persistent homology and dimensionality reduction techniques (PCA, UMAP) to visualize the learned latent manifold.
Datasets and Experimental Design
The experiments utilized three synthetic datasets: 2D Gaussian Bumps, 1D Gaussian Stripes (representing isolated factors), and 2D Gaussian SOS (Sum of Stripes). "Lesion experiments" were performed by withholding specific data segments to evaluate the model's ability to interpolate (fill in missing values) versus compose (combine features seen only in isolation).
Key Findings
Hyper-Factorization and Interpolation Limits
The models develop "hyper-factorized" representations where different values of a single feature are encoded as nearly orthogonal vectors. While this factorization prevents feature interference and facilitates composition, it creates a trade-off: the models struggle with interpolation. If a specific feature value is absent from the training set, the model cannot reliably "guess" its appearance based on neighboring values.
Compositional Efficiency and Data Scaling
A critical insight is that composition is highly data-efficient. Models can learn to compose features even when joint occurrences are rare. By augmenting training with 1D stripes and a small fraction of 2D examples, the data requirement scales linearly ($O(N)$) with image resolution, rather than quadratically ($O(N^2)$).
Percolation Theory and the Sudden Onset of Learning
The emergence of a coherent internal manifold follows a sharp transition described by percolation theory. Just as connectivity in a porous medium depends on a critical density of holes, the model only learns a continuous representation once the training data points provide sufficient "overlap" in the latent space. This explains the sudden jump in accuracy observed during training.
Results and Conclusion
The experimental results confirm that diffusion models naturally favor factorized representations, such as the 4D Clifford Torus, over coupled ones. The study demonstrates that the transition from failure to successful generation is abrupt and tied to the percolation threshold. These findings suggest that sample efficiency in large models could be improved by strategically including isolated feature examples, and provide a theoretical basis for understanding emergent capabilities in AI.
Summary updated