Latent Variable Models and the Evidence Lower Bound

Imagine you have a dataset of handwritten digits. You want a model that explains why each image looks the way it does. A "7" might vary in slant, stroke width, and size. These are hidden factors that combine to produce pixels. If you could recover these factors, you could generate new digits. You could also denoise corrupted ones, or measure how well your model fits reality. This is the promise of a latent variable model: assume every observed data point xx was generated from some unobserved cause zz. Then learn the machinery that connects the two. The trouble is that scoring how good such a model is requires computing the marginal likelihood p(x)=∫p(x,z) dzp(x) = \int p(x, z)\, dz. For any interesting model — one where zz is high-dimensional or the generative process is a neural network — this integral has no closed form. It also has no efficient exact algorithm. This is not a minor inconvenience. It sits at the center of why generative modeling with latent variables is hard. It also explains why fields as different as Bayesian statistics, variational physics, and deep learning converged on the same mathematical trick. That trick is the evidence lower bound (ELBO). Instead of computing the intractable marginal likelihood directly, introduce an auxiliary distribution over the latent variables. Then optimize a tractable lower bound on log⁡p(x)\log p(x). The gap between the bound and the truth is exactly a KL divergence. So tightening the bound and inferring the latents become the same optimization. This single inequality — dressed up in different notation — underlies variational inference in statistics, mean-field methods in physics, expectation-maximization in classical machine learning. Later, it also underlies the variational autoencoder in deep learning. This article derives the ELBO from first principles. It shows the algorithmic recipe for optimizing it. It proves the bound is correct and explains when it is tight. It also traces a worked numerical example, so the abstract inequality becomes concrete arithmetic. It closes with the historical lineage of the idea. Finally, it previews how deep networks turn this classical bound into a trainable, backpropagatable objective.

Key takeaways
  • Latent variable models posit hidden causes zz behind observed data xx, via a joint p(x,z)=p(z) p(x∣z)p(x,z) = p(z)\,p(x\mid z).
  • The marginal likelihood p(x)=∫p(x,z) dzp(x) = \int p(x,z)\,dz is generally intractable — no closed form, no efficient exact computation.
  • Variational inference sidesteps this by introducing a tractable approximate posterior q(z∣x)q(z\mid x) over latents.
  • The ELBO is a lower bound on log⁡p(x)\log p(x); maximizing it simultaneously fits the model and infers the latents.
  • The gap between log⁡p(x)\log p(x) and the ELBO equals DKL(q(z∣x) ∥ p(z∣x))D_{KL}(q(z\mid x)\,\|\,p(z\mid x)) — the bound is tight iff qq equals the true posterior.
  • This exact bound, generalized with neural networks for qq and pp, becomes the training objective for Variational Autoencoders.
The core insight

Because the true posterior over latent causes is intractable, we optimize a computable lower bound on the data likelihood whose slack is exactly the approximation error in our guess of that posterior.

The idea

A latent variable model describes data through a joint distribution pθ(x,z)=p(z) pθ(x∣z)p_\theta(x, z) = p(z)\, p_\theta(x \mid z), where xx is observed, zz is an unobserved (latent) variable, p(z)p(z) is a prior over latents, and pθ(x∣z)p_\theta(x\mid z) is the generative or "decoder" distribution parameterized by θ\theta. The model explains data by imagining that nature first draws a hidden cause zz, then generates the visible xx conditioned on it. Fitting the model means choosing θ\theta to make observed data likely under this story, i.e., maximizing the marginal likelihood (also called the evidence):

pθ(x)=∫p(z) pθ(x∣z) dz.p_\theta(x) = \int p(z)\, p_\theta(x \mid z)\, dz.

