NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Test-Time Compositional Generalization in Diffusion Models via Concept Discovery

Zekun Wang, Anant Gupta, Tianyi Zhu, Christopher J. MacLellanarXiv 2026

TL;DR

Pretrained diffusion models can achieve test-time compositional generalization on out-of-distribution queries without relying on a predefined concept library. By treating the model's time-indexed score geometry as an implicit hierarchy of density modes, the proposed method extracts query-specific concept prototypes and recombines them using a Product-of-Experts framework.

What Problem Does This Paper Address?

Humans possess a remarkable ability for compositional generalization—we can easily understand or create novel combinations of familiar parts, like imagining a "pink zebra" even if we've never seen one. For deep generative models, however, this remains a significant challenge.

In diffusion models, existing composition methods typically assume that the individual parts or conditioning signals (like text prompts or class labels) are already known and available beforehand. If a model encounters an out-of-distribution (OOD) query containing an unseen combination of attributes without any accompanying labels, it struggles to generalize. It will either replicate the query exactly (memorization) or drift toward a completely different, familiar training class.

The authors address this gap by asking: Can a pretrained diffusion model discover reusable concept primitives directly from the geometry of its own learned score function at test time, using only a single unlabeled query image?

Methods

The authors introduce a test-time framework that repurposes a frozen diffusion model's score network into an implicit concept discovery engine. The method consists of four key stages:

  1. Concept Discovery via Mode Ascent: The diffusion process progressively smooths data across different timesteps ($t$). The authors perform gradient ascent on the unconditional score function $s_\theta(x_t, t)$ starting from a noised version of the query image. Thanks to Tweedie's formula, the local density modes found at intermediate timesteps are noise-free and capture concepts at varying levels of abstraction (coarse structures at high $t$, fine details at low $t$).
  2. Local Gaussian Approximation: Each discovered mode is mapped back into clean data space ($x_0$-space) and approximated as a local Gaussian distribution, providing a shared mathematical representation for all discovered concepts.
  3. Product-of-Experts (PoE) Composition: A submodular greedy selection algorithm evaluates the candidate pool of modes and selects the most relevant prototypes to explain the query image. These are combined into a weighted Product-of-Experts teacher model, which yields an analytical score function.
  4. Sampling and Distillation: This analytical PoE score can be plugged directly into a classifier-free guidance (CFG) sampler to generate new variations. Alternatively, these generated samples can be used to distill the newly discovered composition back into the model by training a new class embedding token and a Low-Rank Adapter (LoRA).
Figure 1: Overview of our DDPM-based concept discovery framework for compositional generaliza- tion, as described in Section 3.

Datasets

The method was evaluated on two compositional benchmarks:

  • ColorMNIST: A custom 32×32 RGB dataset featuring three primitive factors: digit identity (0–9), digit color (4 colors), and background color (4 colors). Out of 160 total combinations, 120 are seen during training, leaving 40 held out as OOD test queries.
  • CelebA (compositional): Constructed from the binary CelebA face attributes dataset using 14 binary attributes (e.g., blond hair, smiling, wavy hair). Out of 74 realized attribute combinations, 51 are used for training and 23 are held out as OOD classes.

The authors also utilized Fashion-MNIST, LSUN Churches, and CelebA-HQ to visualize and validate the mode-seeking behavior of their framework.

Key Insights and Ideas

  • The Score Manifold is a Hierarchy: Diffusion timesteps do more than just add noise; they act as a scale-space filter. A pretrained model implicitly organizes information from coarse semantic structures to fine details, meaning a multi-scale taxonomy of concepts already lives inside the model's weights.
  • Modes are Noise-Free Prototypes: While a random sample at an intermediate diffusion step $x_t$ is highly noisy, a local density mode (where the score gradient vanishes) naturally strips away the noise. This allows the model to isolate clean, reusable concept primitives.
  • Bypassing the Need for Labels: Compositional generation can be achieved purely geometrically through the unconditional score landscape, removing the bottleneck of requiring explicit text tokens or manual annotation libraries.

Key Results

The proposed PoE analytic sampler and its LoRA-distilled variant significantly outperformed baselines like "Query-only" (which simply adds isotropic variance around the query) and "Top-$k$ trained classes" (which retrieves the closest seen training tokens).

  • ColorMNIST: The LoRA-distilled model achieved a generalization F1 score of 76.3%, whereas the query-only and top-trained class baselines collapsed to near 0% and ~6.5% respectively. The baselines frequently failed by altering the digit identity or generating noisy, corrupted textures.
  • CelebA: The PoE method achieved the best generalization FID (140.3) and precision (74.5%). Qualitatively, the framework successfully generated entirely new facial identities while strictly preserving the unseen attribute combination (e.g., big lips, blond hair, smiling, wavy hair), proving it was generalizing the underlying concepts rather than just memorizing the query image.
Qualitative comparison on CelebA showing identity variation while preserving attributes

Limitations and Future Work

  • Interpolation vs. Extrapolation: The framework inherits the exact inductive biases of the base model. It excels at interpolating between known primitives (e.g., combining a known color with a known digit), but fails to extrapolate entirely outside the training support (e.g., trying to discover a white background when the model was only trained on dark, unsaturated backgrounds).
  • Pre-known Factors: The evaluation protocol assumes that the underlying primitive factors are known during benchmark setup, even if their specific test-time combination is unseen.
  • Future Directions: The authors note that a valuable next step would be developing a fully automated mechanism to detect, consolidate, and permanently catalog genuinely new primitives discovered at test time for future reuse.

Summary updated

BibTeX
@misc{wang2026test,
  author = {Zekun Wang and Anant Gupta and Tianyi Zhu and Christopher J. MacLellan},
  title = {{Test-Time Compositional Generalization in Diffusion Models via Concept Discovery}},
  year = {2026},
  eprint = {2605.07078},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.07078},
}
Figure