4.5.5 · D5Generative Models

Question bank — ELBO objective and KL term

2,295 words10 min readBack to topic

This page hunts the misconceptions around the ELBO objective and KL term. Every reveal below is a trap that a quick reader falls into. Try to answer before peeking — if your reasoning matches the "why", you actually understand the bound.

Before we start, here are the symbols we will lean on. Everything is defined here so this page stands on its own — no need to jump to the parent first.

The picture below shows this split as heights on a bar — reconstruction pushes the bound up, KL pulls it down, and the two together can never rise above the true ceiling .

Figure — ELBO objective and KL term

The one equation that resolves half the traps: Read it as: true log-likelihood = the bound + the gap, and the gap is a KL divergence, so it can never be negative.

Figure — ELBO objective and KL term

Finally, a question that trips up nearly everyone: why do we always write the KL as (encoder first) and never ? The next figure makes the difference geometric.

Figure — ELBO objective and KL term

True or false — justify

The ELBO is always less than or equal to the true log-likelihood.
True. The gap term is a KL divergence, which is , so for every .
Maximizing the ELBO can never increase the true log-likelihood .
False. The ELBO depends on both and ; changing moves the whole generative model, so climbing genuinely raises — it is not just closing a fixed gap.
If the KL regularization term is zero, the encoder has failed.
False in general — it depends on which KL. If the encoder outputs the prior regardless of , which is posterior collapse and is a failure. But if the gap KL , the encoder is perfect and the ELBO is tight — a triumph.
A larger ELBO always means better sample quality from the generator.
False. ELBO bundles reconstruction and KL; a model can score high ELBO while placing probability mass poorly for sampling, and Monte-Carlo ELBO estimates are also noisy — see Posterior Collapse for a case where ELBO looks fine but samples are useless.
KL divergence is a distance, so .
False. KL is not symmetric and violates the triangle inequality, so it is not a metric. Swapping the arguments generally changes the value; VAEs deliberately use the reverse form .
The reconstruction term can be positive.
True for continuous . A Gaussian density can exceed 1, so its log can be positive; only probabilities (discrete case) are capped at 1 and give non-positive logs.
Jensen's inequality is what guarantees the ELBO is a lower bound rather than upper.
True. Because is concave, , so pulling the log inside the expectation can only lose value — the result sits below .
If equals the true posterior , the ELBO equals the log-likelihood exactly.
True. Then the gap KL is zero, so — the bound is tight and Monte-Carlo estimation of becomes exact in expectation.

Spot the error

" is intractable, so we just replace the integral with for one sampled ."
Error: one sample of is not an unbiased estimate of the integral over the prior — most prior samples make nearly impossible, so this estimate is astronomically high-variance. The ELBO fixes this by sampling from , which concentrates on the codes that actually explain .
"Because , dropping the KL term from the ELBO gives a tighter lower bound."
Error: removing the KL term does not tighten anything — it changes the objective entirely into just reconstruction, which is not a lower bound on and encourages posterior collapse in reverse (each mapped to an arbitrary ).
"We use inside the training loss and minimize it directly."
Error: we cannot compute (that was the whole problem), so we never touch the gap KL directly. The training loss uses against the prior, and minimizing the gap happens implicitly by maximizing .
"Jensen gives , so ."
Error: the inequality direction is stated for convex . Since is concave, the inequality flips: . Getting the direction wrong would make the "bound" an upper bound and break the whole derivation.
" can be negative if the are tiny."
Error: the formula is provably . As , dominates and drives KL up, not negative; the is just the constant that makes KL exactly at .
"The expectation is taken over the prior ."
Error: it is taken over the encoder , not the prior. This is the point of variational inference — we sample the codes that says are relevant to this specific , which is why the estimate is low-variance.

Why questions

Why do we pick the reverse KL instead of forward ?
Because the expectation is over , which is exactly the distribution we can sample from and control; forward KL would need samples from the intractable true posterior. This choice makes zero-forcing — it avoids putting mass where has none, at the cost of possibly ignoring some modes.
Why is the term called the Evidence Lower Bound and not just "the bound"?
In Bayesian language is the evidence for the model, and is a guaranteed lower bound on its logarithm — the name literally spells out "lower bound on the (log) evidence".
Why does the KL term prevent latent codes from drifting arbitrarily far apart?
It penalizes any encoder distribution that strays from the prior , pulling every toward a common, overlapping region. This keeps the latent space continuous so that decoding a fresh produces sensible outputs — the sampling guarantee.
Why can we not just maximize directly if we have the decoder network?
Because integrates the decoder over all latent codes, an integral with no closed form and exponential cost in the latent dimension. The ELBO sidesteps this by replacing the integral with a tractable expectation under .
Why does the closed-form Gaussian KL make VAE training so much faster?
The KL term needs no Monte-Carlo sampling — it is an exact algebraic function of the encoder's and , so only the reconstruction term is estimated by sampling, cutting both cost and variance.
Why does raising a "" weight on the KL term (as in -VAE) risk posterior collapse?
Over-weighting KL makes the cheapest way to lower the loss be for all , ignoring entirely; the encoder stops carrying information — the collapse discussed in Posterior Collapse.

Edge cases

What is the ELBO if the encoder is deterministic, i.e. for all ?
The KL term blows up to , so KL and the ELBO — the objective explicitly forbids a zero-variance encoder, which is why VAEs keep stochastic latents.
What happens to reconstruction and KL when exactly for every ?
KL (perfect regularization) but the code carries no information about , so reconstruction collapses to the best a blind decoder can do — this is textbook posterior collapse: great KL, useless model.
Is the ELBO still a valid lower bound if is a terrible approximation to the posterior?
Yes. holds for any valid distribution ; a poor just makes the gap KL large and the bound loose, but never invalid.
What does the ELBO gap look like at the very start of training with a randomly initialized encoder?
The gap is typically huge, so sits far below — training then simultaneously raises the ceiling () and shrinks the gap ().
If a data point is genuinely impossible under the model (), what happens to and the ELBO?
, and since the ELBO is dragged down with it — the bound faithfully reports "this point is unexplainable".
Can the gap KL and the regularization KL ever both be zero at once?
Only in the degenerate case where the true posterior equals the prior for that (i.e. tells you nothing about ). Then , giving a tight bound but a latent code that ignores the data.
Does tightening the bound with more samples (importance weighting) change what "ELBO" means?
Yes — Importance Weighted Autoencoders use a multi-sample bound that is tighter (closer to ) than the single-sample ELBO, though it is no longer decomposable into a clean reconstruction-minus-KL form.
Recall Self-check

Why is the gap between ELBO and log-likelihood never negative? ::: It equals , and every KL divergence is . Which distribution's samples power the reconstruction expectation? ::: The encoder , not the prior .