For discrete zz this is a sum instead of an integral, but the difficulty is the same: the integral marginalizes out every possible explanation zz for the data, weighted by how plausible that explanation is. When pθ(x∣z)p_\theta(x \mid z) is a simple conjugate distribution (e.g., linear-Gaussian), this integral can sometimes be solved in closed form. But when pθ(x∣z)p_\theta(x \mid z) is parameterized by a neural network, the integral has no analytic solution, and its dimension (over all possible zz) makes numerical quadrature or naive Monte Carlo hopelessly slow — this is precisely the intractable marginal likelihood problem. A related, equally intractable object is the posterior over latents given data, pθ(z∣x)=pθ(x,z)/pθ(x)p_\theta(z \mid x) = p_\theta(x, z) / p_\theta(x), which tells you which hidden causes plausibly generated a specific observation. Since it is defined using pθ(x)p_\theta(x), if the evidence is intractable, so is the exact posterior. Variational inference solves both problems at once: introduce a tractable family of distributions qϕ(z∣x)q_\phi(z \mid x), indexed by parameters ϕ\phi, meant to approximate the true posterior. Then derive a bound on log⁡pθ(x)\log p_\theta(x) that only requires expectations under qϕq_\phi, never under the true posterior. That bound is the Evidence Lower BOund, or ELBO.

Deriving the ELBO. Start from the log marginal likelihood and introduce qϕ(z∣x)q_\phi(z\mid x) by multiplying and dividing inside the integral:

log⁡pθ(x)=log⁡∫pθ(x,z) dz=log⁡∫qϕ(z∣x) pθ(x,z)qϕ(z∣x) dz=log⁡ Eqϕ(z∣x) ⁣[pθ(x,z)qϕ(z∣x)].\log p_\theta(x) = \log \int p_\theta(x, z)\, dz = \log \int q_\phi(z\mid x) \, \frac{p_\theta(x,z)}{q_\phi(z\mid x)}\, dz = \log \, \mathbb{E}_{q_\phi(z\mid x)}\!\left[\frac{p_\theta(x, z)}{q_\phi(z \mid x)}\right].

Because log⁡\log is concave, Jensen's inequality lets us move the log inside the expectation, only decreasing the value:

log⁡pθ(x)  ≥  Eqϕ(z∣x) ⁣[log⁡pθ(x,z)qϕ(z∣x)]  =:  L(θ,ϕ;x).\log p_\theta(x) \;\ge\; \mathbb{E}_{q_\phi(z\mid x)}\!\left[\log \frac{p_\theta(x, z)}{q_\phi(z \mid x)}\right] \;=:\; \mathcal{L}(\theta, \phi; x).

This quantity L(θ,ϕ;x)\mathcal{L}(\theta,\phi;x) is the ELBO. It is fully tractable whenever we can sample from qϕ(z∣x)q_\phi(z\mid x), evaluate its density, and evaluate p(z)p(z) and pθ(x∣z)p_\theta(x\mid z) — all mild requirements satisfied by simple parametric families like Gaussians. Two equivalent rewritings expose its meaning:

L(θ,ϕ;x)=Eqϕ(z∣x)[log⁡pθ(x∣z)]⏟reconstruction term  −  DKL ⁣(qϕ(z∣x) ∥ p(z))⏟regularization term,\mathcal{L}(\theta,\phi;x) = \underbrace{\mathbb{E}_{q_\phi(z\mid x)}[\log p_\theta(x\mid z)]}_{\text{reconstruction term}} \;-\; \underbrace{D_{KL}\!\big(q_\phi(z\mid x)\,\|\,p(z)\big)}_{\text{regularization term}},

which balances explaining xx well against staying close to the prior, and

log⁡pθ(x)=L(θ,ϕ;x)+DKL ⁣(qϕ(z∣x) ∥ pθ(z∣x)),\log p_\theta(x) = \mathcal{L}(\theta,\phi;x) + D_{KL}\!\big(q_\phi(z\mid x)\,\|\,p_\theta(z\mid x)\big),

which reveals the exact gap between the true evidence and the bound: it is the KL divergence from our approximate posterior to the true posterior. Since KL divergence is always non-negative, this immediately re-derives the inequality and, more importantly, tells us how to close the gap: choose ϕ\phi to make qϕ(z∣x)q_\phi(z\mid x) as close as possible to pθ(z∣x)p_\theta(z\mid x).

How it works

The practical recipe alternates — or jointly performs via gradient ascent — two goals: improve the generative model θ\theta and improve the approximate posterior ϕ\phi, both by maximizing the same scalar objective, the ELBO, summed (or averaged) over the dataset.

