4.5.5 · D1Generative Models

Foundations — ELBO objective and KL term

2,092 words10 min readBack to topic

Before you can read a single line of the ELBO derivation, you need the alphabet it is written in. This page builds every symbol from nothing. Read it top to bottom: each idea is a brick for the next.


0. The cast of characters (what all the letters mean)

The parent note throws a lot of letters at you — , , , , , , , . None of them are scary once you meet them one at a time.

Figure — ELBO objective and KL term

Look at the figure. The hidden cause sits on the left. An arrow labelled "generate" pushes it to the visible data on the right. This one arrow is the whole idea of a generative model: nature (or our model) picks a hidden , then produces the we observe. Our job is to run that arrow backwards — see , guess .


1. Probability — the "how likely" machine

Why the topic needs it: everything in generative modelling is a question of "how likely." We measure success by how much probability the model assigns to real data.

Three flavours of appear, and mixing them up is the #1 source of confusion:

Notation Read it as Picture
"how likely is this hidden cause, before seeing anything" the prior — a fixed bell curve
"if the hidden cause is , how likely is this data" the decoder — the generate arrow
"given I saw this data, how likely was each hidden cause" the posterior — the reverse arrow

The little bar means "given" — everything after the bar is assumed known.


2. The integral — "add up over all possibilities"

Figure — ELBO objective and KL term

In the figure, the shaded area under the curve is the integral. Each thin vertical strip is one possible value of ; its height is how much that value contributes; adding every strip gives the whole area.

Why the topic needs it: to find how likely the data is overall, we must consider every hidden cause that could have produced it and add up their contributions:

Read this in words: "the total likelihood of = for every hidden cause , (how likely that cause is) (how likely it makes ), summed over all ."


3. The logarithm — turning products into sums

Why the topic needs it: probabilities of many things multiply together and become vanishingly tiny (like ). Taking turns that fragile product into a stable sum, and because is increasing, maximizing is the same as maximizing . So we always work with , never raw .

Also, has a shape that matters enormously later:

Figure — ELBO objective and KL term

The curve bulges upward (it is concave — it holds water). Notice in the figure: the straight chord between two points on the curve always sits below the curve. That single geometric fact is what makes Jensen's inequality (Step 3 of the derivation) point the right way. Hold this picture.


4. Expectation — the average you'd expect

Why the topic needs it: we can't do the full integral, but we can draw a handful of samples and average. Expectation is the bridge between the impossible integral and a doable computation (this is Monte Carlo — estimating an average by sampling).


5. The approximate posterior — our stand-in for the impossible reverse arrow

The true reverse arrow needs the villain integral. So we build a replacement we can compute, and call it .

The letters (theta) and (phi) are just names for two sets of adjustable numbers:

  • = knobs of the decoder (, the generate arrow).
  • = knobs of the encoder (, the guess arrow).

6. KL divergence — the distance between two clouds of belief

Figure — ELBO objective and KL term

Read the figure: when the two bells sit on top of each other (left), , its is , and KL . When they drift apart (right), the ratio swings away from 1 wherever has mass, the grows, and KL climbs. KL is small when the clouds overlap, large when they separate.

Two facts you must trust (proven on KL Divergence):

  • always — you can never be "negatively different."
  • in general — the order matters. It is not an ordinary symmetric distance.

Why the topic needs it: the ELBO has a KL term that glues the encoder's guesses to the simple prior, and the gap between ELBO and the true log-likelihood is itself a KL. KL is the mortar of the whole building.


How it all feeds the topic

probability p

prior p of z

decoder p x given z

true posterior p z given x

integral over all z

evidence p of x is intractable

log turns products to sums and is concave

ELBO lower bound

expectation as sampled average

encoder q phi z given x

KL divergence

gap equals KL of q to true posterior

Every arrow entering ELBO is a symbol you now own. The impossible evidence at the top is exactly what the ELBO climbs toward from below.


Sanity check with one tiny number


Recall

Cloze yourself before moving on:

The letter that means hidden, unobserved cause
(latent variable)
The letter that means the data you can see
(observed)
is called the
prior — belief about hidden causes before seeing data
is called the
decoder / likelihood — how a cause generates data
is called the
(true) posterior — the reverse arrow, usually intractable
Why is impossible in practice
the integral runs over a huge-dimensional -space, more points than we can ever sum
Why do we take of probabilities
it turns tiny products into stable sums and is increasing, so maximizing maximizes
The shape of that makes Jensen work
concave (bulges up); chords lie below the curve
means
the average of when is drawn from
The subscript on denotes
the encoder's tunable neural-network weights
exactly when
and are the same distribution
Is symmetric
no, in general

Equipment checklist

Say each answer out loud; if any stalls, re-read that section before the derivation page.

I can explain the difference between and in one sentence
is observed data, is the hidden cause behind it
I can name all three: , ,
prior, decoder, posterior
I can say why is intractable
it needs an integral over all hidden causes in high dimensions
I know the two properties of we use
, and is increasing/concave
I can read aloud and say what the subscript does
"average of over drawn from "; the subscript fixes the sampling distribution
I know what and are
decoder weights and encoder weights
I can state what measures and its two key facts
mismatch between two distributions; always , and not symmetric
I can compute a 1-D Gaussian KL from the closed form

Prerequisite deep-dives if any box failed: KL Divergence, Variational Inference, VAE Architecture. Related once you're solid: Expectation Maximization, Information Bottleneck, Posterior Collapse, Normalizing Flows, Importance Weighted Autoencoders. Then return to the parent: ELBO objective and KL term.