Abstract: Variational inference has become a widely used method to approximate posteriors in complex latent variables models. However, deriving a variational inference algorithm generally requires significant model-specific analysis. These efforts can hinder and deter us from quickly developing and exploring a variety of models for a problem at hand. In this paper, we present a “black box” variational inference algorithm, one that can be quickly applied to many models with little additional derivation. Our method is based on a stochastic optimization of the variational objective where the noisy gradient is computed from Monte Carlo samples from the variational distribution. We develop a number of methods to reduce the variance of the gradient, always maintaining the criterion that we want to avoid difficult model-based derivations. We evaluate our method against the corresponding black box sampling based methods. We find that our method reaches better predictive likelihoods much faster than sampling methods. Finally, we demonstrate that Black Box Variational Inference lets us easily explore a wide space of models by quickly constructing and evaluating several models of longitudinal healthcare data.
Introduction
In Bayesian machine learning, the central challenge is computing the posterior distribution—the probability of hidden variables given observed data. For complex models, exact calculation is often intractable. Variational Inference (VI) addresses this by transforming the problem into an optimization task: finding a simpler distribution that approximates the true posterior by maximizing the Evidence Lower Bound (ELBO).
Traditionally, VI has been labor-intensive. Practitioners were required to analytically derive complex expectations for every new model. This model-specific derivation is slow, error-prone, and limits the ability of researchers to iterate on different modeling assumptions. If a model does not fit into specific mathematical categories, such as conjugate exponential families, standard VI becomes difficult to apply.
Methods
The authors propose Black Box Variational Inference (BBVI), a generic algorithm that requires only that a user can evaluate the log-likelihood of their model. The core of the approach is a stochastic optimization of the ELBO using the "score function" (or REINFORCE) estimator. This allows the gradient to be estimated using Monte Carlo samples from the variational distribution, making the gradient of the log-variational distribution dependent only on the variational family, not the model itself.
However, raw Monte Carlo gradients are often too noisy for practical use. To stabilize the algorithm, the authors introduce two critical variance reduction techniques:
- Rao-Blackwellization: This technique exploits the local structure of the model (Markov blankets) to ignore irrelevant variables when computing the gradient for a specific parameter.
- Control Variates: The score function itself is used as a "baseline" to cancel out variance without biasing the expected value of the gradient.
As shown in the figure above, these techniques are essential. Rao-Blackwellization reduces gradient variance by several orders of magnitude, and the addition of control variates provides a further significant boost, making the "black box" approach computationally viable.
Experimental Evaluation
The authors evaluated BBVI using a real-world longitudinal healthcare dataset from the Columbia University Medical Center (CUMC). The data included records from 976 patients with chronic kidney disease, totaling 33,000 clinic visits and 17 different lab measurements. The task was to summarize patient health over time using various latent factor models, including non-conjugate models like Gamma-Normal and Gamma-Gamma distributions.
Key Results
BBVI demonstrated significant advantages in both speed and accuracy compared to traditional sampling methods like Metropolis-Hastings within Gibbs.
In the healthcare data experiments, BBVI reached higher predictive likelihoods significantly faster than the sampling baseline. This efficiency allowed the authors to quickly compare four different complex models—a process that would have traditionally required weeks of manual derivation.
Conclusion
Black Box Variational Inference represents a shift toward "plug-and-play" probabilistic modeling. By automating the mathematical heavy lifting of VI through stochastic optimization and aggressive variance reduction, it enables researchers to focus on model design rather than algorithmic derivation. While the method is sensitive to sample sizes and could benefit from more sophisticated sampling techniques like quasi-Monte Carlo methods, it provides a scalable framework for exploring a wide space of non-conjugate models in complex domains like healthcare.
Summary updated