Step-by-step mechanism: 1. Choose a prior p(z)p(z), typically simple (e.g., standard normal N(0,I)\mathcal{N}(0, I)), fixed or learned. 2. Choose a generative (decoder) family pθ(x∣z)p_\theta(x\mid z), e.g., a neural network mapping zz to the parameters of a distribution over xx (Gaussian mean/variance for continuous xx, Bernoulli logits for binary xx). 3. Choose a variational (encoder) family qϕ(z∣x)q_\phi(z\mid x), e.g., a neural network mapping xx to the mean and variance of a diagonal Gaussian over zz. 4. For each data point (or minibatch), estimate the ELBO:

  • Sample z∼qϕ(z∣x)z \sim q_\phi(z\mid x) (or use a closed-form expectation when possible).
  • Compute log⁡pθ(x∣z)\log p_\theta(x\mid z) — the reconstruction log-likelihood.
  • Compute DKL(qϕ(z∣x) ∥ p(z))D_{KL}(q_\phi(z\mid x)\,\|\,p(z)) — closed-form when both are Gaussian.
  • Combine: L^=log⁡pθ(x∣z)−DKL(qϕ(z∣x) ∥ p(z))\hat{\mathcal{L}} = \log p_\theta(x\mid z) - D_{KL}(q_\phi(z\mid x)\,\|\,p(z)).

5. Ascend the gradient of L^\hat{\mathcal{L}} with respect to both θ\theta and ϕ\phi (this requires differentiating through the sampling step — the reparameterization trick, foreshadowing the Variational Autoencoder). 6. Repeat over the dataset until convergence; at convergence, θ\theta defines a good generative model and qϕ(z∣x)q_\phi(z\mid x) approximates the true posterior for any xx. This is the modern, amortized, gradient-based version. A classical, non-amortized ancestor is Expectation-Maximization (EM), which alternates fully solving for qq (the E-step, setting q=pθ(z∣x)q = p_\theta(z\mid x) exactly when tractable) and then maximizing over θ\theta (the M-step) — both steps are coordinate ascent on the exact same ELBO objective. ``` ALGORITHM: ELBO-based training of a latent variable model (variational EM, amortized) Input: dataset D = {x_1, ..., x_N} prior p(z) decoder p_theta(x | z) # neural network, params theta encoder q_phi(z | x) # neural network, params phi learning rate eta, number of steps T Initialize theta, phi randomly for step = 1 to T: sample minibatch B = {x_1, ..., x_m} from D grad_theta = 0 grad_phi = 0 for each x in B:

# --- variational step: get an approximate posterior sample --- (mu, sigma) = encoder_forward(phi, x) # e.g. Gaussian params epsilon ~ N(0, I) # reparameterization noise z = mu + sigma * epsilon # differentiable sample

# --- evaluate the ELBO for this point --- recon_ll = log p_theta(x | z) # decoder log-likelihood kl_term = KL( N(mu, sigma^2) || p(z) ) # closed form if p(z)=N(0,I) elbo_x = recon_ll - kl_term

# --- backpropagate through both terms --- grad_theta += d(elbo_x) / d(theta) grad_phi += d(elbo_x) / d(phi) # flows through z via reparameterization theta = theta + eta grad_theta / m # gradient ASCENT on ELBO phi = phi + eta grad_phi / m return theta, phi ``` The key subtlety in this pseudocode is that zz is drawn via z=μ+σ⊙ϵz = \mu + \sigma \odot \epsilon with ϵ∼N(0,I)\epsilon \sim \mathcal{N}(0,I) fixed as external randomness, rather than sampled directly as z∼N(μ,σ2)z \sim \mathcal{N}(\mu, \sigma^2). This reparameterization makes zz a deterministic, differentiable function of ϕ\phi and noise, so gradients can flow from the ELBO back into the encoder — without it, `grad_phi` could not be computed by ordinary backpropagation, only by higher-variance estimators like REINFORCE.

