---
title: Hierarchical Variational Models (HVMs)
url: https://www.emergentmind.com/topics/hierarchical-variational-models-hvms
type: topic
---

# Hierarchical Variational Models (HVMs)

Hierarchical Variational Models (HVMs) are a class of variational inference methods that extend the flexibility of approximate posterior distributions by introducing additional latent or variational random variables. This hierarchical structure enables HVMs to capture complex dependencies and multimodalities in latent variable models, including nontrivial marginal posteriors that simple mean-field approximations cannot represent. HVMs admit provable lower bounds on marginal likelihood and are mathematically equivalent to models such as Auxiliary Deep Generative Models under mild assumptions [1603.02443]. Their flexibility extends to discrete and continuous latent variables, supporting black-box inference and scalable stochastic optimization [1511.02386].

## 1. Model Architecture and Mathematical Formulation

At the core, HVMs introduce a hierarchical auxiliary latent variable $h$ into the variational family. The generative model is unaltered:

$p(x,z) = p(x|z)\,p(z)$

The variational approximation is expanded hierarchically:

$q(z,h|x;\varphi) = q(h|x;\varphi_1)\,q(z|h,x;\varphi_2)$

This factorization requires only the ability to evaluate and sample from each conditional factor. The marginal $q(z|x)$ becomes:

$q(z|x) = \int q(h|x)\,q(z|h,x)\,dh$

which is generally intractable, but sampling-based approximations are straightforward.

The hierarchical structure creates implicit mixture or compound variational families: even if $q(z|h,x)$ is unimodal and simple, integrating over $h$ enables the modeling of complex multimodal or heavy-tailed marginals [1603.02443, 1511.02386].

## 2. Evidence Lower Bound (ELBO) Derivation and Learning

The standard evidence lower bound,

$\log p(x)\geq \mathbb{E}_{q(z|x)}[\log p(x,z) - \log q(z|x)]$,

cannot be used directly because $q(z|x)$ is intractable. Instead, HVMs optimize a joint ELBO over $(z,h)$ but require correction to ensure a valid lower bound. The hierarchical ELBO is constructed as:

$
\mathcal{L}(\varphi,\psi) = \mathbb{E}_{q(z,h|x;\varphi)}[ \log p(x,z) + \log r(h|z,x;\psi) - \log q(h|x;\varphi_1) - \log q(z|h,x;\varphi_2) ]
$

where $r(h|z,x;\psi)$ is an auxiliary "reverse" inference model, ideally matching $q(h|z,x;\varphi)$, and $\psi$ are its parameters [1603.02443].

This bound is provably valid. When $r(h|z,x) = q(h|z,x)$, it collapses to the standard marginal ELBO [1603.02443]; otherwise, it penalizes mismatch via a KL term.

Pseudocode for HVM learning iteratively samples $(h,z)\sim q(h|x)\,q(z|h,x)$, evaluates the per-sample ELBO, computes gradients with respect to both generative and variational parameters, and updates using stochastic optimization such as ADAM [1603.02443, 1511.02386].

## 3. Expressive Power and Related Variational Families

The essential virtue of HVMs is the flexibility of the marginal $q(z|x)$. The induced posterior $q(z|x) = \int q(h|x)\,q(z|h,x)\,dh$ can be arbitrarily expressive even if $q(z|h,x)$ and $q(h|x)$ are both simple (e.g., diagonal Gaussians), enabling multimodality, heavy tails, and complex structure in the variational family [1603.02443].

HVMs subsume and unify several other expressive variational family architectures:

- **Auxiliary Deep Generative Models:** These models enrich the generative model with an auxiliary variable, while HVMs augment the inference side. Both are mathematically equivalent: the term $r(h|z,x;\psi)$ in the HVM ELBO can be interpreted as an explicit auxiliary generative model factor. The two yield identical ELBOs and operational procedures [1603.02443].
- **Mixture and Flow-based Variational Families:** Placing a mixture or flow prior on the variational parameters (as with HVMs) admits a complexity in $q(z|x)$, comparable to, and generalizing, direct mixtures or normalizing flows [1511.02386, 1905.03290].

Key theoretical properties include that HVM ELBOs are valid variational lower bounds tightened when the auxiliary reverse $r(h|z,x)$ closely matches the true conditional, and that optimization behavior inherits standard stochastic variational inference convergence properties [1511.02386].

## 4. Extensions, Limitations, and Advanced Hierarchical Designs

The hierarchical variational principle generalizes to multi-level settings, semi-implicit construction, and complex dependencies:

