Few-Shot Diffusion Models

Giorgio Giannone, Didrik Nielsen, Ole Winther

TL;DR

Few-Shot Diffusion Models (FSDM) allow generative models to produce high-quality, diverse images of entirely new categories using as few as five examples. By combining the high-fidelity generation of Diffusion Models with the flexible context-encoding of Vision Transformers, the authors create a system that adapts to unseen concepts without needing to be retrained from scratch.

What Problem Does This Paper Address?

While humans can see a few pictures of a "quokka" and immediately imagine what another one might look like, traditional AI models are "data-hungry." Denoising Diffusion Probabilistic Models (DDPMs) have recently set records for image quality, but they are notoriously difficult to adapt. Usually, if you want a DDPM to generate a new class of objects, you need thousands of images and a massive amount of compute for retraining.

The authors tackle the challenge of few-shot generation: how can we condition a powerful generative model on a tiny "support set" of images so that it can "grasp" a new concept and generate novel variations of it? Previous attempts at this were often limited to very simple datasets or relied on rigid, handcrafted mechanisms that couldn't handle the complexity of real-world images.

Methods

The FSDM framework consists of two primary components working in tandem:

  1. The Set Encoder (sViT): The researchers adapted a Vision Transformer (ViT) to process a small set of images (the "context"). Instead of looking at one image, it treats the entire set as a collection of patches. This allows the model to extract global features (like "has fur" or "is a car") from across multiple examples.
  2. Learnable Attentive Conditioning (LAC): This is the paper's "secret sauce." While standard methods might just squash the context into a single vector (using a technique called FiLM), LAC uses a cross-attention mechanism. The generative model "attends" to specific patches in the context set while it's denoising the new image. This allows for a much more granular transfer of information—the model can look at the wheels of one context image and the color of another to inform the new sample.

The model is trained using a conditional version of the standard diffusion loss, essentially learning to predict noise while being "guided" by the set encoder.

Datasets

The authors evaluated FSDM on four diverse image datasets:

  • Omniglot: A "lake-of-characters" dataset used for basic few-shot testing.
  • FS-CIFAR100: A version of the classic CIFAR dataset split specifically for few-shot tasks (60 classes for training, 20 for validation, 20 for testing).
  • miniImageNet: A more complex dataset of 32x32 images used to test the model's ability to handle realistic objects.
  • CelebA: Used for high-resolution (64x64) face generation visualizations.

Crucially, they also performed transfer learning tests, training on CIFAR100 and testing on miniImageNet to see how well the model generalizes to entirely different data distributions.

Key Insights and Ideas

  • Conditioning Speeds Up Convergence: One of the most surprising findings was that adding conditioning doesn't just make the model smarter—it makes it learn faster. FSDM reached lower error rates significantly earlier in the training process compared to unconditional baselines.
  • The Power of Patches: By processing the input set as a "bag of patches" rather than a single global description, the model can perform a sort of "mental interpolation." It doesn't just copy one image; it composes new ones based on the visual vocabulary found in the support set.
  • Input-Dependent Bottlenecks: The authors found that making the context extraction dependent on the specific input sample during training acts as a beneficial bottleneck. This prevents the model from simply memorizing classes and forces it to learn how to actually use the provided context to generate details.

Key Results

  • Superior Sample Quality: On CIFAR100, FSDM achieved an FID (Fréchet Inception Distance) of 35.07 for unseen classes, nearly doubling the performance of standard unconditional DDPMs (FID 62.84) and outperforming other conditional baselines.
  • Robust Transfer: When trained on CIFAR100 and tested on the more difficult miniImageNet, FSDM maintained its lead (FID 39.55 vs. 63.13 for the baseline), proving it isn't just memorizing the training set.
  • Precision and Recall: The model showed higher "Recall" scores, indicating it generates a wider variety of samples within a new class, rather than just repeating the same few patterns (mode collapse).

Limitations and Future Work

  • The Variety-Quality Trade-off: The authors noted that while the model is great at "out-of-distribution" tasks (new classes), there is a slight trade-off where it might produce less variety for classes it has already seen compared to a specialized model.
  • Complexity Scaling: While results on 32x32 and 64x64 images are impressive, scaling this to very high-resolution images (like 1024x1024) would likely require significantly more compute and more efficient attention mechanisms.
  • Future Directions: The researchers suggest exploring "Variational FSDM" further—treating the context as a latent variable with its own distribution—which could lead to even more creative and diverse few-shot generation.

Summary updated

BibTeX
@inproceedings{giannone2022few,
  author = {Giorgio Giannone and Didrik Nielsen and Ole Winther},
  title = {{Few-Shot Diffusion Models}},
  booktitle = {SBM @ NeurIPS},
  year = {2022},
  url = {https://openreview.net/forum?id=rqKTms-YHAW},
}
Figure