Figure
The ELBO as a bound: evidence, bound, and the KL gap
log p(x) log p_θ(x) (true evidence) ELBO ℒ(θ,φ;x) gap = D_KL(q(z|x) ‖ p(z|x)) ℒ(θ,φ;x) decomposes as: 𝔼_q[log p_θ(x|z)] − D_KL(q‖p(z)) reconstruction term regularization to prior Tightening the bound (raising the green bar toward the blue bar) ⇔ making q(z|x) match the true posterior p(z|x).

Complexity & correctness

Correctness — why the inequality holds and what "tight" means. The derivation used only two facts: the algebraic identity pθ(x,z)=qϕ(z∣x)⋅pθ(x,z)qϕ(z∣x)p_\theta(x,z) = q_\phi(z\mid x)\cdot \frac{p_\theta(x,z)}{q_\phi(z\mid x)} (valid wherever qϕ(z∣x)>0q_\phi(z\mid x) > 0), and Jensen's inequality for the concave function log⁡\log, which states log⁡E[Y]≥E[log⁡Y]\log \mathbb{E}[Y] \ge \mathbb{E}[\log Y] for any positive random variable YY, with equality iff YY is almost surely constant. Applying this with Y=pθ(x,z)/qϕ(z∣x)Y = p_\theta(x,z)/q_\phi(z\mid x) gives the ELBO inequality, and equality holds exactly when pθ(x,z)/qϕ(z∣x)p_\theta(x,z)/q_\phi(z\mid x) is constant in zz — which happens precisely when qϕ(z∣x)∝pθ(x,z)q_\phi(z\mid x) \propto p_\theta(x,z), i.e. when qϕ(z∣x)=pθ(z∣x)q_\phi(z\mid x) = p_\theta(z\mid x) (the true posterior). This matches the second derivation exactly: the gap is DKL(qϕ(z∣x) ∥ pθ(z∣x))≥0D_{KL}(q_\phi(z\mid x)\,\|\,p_\theta(z\mid x)) \ge 0, with equality iff the two distributions are identical (KL divergence is zero iff its two arguments coincide almost everywhere). So the ELBO is not an ad hoc approximation — it is provably a lower bound for any valid probability distribution qϕq_\phi, and the slack is a well-understood, non-negative quantity that vanishes exactly when inference is perfect. This also explains why maximizing the ELBO over ϕ\phi alone (holding θ\theta fixed) performs correct approximate inference: since log⁡pθ(x)\log p_\theta(x) does not depend on ϕ\phi, increasing L(θ,ϕ;x)\mathcal{L}(\theta,\phi;x) can only be achieved by decreasing the KL gap. And maximizing over θ\theta pushes up a valid lower bound on the true log-likelihood, so (unlike, say, maximizing a heuristic surrogate) improving the ELBO is guaranteed to improve a certified floor on how well the model explains the data.

Complexity. Let dd be the dimensionality of zz, and suppose the encoder and decoder are neural networks with O(P)O(P) parameters and O(F)O(F) floating-point operations per forward pass.

  • Exact marginal likelihood (baseline, for contrast): computing pθ(x)=∫p(z)pθ(x∣z) dzp_\theta(x) = \int p(z) p_\theta(x\mid z)\,dz exactly by numerical integration over a grid costs O(kd)O(k^d) for kk grid points per dimension — exponential in dd, intractable for dd beyond a handful of dimensions. This is the problem the ELBO exists to avoid.
  • ELBO estimation (Monte Carlo, one sample): O(F)O(F) — one encoder forward pass to get qϕ(z∣x)q_\phi(z\mid x)'s parameters, one sample of zz (cost O(d)O(d), negligible next to FF), one decoder forward pass to get log⁡pθ(x∣z)\log p_\theta(x\mid z), and, when qq and the prior are both Gaussian, a closed-form KL term costing only O(d)O(d) arithmetic operations (no sampling needed for that piece). Crucially this cost does not grow with dd exponentially — it is linear in network size, independent of how the exponential-integral difficulty would have scaled.
  • Gradient computation: backpropagation through encoder and decoder costs the same order as the forward pass, O(F)O(F), by the standard reverse-mode differentiation argument (each op is differentiated once).
  • Per training step overall: O(mF)O(m F) for a minibatch of size mm; memory: O(P+mFact)O(P + mF_{\text{act}}) for parameters plus stored activations for backpropagation, exactly as in standard supervised deep learning.
  • Variance of the estimate: because zz is stochastic, the ELBO estimate from a single sample is a Monte Carlo estimator with some variance; more samples of zz reduce variance at cost O(kF)O(kF) for kk samples, trading compute for lower-variance gradients — a tunable, not a fundamental, tradeoff.

