Amortizing intractable inference in diffusion models for vision, language, and control

Siddarth Venkatraman, Moksh Jain, Luca Scimeca, Minsu Kim, Marcin Sendera, Mohsin Hasan, Luke Rowe, Sarthak Mittal, Pablo Lemos, Emmanuel Bengio, Alexandre Adam, Jarrid Rector-Brooks, Yoshua Bengio, Glen Berseth, Nikolay Malkin

Introduction

Diffusion models have established themselves as the state-of-the-art for high-fidelity generation in domains ranging from computer vision to robotics. However, a persistent challenge remains: how to effectively "steer" these models to satisfy specific constraints or maximize particular reward functions without losing the diversity of the original generative prior. This problem, known as posterior inference, involves sampling from a distribution $p(x|y) \propto p(x)r(x)$, where $p(x)$ is a pretrained diffusion prior and $r(x)$ is a reward or constraint function.

Traditional approaches to this problem often face significant trade-offs. Classifier guidance requires training auxiliary models on noisy data; reinforcement learning (RL) fine-tuning often leads to "mode collapse," where the model sacrifices diversity for high rewards; and MCMC-based methods are frequently too computationally expensive for high-dimensional applications. This paper introduces Relative Trajectory Balance (RTB), a novel training objective that amortizes the cost of complex posterior inference, providing an asymptotically unbiased way to fine-tune diffusion models.

The Relative Trajectory Balance (RTB) Framework

RTB is built upon the theoretical foundation of Generative Flow Networks (GFlowNets). Rather than treating diffusion as a simple denoising process, RTB views the entire generation sequence as a trajectory through a state space.

The core innovation of RTB is a consistency constraint applied to these trajectories. It enforces that the ratio of the probability of a trajectory in the updated (posterior) model versus the original (prior) model must be proportional to the reward $r(x)$ divided by a learned normalization constant $Z$.

Key Technical Advantages

  • Data-Free Learning: RTB does not require a dataset of samples that already satisfy the target constraints. It learns solely from the pretrained prior and the reward function.
  • Off-Policy Training: The objective allows the model to learn from trajectories stored in a replay buffer, even if they were generated by previous versions of the model. This facilitates the discovery of rare, high-reward modes that standard on-policy methods might miss.
  • Langevin Inductive Bias: For scenarios where the reward function is differentiable, RTB incorporates the gradient of the reward directly into the model's architecture. This "nudges" the denoising process at every step, significantly improving training efficiency.

Experimental Results

The authors evaluated RTB across a diverse array of tasks to demonstrate its versatility and robustness.

Vision and Text-to-Image

In class-conditional generation tasks (MNIST and CIFAR-10), RTB achieved a superior balance between reward (class accuracy) and diversity (FID scores) compared to existing RL-based methods like DDPO. Furthermore, the authors applied RTB to Stable Diffusion v1-5 using the ImageReward dataset. The results showed that RTB could fine-tune the model to better adhere to complex, multi-object prompts (e.g., "a cat and a dog") while avoiding the repetitive, low-diversity outputs common in standard fine-tuning.

Language Infilling

Using the ROCStories corpus, RTB was tasked with "infilling" missing sentences in a narrative. The model outperformed both simple zero-shot prompting and previous GFlowNet-based autoregressive models, generating completions that were more contextually coherent and relevant to the overall story arc.

Continuous Control and Offline RL

RTB was tested on the D4RL benchmark, the standard for offline reinforcement learning. It achieved state-of-the-art results on several tasks (HalfCheetah, Hopper, Walker2d). RTB proved particularly effective in "medium-replay" scenarios, where the training data is noisy and the initial behavior policy is suboptimal, demonstrating its ability to extract high-performing policies from messy data.

Discussion and Future Work

RTB represents a significant step forward in making diffusion models more controllable and useful for downstream tasks. By framing the problem as trajectory balancing, the authors provide a mathematically grounded way to preserve the "creativity" of the prior while optimizing for specific goals.

However, challenges remain. Training RTB models is computationally intensive, as it requires simulating numerous trajectories. Additionally, the "sparse reward" problem—where feedback is only received at the end of a trajectory—can lead to high gradient variance. Future research may focus on "local-in-time" objectives to provide more frequent feedback during the generation process, potentially expanding RTB's utility in fields like molecular dynamics and scientific simulation where physical constraints serve as the reward function.

Summary updated

BibTeX
@inproceedings{venkatraman2024amortizing,
  author = {Siddarth Venkatraman and Moksh Jain and Luca Scimeca and Minsu Kim and Marcin Sendera and Mohsin Hasan and Luke Rowe and Sarthak Mittal and Pablo Lemos and Emmanuel Bengio and Alexandre Adam and Jarrid Rector-Brooks and Yoshua Bengio and Glen Berseth and Nikolay Malkin},
  title = {{Amortizing intractable inference in diffusion models for vision, language, and control}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2024},
  url = {https://openreview.net/forum?id=gVTkMsaaGI},
}
Figure