Abstract: We propose Diffusion Model Variational Inference (DMVI), a novel method for automated approximate inference in probabilistic programming languages (PPLs). DMVI utilizes diffusion models as variational approximations to the true posterior distribution by deriving a novel bound to the marginal likelihood objective used in Bayesian modelling. DMVI is easy to implement, allows hassle-free inference in PPLs without the drawbacks of, e.g., variational inference using normalizing flows, and does not make any constraints on the underlying neural network model. We evaluate DMVI on a set of common Bayesian models and show that its posterior inferences are in general more accurate than those of contemporary methods used in PPLs while having a similar computational cost and requiring less manual tuning.
Introduction
Probabilistic Programming Languages (PPLs) allow researchers to define complex statistical models and automatically perform inference to find the posterior distribution of unknown parameters. Currently, PPLs rely on two primary strategies: Markov Chain Monte Carlo (MCMC) and Variational Inference (VI). While MCMC is highly accurate, it is often computationally prohibitive for large datasets. VI transforms inference into an optimization problem, offering speed at the cost of potential accuracy. Standard VI methods like Automatic Differentiation Variational Inference (ADVI) use restrictive Gaussian approximations, while more flexible Normalizing Flow Variational Inference (NFVI) requires specialized, invertible neural architectures that are difficult to tune and numerically unstable.
Diffusion Model Variational Inference (DMVI)
We introduce DMVI, which employs Diffusion Probabilistic Models (DPMs) as flexible variational approximations (or "guides"). The core innovation is a novel mathematical objective derived by applying the variational principle twice to the marginal likelihood, allowing the diffusion process's latent variables to be integrated into the variational objective.
Key advantages of DMVI include:
- Architectural Freedom: Unlike Normalizing Flows, DMVI does not require invertible layers or Jacobian determinant calculations. It can utilize standard neural networks, such as simple multi-layer perceptrons (MLPs), as score models.
- Efficient Sampling: By integrating modern DPM-solvers (efficient ODE-solvers), DMVI can generate high-quality posterior samples in just 10–20 steps, mitigating the traditional slowness of diffusion processes.
- Constraint Handling: Parameters with specific domains (e.g., positive variance) are handled via bijections to an unconstrained real-valued space, ensuring compatibility with standard PPL workflows.
Experimental Evaluation
DMVI was evaluated against ADVI and NFVI using synthetic datasets from three benchmark Bayesian models: a Gaussian Mean model, a Hierarchical model with complex dependencies, and a Gaussian Mixture model. Performance was measured across sample sizes of $N=100$ and $N=1000$.
Results and Discussion
As demonstrated in the experimental results, DMVI consistently provides more accurate posterior inferences than contemporary methods. In the Hierarchical model ($N=100$), which features a notoriously difficult "funnel" geometry, DMVI achieved a Mean Squared Error (MSE) of 0.39, significantly outperforming NFVI (0.62) and substantially improving upon ADVI (11.77).
DMVI's robustness to complex posterior geometries stems from its ability to learn how to "push" points from a simple distribution toward a complex target without the rigidity of Gaussian approximations. Furthermore, the lack of architectural constraints allowed for a consistent MLP setup across different problems with minimal hyperparameter tuning. While ADVI remains the fastest due to its simplicity, DMVI's training and sampling times are competitive with NFVI, particularly in complex hierarchical and mixture models.
Conclusion
DMVI represents a significant step forward for automated inference in PPLs, offering high expressivity without the architectural headaches of normalizing flows. Future work will explore scaling DMVI to high-dimensional parameter spaces and its integration into mainstream PPL frameworks like PyMC and Turing.jl.
Summary updated