---
title: Markovian Hierarchical Variational Autoencoders
url: https://www.emergentmind.com/topics/markovian-hierarchical-variational-autoencoders-hvaes
type: topic
---

# Markovian Hierarchical Variational Autoencoders

Markovian Hierarchical Variational Autoencoders (HVAEs) are a class of generative models that structure the latent variable space into multiple stochastic layers, with each layer forming a Markov chain—each variable depending only on its immediate predecessor or successor. Markovian HVAEs, introduced to leverage deep feature hierarchies within generative modeling frameworks, reveal both representational power and fundamental limitations in terms of hierarchical feature disentanglement. Extensions using quantized discrete codes, such as Hierarchical Quantized Autoencoders (HQA), combine the Markovian structure with powerful discrete representation learning for improved lossy image compression and the retention of semantic features.

## 1. Model Structure and Markovian Assumptions

A Markovian HVAE defines a generative process with $L$ stochastic layers, with the observation $x$ at the bottom and latent variables $z_1, z_2, \dots, z_L$ hierarchically above. The generative joint factorizes as

\[
p_\theta(x,z_{1:L}) = p_\theta(x\mid z_1)\, \prod_{\ell=1}^{L-1} p_\theta(z_\ell\mid z_{\ell+1})\, p_\theta(z_L)
\]

where $z_1$ is directly connected to the data, and each $z_\ell$ is conditionally independent of $z_{>\ell+1}$ given $z_{\ell+1}$. The decoder reads only $z_1$, i.e., $x \perp z_{2:L}\mid z_1$. In the discrete code version—exemplified by HQA—the hierarchy is implemented in terms of a Markov chain on discrete code indices $z^{(1)}, \ldots, z^{(L)}$ and associated continuous embeddings $z_e^{(l)}$ [1702.08396, 2002.08111].

## 2. Variational Inference and Posterior Approximations

The variational inference model is typically constructed in a "bottom-up" or mean-field form that reverses the arrows of the generative chain:

\[
q_\phi(z_{1:L}\mid x) = q_\phi(z_1\mid x)\prod_{\ell=2}^L q_\phi(z_\ell\mid z_{\ell-1},x)
\]

A more general inference model may allow for dependencies on $z_{<\ell}$ or $z_{>\ell}$, but the Markovian case restricts posterior dependencies to mirror the generative structure. In the setting of quantized HVAEs, the approximate posterior is fully factorized over quantized discrete variables at each layer:

\[
q(z^{(1:L)}\mid x) = \prod_{l=1}^L q(z^{(l)}\mid z_e^{(l)})
\]
where $q(z^{(l)}=k\mid z_e^{(l)}) \propto \exp(-\|z_e^{(l)}-e^{(l)}_k\|_2^2)$ and stochastic quantization is performed using Gumbel–Softmax annealed to exact sampling at test time [2002.08111].

## 3. Evidence Lower Bound and Layer-wise Decomposition

The standard objective is the maximization of the evidence lower bound (ELBO):

\[
\log p_\theta(x)\geq \mathcal{L}_\mathrm{ELBO}(x) = \mathbb{E}_{q_\phi(z_{1:L} \mid x)}[\log p_\theta(x, z_{1:L}) - \log q_\phi(z_{1:L}\mid x)]
\]

Substituting the Markov factorization yields a layer-wise decomposition:

\begin{align*}
\mathcal{L}_\mathrm{ELBO}
&= \mathbb{E}_q[\log p_\theta(x\mid z_1)]
  +\sum_{\ell=1}^{L-1}\mathbb{E}_q[\log p_\theta(z_\ell\mid z_{\ell+1})]
  +\mathbb{E}_q[\log p_\theta(z_L)]
\\
&\qquad-\mathbb{E}_q[\log q_\phi(z_1\mid x)]
  -\sum_{\ell=2}^L\mathbb{E}_q[\log q_\phi(z_\ell\mid z_{\ell-1}, x)]
\end{align*}

In quantized/discrete Markovian HQA, the objective per layer is

\[
\mathcal{L}^{(l)} = \mathbb{E}_{q(z^{(l)}\mid z_e^{(l)})}\bigl[-\log p(\mathit{target}^{(l-1)} \mid z^{(l)})\bigr]
    - \beta_e\,\mathcal H\bigl[q(z^{(l)}\mid z_e^{(l)})\bigr] + \beta_c\, \mathbb{E}_{q(z^{(l)}\mid z_e^{(l)})}\|z_e^{(l)} - e^{(l)}_{z^{(l)}}\|_2^2
\]
where $\mathit{target}^{(0)}=x$ for the lowest level and $z_e^{(l-1)}$ for upper layers [2002.08111].