Honest tradeoffs. The ELBO purchases tractability at the price of an approximation gap that is rarely known exactly in practice (we cannot compute the true posterior to check how tight our bound is). A poorly chosen qϕq_\phi family — e.g., a diagonal Gaussian approximating a true posterior that is highly multimodal or correlated — can leave a large, uncorrectable gap no matter how well ϕ\phi is optimized within that family; this is a model-mismatch limitation, not an optimization failure. Richer variational families (normalizing flows, hierarchical qq) shrink the gap but increase computational cost per step.

Worked example

Consider a toy one-dimensional latent variable model so every term can be computed by hand. Let the prior be standard normal, p(z)=N(0,1)p(z) = \mathcal{N}(0, 1). Let the decoder be a fixed linear-Gaussian model, p(x∣z)=N(x; 2z, 1)p(x \mid z) = \mathcal{N}(x; \,2z,\, 1) (mean 2z2z, variance 11) — chosen simple so we can also compute the true posterior for comparison, to see the ELBO gap concretely. Suppose we observe x=3x = 3.

Step 1 — the true posterior (ground truth, for checking). Since prior and likelihood are conjugate Gaussians, p(z∣x)∝p(z) p(x∣z)∝exp⁡ ⁣(−z22)exp⁡ ⁣(−(x−2z)22)p(z\mid x) \propto p(z)\,p(x\mid z) \propto \exp\!\left(-\tfrac{z^2}{2}\right)\exp\!\left(-\tfrac{(x-2z)^2}{2}\right). Completing the square in zz gives a Gaussian posterior with

precision=1+4=5,mean=2x5=65=1.2,variance=15=0.2.\text{precision} = 1 + 4 = 5, \quad \text{mean} = \frac{2x}{5} = \frac{6}{5} = 1.2, \quad \text{variance} = \frac{1}{5} = 0.2.

So the true posterior is p(z∣x=3)=N(1.2, 0.2)p(z\mid x=3) = \mathcal{N}(1.2,\ 0.2). (In a real deep model we would not have this in closed form — this is exactly why we need qϕq_\phi.)

Step 2 — suppose our variational family is Gaussian qϕ(z∣x)=N(μ,σ2)q_\phi(z\mid x) = \mathcal{N}(\mu, \sigma^2) and, before training, the encoder outputs a poor guess μ=0.5, σ2=1\mu = 0.5,\ \sigma^2 = 1 (close to the prior, badly off the true posterior).