- **Multi-level Hierarchies:** Deep hierarchies (e.g., $L$-layer latent stacks) are used for structured data (video, sequence models) and for improved representation learning [2103.04174, 2007.07307].
- **Semi-Implicit Variational Inference (SIVI/HSIVI):** These methods extend HVMs with implicit mixing layers, where only sample access is required for some variational variables. Hierarchical SIVI (HSIVI) provides a principled approach to stacking semi-implicit layers, using layerwise ELBO or score-matching objectives [2310.17153].
- **Importance Weighted and Locally-Enhanced Inference:** Recent works apply importance weighting to tighten ELBOs for each group of local random variables or throughout the hierarchy, yielding more accurate posterior approximation, especially when combined with subsampling [2203.04432, 1905.03290].

Limitations include the requirement of auxiliary density evaluation, potential increases in gradient variance, and calibration of auxiliary reverse distributions $r(h|z,x)$ or inverse models $\tau(\cdot)$ in tighter bounds. For discrete auxiliary variables or complex dependencies, variance reduction techniques or partial analytic marginalization may be required [1511.02386, 1905.03290].

## 5. Connections with Classical and Modern Bayesian Inference

HVMs generalize both classical hierarchical Bayesian modeling and modern amortized variational inference:

- In Bayesian hierarchical regression and empirical Bayes, mean-field or structured variational factorization closely follows the posterior factorization of Bayesian graphical models, enabling conjugate closed-form solutions when available, otherwise using black-box optimization [1811.03687].
- In deep generative models, hierarchical priors prevent over-regularization and enable the variational code to reflect the data manifold more faithfully (e.g., Taming VAEs with hierarchical priors) [1905.04982].
- For mixed-type or missing data, hierarchical dependencies among latent variables, combined with advanced sampling or HMC-based inference, have demonstrated state-of-the-art results in imputation and active feature acquisition [2202.04599].

The unification provided by importance weighted HVMs bridges classical auxiliary-variable bounds, semi-implicit variational inference, and more recent doubly-semi-implicit cases. Each is recovered by appropriate specialization of the IWHVI upper/lower bounds and associated auxiliary distributions [1905.03290].

## 6. Practical Algorithmic Considerations and Empirical Results

HVMs support scalable learning algorithms with computational complexity linear in retained factorization structure and the number of auxiliary variables. Black-box gradient estimators are enabled by reparameterization and stochastic optimization [1511.02386].

Empirical evaluations demonstrate that HVMs:

- Substantially tighten variational bounds compared to standard mean-field or naive VI in structured models, including deep exponential families, variational autoencoders with structured priors, and hierarchical discrete VAEs [1511.02386, 2007.07307, 2103.04174].
- Enable disentangled representation learning, particularly in sequence domains and deep hierarchies, by structuring the generative process to separate sequence-level and segment-level factors (e.g., FHVAE) [1804.03201].
- Outperform classical and MCMC-based inference in terms of computational efficiency and often show superior predictive and generative accuracy [1811.03687, 2203.04432].
- Can be applied effectively to large-scale data, including speech, video, and missing data scenarios, via advanced local and amortized variational families [2103.04174, 2007.07307, 2202.04599].

## 7. Theoretical Guarantees and Mathematical Equivalence

HVMs and their auxiliary- or semi-implicit equivalents admit sharp theoretical guarantees:

- The hierarchical ELBO is a valid lower bound, tightening to the marginal ELBO when the auxiliary reverse matches the true conditional.
- For importance weighted HVMs, the family of lower and upper bounds constructed (e.g., IWHVI, DIWHVI) converge to the true marginal likelihood as the number of samples increases, and sandwich the standard ELBO and SIVI-type bounds as special cases [1603.02443, 1905.03290].
- Mathematical equivalence holds between HVMs and auxiliary deep generative models: reinterpreting auxiliary distributions between inference and generative side yields identical ELBO objectives and optimization [1603.02443].

This equivalence, coupled with the black-box optimization framework, marks HVMs as a theoretically well-grounded and practical generalization of variational inference methods in modern probabilistic modeling.

---

**Principal references:**  
[1511.02386] Ranganath et al., "Hierarchical Variational Models"  
[1603.02443] Brümmer, "Note on the equivalence of hierarchical variational models and auxiliary deep generative models"  
[1905.03290] Bauer et al., "Importance Weighted Hierarchical Variational Inference"  
[2203.04432] Kingma et al., "Variational Inference with Locally Enhanced Bounds for Hierarchical Models"  
[2103.04174], [2007.07307], [1804.03201], [1905.04982], [1811.03687] for application- and domain-specific developments.

Source: https://www.emergentmind.com/topics/hierarchical-variational-models-hvms