## 4. Theoretical Properties and Limitations

Markovian HVAE architectures are subject to representational redundancy and severe constraints on hierarchical feature learning:

- **Redundancy at Optimum:** At the global optimum of the ELBO—where $q(z_{1:L}\mid x) = p_\theta(z_{1:L}\mid x)$ and $p_\theta(x)=p_{\rm data}(x)$—the distribution over data can be reconstructed solely from the bottom layer $z_1$. That is, a two-step Gibbs chain alternately sampling $z_1\sim q(z_1\mid x)$ and $x\sim p_\theta(x\mid z_1)$ suffices, with upper layers contributing nothing additional [1702.08396, Prop. 1].

- **Limited Hierarchical Feature Learning:** The conditional priors $p_\theta(z_\ell\mid z_{\ell+1})$ are typically chosen from restrictive unimodal families (such as Gaussians). This enforces the approximate posteriors to be unimodal, preventing the emergence of nontrivial, multimodal, part-subpart correlations. As a result, stacking additional latent layers does not yield interpretable or disentangled feature hierarchies—a phenomenon contrary to the compositional representations observed in supervised deep networks [1702.08396].

## 5. Empirical Evaluation and Model Behavior

Experimental studies with Markovian HVAEs using natural image datasets (e.g., MNIST, SVHN) confirm these theoretical limitations:

- **Qualitative Sampling:** Samples from the full hierarchical ancestral model and the bottom-layer-only Gibbs chain are nearly indistinguishable, demonstrating redundancy of upper layers.
- **Layer-wise Noise Perturbation:** Varying only the top layer's noise leads to almost all global variation in $x$, whereas perturbing lower layers yields only minimal, local changes—indicating the lack of rich hierarchical structure [1702.08396].

In discrete Markov hierarchies such as HQA, additional empirical gains are found in compressed image settings:

- **Compression Benchmarks:** On CelebA at 576 bits (171× compression), HQA achieves rFID ≈ 39.1, outperforming flat VQ-VAE (rFID ≈ 52.3) and hierarchical autoregressive models (HAMs; rFID ≈ 52.3). At extreme 9-bit rates, HQA maintains rFID ≈ 85.3, superior to HAMs (167.6) and VQ-VAE (196.0) [2002.08111].
- **Ablation Studies:** On MNIST at 8 bits, HQA achieves the lowest rFID (22.8) and classification error (~12.4%) compared to non-hierarchical or non-stochastic baselines.

## 6. Architectural Choices in Markovian Hierarchical Discrete Models

Hierarchical Quantized Autoencoders operationalize the Markov chain via layerwise discrete codes and embeddings:

- Each layer reduces spatial resolution by ×2 via a convolutional encoder, yielding a $D$-dimensional embedding.
- A "codebook" of $N$ vectors provides discrete latent code implementations with Gaussian mixture priors.
- The decoder upsamples from code embeddings to soft targets at the lower layer; at the bottom, reconstructions map back to pixel space via Bernoulli or Gaussian likelihoods.
- Greedy layerwise training—enabled by Markov conditional independence—allows each level to reconstruct the "soft-embedding" representation of the level below [2002.08111].

These choices—especially the combination of hierarchy, stochastic quantization, and MSE targets—are shown to preserve semantic content and achieve multimodal reconstructions even at very low bitrates.

## 7. Significance, Context, and Future Directions

Markovian HVAEs clarify both the strengths and inherent bottlenecks of hierarchical stochastic latent modeling in generative frameworks. While conditional independence and Markovian factorization yield tractable inference and modular design, they also induce redundancy and fail to capture deep, disentangled feature hierarchies under most variational training protocols [1702.08396]. Introduction of discrete latent codes and careful Markovian design—exemplified by HQA—mitigates mode-dropping and delivers empirically superior performance in low-bitrate lossy compression [2002.08111]. A plausible implication is that meaningful hierarchical compositionality may require departing from strict Markovianity, or introducing richer conditional structures and priors at upper layers, to achieve interpretable, disentangled representations.

Source: https://www.emergentmind.com/topics/markovian-hierarchical-variational-autoencoders-hvaes