Step 3 — compute the ELBO terms with this bad guess. Draw z∼N(0.5,1)z \sim \mathcal{N}(0.5, 1); take the mean-value estimate z=0.5z = 0.5 for illustration (in practice we'd sample and/or use closed forms where possible).

  • Reconstruction term: log⁡p(x∣z)=log⁡N(3; 2(0.5), 1)=log⁡N(3;1,1)\log p(x\mid z) = \log \mathcal{N}(3;\, 2(0.5),\, 1) = \log \mathcal{N}(3; 1, 1).
log⁡N(3;1,1)=−12log⁡(2π)−(3−1)22=−0.919−2=−2.919.\log \mathcal{N}(3;1,1) = -\tfrac12\log(2\pi) - \tfrac{(3-1)^2}{2} = -0.919 - 2 = -2.919.
  • KL term (closed form for two Gaussians N(μ,σ2)\mathcal{N}(\mu,\sigma^2) vs N(0,1)\mathcal{N}(0,1)):
DKL=12(σ2+μ2−1−log⁡σ2)=12(1+0.25−1−0)=0.125.D_{KL} = \tfrac12\left(\sigma^2 + \mu^2 - 1 - \log \sigma^2\right) = \tfrac12\left(1 + 0.25 - 1 - 0\right) = 0.125.
  • ELBO estimate: L≈−2.919−0.125=−3.044\mathcal{L} \approx -2.919 - 0.125 = -3.044.

Step 4 — repeat with a better guess, μ=1.2, σ2=0.2\mu = 1.2,\ \sigma^2 = 0.2 (matching the true posterior exactly), using z=1.2z = 1.2:

  • Reconstruction term: log⁡N(3;2(1.2),1)=log⁡N(3;2.4,1)=−0.919−(0.6)22=−0.919−0.18=−1.099\log \mathcal{N}(3; 2(1.2), 1) = \log \mathcal{N}(3; 2.4, 1) = -0.919 - \tfrac{(0.6)^2}{2} = -0.919 - 0.18 = -1.099.
  • KL term: 12(0.2+1.44−1−log⁡0.2)=12(0.2+1.44−1+1.609)=12(2.249)=1.125\tfrac12(0.2 + 1.44 - 1 - \log 0.2) = \tfrac12(0.2+1.44-1+1.609) = \tfrac12(2.249) = 1.125.
  • ELBO estimate: L≈−1.099−1.125=−2.224\mathcal{L} \approx -1.099 - 1.125 = -2.224.

Step 5 — check against the true log-evidence. For this linear-Gaussian model, p(x)=N(x;0, 4⋅1+1)=N(3;0,5)p(x) = \mathcal{N}(x; 0, \,4\cdot 1 + 1) = \mathcal{N}(3; 0, 5) (since x=2z+noisex = 2z + \text{noise}, z∼N(0,1)z\sim\mathcal N(0,1) gives Var(x)=4+1=5\text{Var}(x)=4+1=5):

log⁡p(x=3)=−12log⁡(2π⋅5)−92⋅5=−2.418−0.9=−3.318.\log p(x=3) = -\tfrac12\log(2\pi \cdot 5) - \frac{9}{2\cdot 5} = -2.418 - 0.9 = -3.318.
QuantityBad qq (μ=0.5,σ2=1\mu{=}0.5,\sigma^2{=}1)Good qq (μ=1.2,σ2=0.2\mu{=}1.2,\sigma^2{=}0.2)True log⁡p(x)\log p(x)
ELBO estimate−3.044-3.044−2.224-2.224—
True log-evidence−3.318-3.318−3.318-3.318−3.318-3.318
Bound valid? (L≤log⁡p(x)\mathcal L \le \log p(x))violated by point-estimate approximation (expected: MC sampling / Jensen bias)holds—

(Note: because we used single point evaluations at the mean instead of a proper Monte Carlo expectation, the "bad qq" row's ELBO estimate of −3.044-3.044 exceeding −3.318-3.318 reflects estimator noise/bias from skipping the expectation, not a violation of the theorem — with true expectations taken analytically, both values are guaranteed ≤−3.318\le -3.318, and the good-qq case, using the exact posterior, gives L=log⁡p(x)\mathcal L = \log p(x) exactly, since the KL gap is exactly zero there.) This subtlety itself is instructive: it shows why in practice we must be careful about Monte Carlo variance when reporting or comparing ELBO values, and why using the exact posterior as qq collapses the bound to equality — exactly as the correctness argument predicted.

Common pitfalls & traps

PitfallWhy it happensConsequence
Forgetting the KL term is a divergence to the prior, not to the true posteriorConfusing the two KLs in the two ELBO decompositionsMisinterpreting what regularizes the latent space during training
Treating the ELBO gap as always smallAssuming a simple qq family is "good enough"Silent underestimation of log⁡p(x)\log p(x); latent codes may not reflect the true posterior geometry
Sampling zz without reparameterization when gradients w.r.t. ϕ\phi are neededSampling breaks the differentiable computation graphGradients for the encoder cannot be computed by standard backpropagation
Using only one Monte Carlo sample and reporting the ELBO as if exactHigh variance from single-sample estimates, especially early in trainingNoisy or misleading likelihood comparisons across models
Comparing ELBO values across models with different qϕq_\phi families as if comparing log⁡p(x)\log p(x) directlyELBO ≠log⁡p(x)\ne \log p(x) in general; gap sizes differ across modelsA model with a worse fit but a better/richer qq can appear to "win" spuriously

Pioneers & history

The mathematics of bounding an intractable integral via a variational distribution has roots in statistical physics — mean-field approximations for the free energy of interacting systems — and was imported into statistics and machine learning through the lens of variational inference and the closely related Expectation-Maximization algorithm.

Origins · 1 minRichard S. Sutton and how this was discovered
RS
Richard S. Sutton
N/A · not applicable — see below

GE
Geoffrey E. Hinton
born 1947 · Co-developed the Helmholtz machine and the wake-sleep algorithm in the early 1990s, an early neural-network precursor to amortized variational inference, and later helped bring variational, energy-based, and deep generative ideas into mainstream deep learning.

History
1970
— Arthur Dempster, Nan Laird, and Donald Rubin formalize the Expectation-Maximization algorithm, an alternating coordinate-ascent scheme on what is, in modern language, the ELBO.
1990
— Peter Dayan, Geoffrey Hinton, Radford Neal, and Richard Zemel introduce the Helmholtz machine and the wake-sleep algorithm, using an explicit recognition (encoder) network to approximate posteriors.
1999
— Michael Jordan, Zoubin Ghahramani, Tommi Jaakkola, and Lawrence Saul publish a unifying tutorial on variational methods for graphical models, cementing "variational inference" and the ELBO as standard machine-learning tools.
2013
— Diederik Kingma and Max Welling introduce the reparameterization trick and the Variational Autoencoder, coupling the ELBO with backpropagation through neural encoder/decoder networks.
2014
— Danilo Rezende, Shakir Mohamed, and Daan Wierstra independently derive stochastic backpropagation for deep generative models, reinforcing the same reparameterized-ELBO framework.

Where this matters

The ELBO is the training objective behind Variational Autoencoders, which power generative image models, molecular design pipelines, anomaly detection systems, and representation-learning backbones across industry. It underlies topic models like Latent Dirichlet Allocation, where variational inference (an ELBO maximization) is the standard scalable fitting algorithm for millions of documents. In Bayesian deep learning, ELBO-style objectives approximate posteriors over network weights for uncertainty quantification in medical imaging and autonomous systems. Probabilistic programming languages (Pyro, Stan's variational mode, TensorFlow Probability) implement generic ELBO optimizers so practitioners can plug in custom generative models without deriving inference by hand. The same bound, generalized to sequences of latents, appears in state-space models for time series and in diffusion-adjacent hierarchical latent variable models, making the ELBO one of the most reused mathematical objects connecting classical statistics to modern deep generative modeling, alongside foundational tools like KL Divergence and Bayes' Rule.

Ask the tutor: How does the reparameterization trick concretely enable gradient-based optimization of the ELBO in a Variational Autoencoder?

Is the ELBO just an approximation, or is it a mathematically guaranteed bound?

It is a guaranteed bound, not a heuristic approximation. The derivation uses only an algebraic identity (multiplying and dividing by qϕ(z∣x)q_\phi(z\mid x)) and Jensen's inequality applied to the concave logarithm function, both of which hold for any valid probability distributions involved — no assumptions about the model family are needed. This means for any choice of qϕq_\phi, L(θ,ϕ;x)≤log⁡pθ(x)\mathcal{L}(\theta,\phi;x) \le \log p_\theta(x) is provably true; what varies is only how tight the bound is, governed by the KL divergence between qϕ(z∣x)q_\phi(z\mid x) and the true posterior. So while the value of the ELBO underestimates the true likelihood, the inequality itself is exact mathematics, not an approximation.

Why not just compute the true posterior p(z|x) exactly instead of approximating it with q(z|x)?

Computing p(z∣x)=p(x,z)/p(x)p(z\mid x) = p(x,z)/p(x) exactly requires knowing p(x)p(x), the very intractable integral that motivated variational inference in the first place — so exact posterior computation and exact marginal likelihood computation are two faces of the same intractability. In special cases (conjugate exponential-family models like linear-Gaussian systems) the posterior is available in closed form, and there variational inference is unnecessary. But once the generative model pθ(x∣z)p_\theta(x\mid z) is a nonlinear neural network, no conjugacy holds, the posterior can be arbitrarily complex (multimodal, correlated), and no closed form exists — forcing an approximation strategy like variational inference or Monte Carlo sampling methods.

How is the ELBO related to Expectation-Maximization (EM)?

EM is a special case of ELBO maximization where, in the E-step, qq is set to the exact true posterior pθ(z∣x)p_\theta(z\mid x) whenever that is tractable (making the KL gap exactly zero and the bound tight), and in the M-step, θ\theta is updated to maximize the resulting tight ELBO. Modern amortized variational inference generalizes this by restricting qϕ(z∣x)q_\phi(z\mid x) to a parametric family (e.g., Gaussian encoders) when the true posterior is intractable, accepting a nonzero KL gap in exchange for tractability. Both methods are coordinate ascent on the exact same objective function — the ELBO — differing only in whether the E-step can be solved exactly or must itself be approximated.

Why does the ELBO decompose into a reconstruction term and a KL-to-prior term, and what does each mean intuitively?

Algebraically, log⁡pθ(x,z)qϕ(z∣x)=log⁡pθ(x∣z)+log⁡p(z)qϕ(z∣x)\log \frac{p_\theta(x,z)}{q_\phi(z\mid x)} = \log p_\theta(x\mid z) + \log\frac{p(z)}{q_\phi(z\mid x)}, and taking the expectation under qϕ(z∣x)q_\phi(z\mid x) turns the second term into −DKL(qϕ(z∣x) ∥ p(z))-D_{KL}(q_\phi(z\mid x)\,\|\,p(z)). Intuitively, the reconstruction term rewards latent samples zz that let the decoder assign high probability to the actual observed xx — it wants the model to explain the data well. The KL term penalizes the encoder for drifting far from the prior, acting as a regularizer that keeps the latent space well-structured and prevents the model from encoding xx as an arbitrarily specific, non-generalizing code. Training balances these two competing pressures.

Does a higher ELBO always mean a better generative model?

Not necessarily, and this is a subtle but important caveat. The ELBO is a lower bound on log⁡pθ(x)\log p_\theta(x), and the gap depends on how well qϕq_\phi approximates the true posterior for that particular θ\theta. Two models with identical true log-likelihoods can have different ELBOs if their posteriors are easier or harder for the chosen qϕq_\phi family to approximate — a model whose true posterior happens to be close to Gaussian will show a smaller gap than one with a highly multimodal posterior, even if the second model fits the data equally well. So the ELBO should be interpreted as a joint measure of model fit and inference quality, and comparisons across differently-structured qϕq_\phi families should be made cautiously.

What role does the choice of variational family for q(z|x) play in practice?

The family of qϕ(z∣x)q_\phi(z\mid x) determines how tight the ELBO can possibly become, independent of how well ϕ\phi is optimized. A simple family, such as a diagonal (mean-field) Gaussian, is cheap to sample from and yields closed-form KL terms against a Gaussian prior, but cannot represent correlations or multimodality in the true posterior, capping how small the KL gap can get. Richer families — full-covariance Gaussians, mixtures, or normalizing flows applied to a base distribution — can shrink the gap further at increased computational and implementation cost. Choosing this family is therefore a direct tradeoff between tractability/speed and the tightness of the bound, and is one of the main design decisions inherited by later architectures such as the Variational Autoencoder.

How does this connect to Variational Autoencoders specifically?

A Variational Autoencoder instantiates exactly this framework with neural networks: an encoder network parameterizes qϕ(z∣x)q_\phi(z\mid x) (typically outputting a Gaussian mean and variance), and a decoder network parameterizes pθ(x∣z)p_\theta(x\mid z). Training maximizes the ELBO via stochastic gradient ascent, using the reparameterization trick to backpropagate through the sampled latent zz. Every piece of the ELBO derivation — the Jensen's-inequality bound, the reconstruction-plus-KL decomposition, the interpretation of the gap as approximate-posterior error — carries over unchanged; the VAE's novelty is making both pθp_\theta and qϕq_\phi flexible neural networks trained jointly and efficiently at scale, which is the natural next step after understanding the ELBO itself.

Before this

Where this leads