NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Nested Variational Inference

Heiko Zimmermann, Hao Wu, Babak Esmaeili, Jan-Willem van de Meent

Introduction

Nested Variational Inference (NVI) is a novel framework that bridges the gap between importance sampling and variational inference by optimizing a sequence of local objectives. By minimizing divergences at every "level" of a sampling process, NVI allows researchers to learn high-quality proposals and intermediate densities. This results in better mode coverage and more accurate posterior approximations in complex, structured models.

The Challenge with Standard Variational Inference

Standard Variational Inference (VI)—the engine behind models like Variational Autoencoders (VAEs)—typically relies on maximizing a single global objective: the Evidence Lower Bound (ELBO). While effective for simple models, this approach often fails when the prior is highly structured or the posterior is multimodal (containing multiple peaks).

To address this, researchers frequently turn to multi-step sampling methods like Sequential Monte Carlo (SMC) or Annealed Importance Sampling (AIS). However, these traditional methods are usually "hard-coded." They do not easily allow practitioners to learn the optimal way to transition from a simple starting distribution to a complex target. The core challenge lies in creating a unified, differentiable framework capable of learning the optimal "path" and proposals for these multi-step samplers without suffering from high gradient variance or massive memory requirements.

The NVI Approach

The central innovation of NVI is nesting. Instead of relying on one large loss function at the end of a sampling chain, NVI defines a sequence of intermediate targets.

Nested Variational Inference optimizes local divergences between forward and reverse kernels at each step.
  1. Local Objectives: At each step $k$ in the sampling sequence, NVI minimizes the discrepancy (an $f$-divergence, such as KL divergence) between a "forward" density (the proposal) and a "reverse" density (the target).
  2. Incremental Weights: Unlike standard importance-weighted VI, which uses a global weight dependent on the entire sampling history, NVI utilizes incremental weights. This localizes the gradient computation to a specific level of the sampler.
  3. Memory Efficiency: Because gradients are localized, NVI does not necessarily need to backpropagate through the entire chain of samples. This reduces memory scaling from $O(SK)$ (where $S$ is samples and $K$ is steps) to $O(S)$, enabling much deeper sampling chains.
  4. Learned Annealing: NVI can learn the "annealing schedule"—the path the distribution takes as it transforms from a simple Gaussian to a complex posterior. This ensures that each step is "equidistant" in terms of information gain, smoothing the interpolation compared to standard linear schedules.

Key Insights and Results

The authors evaluated NVI across several tasks, including synthetic multimodal distributions, Hidden Markov Models (HMMs), and hierarchical deep generative models (using MNIST and FashionMNIST).

Variance Reduction and Resampling

A major insight from the paper is overcoming the poor signal-to-noise ratio that plagues standard importance-weighted objectives as sample sizes increase. Because NVI stays "local" and avoids computing the logarithm of an average global weight, it achieves much more stable training. Furthermore, incorporating importance resampling (effectively turning NVI into a "Variational SMC") acts as a regularizer. It reduces the reliance on having perfect proposals at every single step, smoothing out training dynamics.

Superior Mode Coverage

In a synthetic 2D "flower" distribution task designed to test mode-seeking behavior, NVI demonstrated significant improvements over baselines.

NVIR* successfully captures all 8 modes of the target distribution, whereas baseline methods like AVO struggle with mode collapse.

The NVIR* variant successfully captured all 8 isolated modes with equal mass. In contrast, baseline methods like Annealed Variational Objectives (AVO) often missed modes entirely or distributed mass unevenly.

Improved Sample Quality and Hierarchical Inference

Across the board, NVI consistently outperformed standard VI and Variational SMC baselines in terms of Effective Sample Size (ESS) and the log marginal likelihood estimate ($\log \hat{Z}$). When applied to a Bayesian Gaussian Mixture Model VAE (BGMM-VAE) on image datasets, NVI accurately inferred class weights in a complex hierarchical model where standard algorithms like Reweighted Wake-Sleep (RWS) produced poor posterior approximations.

Limitations and Future Work

While powerful, NVI has some limitations. The authors noted that optimizing the forward KL divergence to learn "reverse kernels" can be unstable, prompting them to use the reverse KL in those specific instances. Additionally, while theory suggests NVI can handle a very large number of nesting levels ($K$), the experiments were limited to relatively small depths (up to 8 for annealing, 200 for HMMs). The stability of gradients at extreme depths remains an open question.

Looking ahead, NVI presents a natural fit for Probabilistic Programming Languages (PPLs), where it could be leveraged to automatically derive robust inference schemes for complex, user-defined probabilistic programs.

Summary updated

BibTeX
@inproceedings{zimmermann2021nested,
  author = {Heiko Zimmermann and Hao Wu and Babak Esmaeili and Jan-Willem van de Meent},
  title = {{Nested Variational Inference}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2021},
  url = {https://openreview.net/forum?id=kBrHzFtwdp},
}
Figure