Practical and Asymptotically Exact Conditional Sampling in Diffusion Models

Brian L. Trippe, Luhuan Wu, Christian A. Naesseth, David Blei, John Patrick Cunningham

TL;DR

This paper introduces the Twisted Diffusion Sampler (TDS), a novel algorithm that enables diffusion models to perform exact conditional sampling without requiring task-specific training. By combining Sequential Monte Carlo (SMC) with a technique called "twisting," TDS offers a practical and efficient way to generate data that precisely matches specified conditions, outperforming existing methods on tasks like image inpainting and protein design.

What Problem Does This Paper Address?

Diffusion models have become incredibly powerful for generating realistic data, from images to molecular structures. However, making them generate data that specifically meets certain criteria (conditional generation) has been a major hurdle. Current approaches either require expensive, custom training for each new condition or rely on heuristic methods that are often inaccurate and unreliable. This is particularly problematic in fields like drug discovery or material science, where even small errors in conditional generation can lead to chemically impossible or functionally useless outputs. The authors aim to bridge this gap by providing a method that is both theoretically sound (asymptotically exact) and practically applicable.

Methods

The core innovation is the Twisted Diffusion Sampler (TDS), which leverages Sequential Monte Carlo (SMC). Here's the breakdown:

  • Diffusion Models as Markov Chains: The paper frames the reverse diffusion process (generating data from noise) as a sequential process, similar to a Markov chain. This structure is amenable to SMC techniques.
  • Sequential Monte Carlo (SMC): SMC is a general framework for approximating probability distributions by maintaining a set of weighted "particles" that evolve over time. It's known for its ability to provide asymptotically exact inference.
  • Twisting: This is the key novelty. Twisting is an SMC technique that modifies the "proposal" distributions (how particles move) and "weighting" mechanisms to bring them closer to the optimal choices for the target distribution. This significantly improves efficiency and accuracy.
  • Heuristic Approximations with Correction: TDS uses heuristic approximations for certain parts of the diffusion process (like the score function) but corrects for any inaccuracies through the SMC weighting mechanism. This allows it to benefit from efficient approximations without sacrificing asymptotic exactness.
  • Riemannian Manifold Extension: The authors show that TDS can be extended to diffusion models operating on Riemannian manifolds, which are crucial for representing complex structures like protein backbones.

Datasets

The paper evaluates TDS on several standard datasets and benchmarks:

  • MNIST: Used for class-conditional generation and image inpainting tasks.
  • Protein Motif-Scaffolding Benchmark: A set of 24 problems used to evaluate protein design capabilities.

Key Insights and Ideas

  • Bridging the Gap: The most significant insight is that by combining the sequential nature of diffusion models with the power of SMC and the efficiency of twisting, it's possible to achieve exact conditional sampling without task-specific training.
  • Twisting as a Game-Changer: Twisting is presented not just as an optimization, but as a crucial component that allows heuristic approximations to be used effectively while maintaining theoretical guarantees.
  • Flexibility in Conditioning: TDS offers more flexible conditioning criteria than existing methods, particularly in complex domains like protein design, where specifying exact motif locations or orientations can be challenging.
  • Practicality Matters: The authors demonstrate that TDS is not just theoretically sound but also performs well in practice, often outperforming state-of-the-art methods with fewer particles or less specialized training.

Key Results

  • MNIST Class-Conditional Generation: TDS generates diverse and high-quality digits, outperforming other SMC samplers in particle efficiency. With as few as 2 particles, TDS achieved comparable or better classification accuracy than baselines.
  • MNIST Inpainting: TDS shows strong performance in inpainting tasks, achieving high classification and Bayes accuracy, often outperforming SMC-Diff and Replacement methods.
  • Protein Design (Motif-Scaffolding): TDS achieves state-of-the-art success rates on 9/12 problems in a benchmark set for scaffolds shorter than 100 residues. It also enables more flexible conditioning criteria than previous methods.
  • Riemannian Diffusion Models: The extension of TDS to Riemannian manifolds is shown to be effective for tasks like protein backbone generation.

Limitations and Future Work

  • Computational Resources: TDS requires simulating multiple particles, which can be computationally intensive. The exact number of particles needed for good performance is problem-dependent.
  • Twisting Function Design: Designing optimal twisting functions for generic, nonlinear constraints can be challenging.
  • Future Directions: The authors suggest improving computational efficiency and addressing the challenges in designing twisting functions for complex constraints as important avenues for future research.

Summary updated

Abstract

Diffusion models have been successful on a range of conditional generation tasks including molecular design and text-to-image generation. However, these achievements have primarily depended on expensive, task-specific conditional training or error-prone heuristic approximations to them. Ideally, a conditional generation method should provide exact samples for a broad range of conditional distributions without requiring task-specific training. To this end, we introduce the Twisted Diffusion Sampler, or TDS, a sequential Monte Carlo (SMC) algorithm that targets the conditional distributions of diffusion models. The main idea is to use twisting, an SMC technique the enjoys good computational efficiency, to incorporate heuristic approximations without compromising asymptotic exactness. We study the properties of TDS on MNIST image inpainting and class-conditional generation tasks. TDS extends to Riemannian diffusion models, which are crucial for protein modeling. When applied to the motif-scaffolding problem, a core problem in protein design, TDS enables more flexible conditioning criteria than conditionally trained models, and provides state-of-the-art success rates on 9/12 problems in a benchmark set with scaffolds shorter than 100 residues.
BibTeX
@inproceedings{trippe2023practical,
  author = {Brian L. Trippe and Luhuan Wu and Christian A. Naesseth and David Blei and John Patrick Cunningham},
  title = {{Practical and Asymptotically Exact Conditional Sampling in Diffusion Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2023},
  url = {https://openreview.net/forum?id=eWKqr1zcRv},
}
Figure