
Generative Models · v1.0.2
2026-11-19 08:50:23

Encoder — fixed
Decoder — learned
With no encoder network there is no posterior to collapse. The decoder alone must tighten the bound.
\[ \begin{aligned} z_1 &= \sqrt{1-\beta_1}\cdot x + \sqrt{\beta_1}\cdot \epsilon_1 \\[2pt] z_t &= \underbrace{\sqrt{1-\beta_t}\cdot z_{t-1}}_{\text{attenuate}} + \underbrace{\sqrt{\beta_t}\cdot \epsilon_t}_{\text{add noise}}, \qquad t = 2, \dots, T \end{aligned} \]
with \(\epsilon_t \sim \text{Norm}[0, I]\). Equivalently,
\[q(z_t|z_{t-1}) = \text{Norm}_{z_t}\!\left[\sqrt{1-\beta_t}\,z_{t-1},\ \beta_t I\right]\]

Variance removed by the shrink equals variance added by the noise, so \(\text{Var}[z_t]\) stays at \(1\).


\(z_t\) depends only on \(z_{t-1}\), so the joint factorises:
\[q(z_{1\dots T}|x) = q(z_1|x)\prod_{t=2}^{T} q(z_t|z_{t-1})\]
Take \(z_2\) and replace \(z_1\) by its definition:
\[ \begin{aligned} z_2 &= \sqrt{1-\beta_2}\cdot \class{hg-key}{z_1} + \sqrt{\beta_2}\cdot\epsilon_2 \\[4pt] &= \sqrt{1-\beta_2}\left(\class{hg-key}{\sqrt{1-\beta_1}\cdot x + \sqrt{\beta_1}\cdot\epsilon_1}\right) + \sqrt{\beta_2}\cdot\epsilon_2 \\[4pt] &= \sqrt{1-\beta_2}\sqrt{1-\beta_1}\cdot x \ +\ \class{hg-alt}{\sqrt{(1-\beta_2)\beta_1}\cdot\epsilon_1 + \sqrt{\beta_2}\cdot\epsilon_2} \end{aligned} \]
One term in \(x\), and two independent noise terms.

Two independent mean-zero normals add to one, with the variances summing:
\[ \class{hg-alt}{(1-\beta_2)\beta_1 + \beta_2} = 1 - (1-\beta_1)(1-\beta_2) \]
\[ z_2 = \sqrt{(1-\beta_1)(1-\beta_2)}\cdot x + \sqrt{1 - (1-\beta_1)(1-\beta_2)}\cdot\class{hg-alt}{\epsilon} \]
Repeating the substitution through \(z_3, z_4, \dots\) gives
\[ z_t = \sqrt{\class{hg-key}{\alpha_t}}\cdot x + \sqrt{1-\class{hg-key}{\alpha_t}}\cdot\epsilon, \qquad \class{hg-key}{\alpha_t} = \prod_{s=1}^{t}(1-\beta_s) \]
or in probabilistic form, the diffusion kernel
\[q(z_t|x) = \text{Norm}_{z_t}\!\left[\sqrt{\alpha_t}\,x,\ (1-\alpha_t)I\right]\]
Any noise level is reached in one operation, without computing \(z_1 \dots z_{t-1}\).

\(\alpha_t\) is a running product of terms below one, so it decreases to zero and the kernel tends to \(\text{Norm}[0,I]\).

The marginal integrates the kernel against the data density:
\[q(z_t) = \int q(z_t|x)\,Pr(x)\,dx\]
Bayes’ rule reverses one step:
\[q(z_{t-1}|z_t) = \frac{q(z_t|z_{t-1})\,\class{hg-alt}{q(z_{t-1})}}{\class{hg-alt}{q(z_t)}}\]
The marginals \(\class{hg-alt}{q(z_{t-1})}\) and \(\class{hg-alt}{q(z_t)}\) have no closed form, so neither does the ratio.

During training \(x\) is known. Keeping it in the conditioning replaces the unknown marginals with kernels:
\[ q(z_{t-1}|z_t, \class{hg-key}{x}) = \frac{q(z_t|z_{t-1},\class{hg-key}{x})\ \class{hg-key}{q(z_{t-1}|x)}}{\class{hg-key}{q(z_t|x)}} \ \propto\ q(z_t|z_{t-1})\ \class{hg-key}{q(z_{t-1}|x)} \]
Both factors are now Gaussian, so their product is Gaussian.
\[ q(z_{t-1}|z_t, x) = \text{Norm}_{z_{t-1}}\!\left[\ \underbrace{\frac{(1-\alpha_{t-1})\sqrt{1-\beta_t}}{1-\alpha_t}z_t + \frac{\sqrt{\alpha_{t-1}}\,\beta_t}{1-\alpha_t}x}_{\text{mean}}, \quad \underbrace{\frac{\beta_t(1-\alpha_{t-1})}{1-\alpha_t}I}_{\text{variance}}\ \right] \]
\[ \begin{aligned} Pr(z_T) &= \text{Norm}_{z_T}[0, I] \\[2pt] Pr(z_{t-1}|z_t, \phi_t) &= \text{Norm}_{z_{t-1}}\!\left[\class{hg-key}{f_t[z_t,\phi_t]},\ \sigma_t^2 I\right] \\[2pt] Pr(x|z_1, \phi_1) &= \text{Norm}_{x}\!\left[\class{hg-key}{f_1[z_1,\phi_1]},\ \sigma_1^2 I\right] \end{aligned} \]
Generation is ancestral sampling: draw \(z_T\), then \(z_{T-1}\), down to \(x\).
\[ Pr(x, z_{1\dots T}|\phi) = Pr(x|z_1,\phi_1)\prod_{t=2}^{T} Pr(z_{t-1}|z_t,\phi_t)\cdot Pr(z_T) \]
The likelihood requires marginalising \(z_{1 \dots T}\) out of this product — an integral over \(T\) latent variables with no closed form.
The same obstruction as the VAE, and the same repair: bound it below.
Multiply and divide by the encoder distribution, then apply Jensen:
\[ \begin{aligned} \log\!\left[Pr(x|\phi)\right] &= \log\!\left[\int \class{hg-key}{q(z_{1\dots T}|x)}\, \frac{Pr(x, z_{1\dots T}|\phi)}{\class{hg-key}{q(z_{1\dots T}|x)}}\, dz_{1\dots T}\right] \\[6pt] &\ge\ \int q(z_{1\dots T}|x)\,\class{hg-alt}{\log}\!\left[ \frac{Pr(x, z_{1\dots T}|\phi)}{q(z_{1\dots T}|x)}\right] dz_{1\dots T} \end{aligned} \]
\(q\) has no parameters, so the decoder alone must tighten the bound.
Substituting both products and separating the terms:
\[ \log\!\left[\frac{Pr(x,z_{1\dots T}|\phi)}{q(z_{1\dots T}|x)}\right] = \log\!\left[\frac{Pr(x|z_1,\phi_1)}{q(z_1|x)}\right] + \log\!\left[\frac{\prod_{t=2}^{T}Pr(z_{t-1}|z_t,\phi_t)}{\prod_{t=2}^{T}\class{hg-alt}{q(z_t|z_{t-1})}}\right] + \log\!\left[Pr(z_T)\right] \]
The denominator of the middle term is rewritten by the Markov property and Bayes’ rule:
\[ \class{hg-alt}{q(z_t|z_{t-1})} = q(z_t|z_{t-1},x) = \frac{q(z_{t-1}|z_t,x)\ \class{hg-key}{q(z_t|x)}}{\class{hg-key}{q(z_{t-1}|x)}} \]

Each numerator cancels the denominator of the next factor. Only \(q(z_1|x)\) and \(q(z_T|x)\) survive, and \(\log\left[Pr(z_T)/q(z_T|x)\right] \approx \log 1 = 0\), because the forward process ends at a standard normal and so does the prior.
\[ \text{ELBO}[\phi] \approx \underbrace{\mathbb{E}_{q(z_1|x)}\!\left[\log Pr(x|z_1,\phi_1)\right]}_{\text{reconstruction}} \ -\ \sum_{t=2}^{T} \underbrace{\mathbb{E}_{q(z_t|x)}\!\left[D_{KL}\!\left[q(z_{t-1}|z_t,x)\,\big\|\,Pr(z_{t-1}|z_t,\phi_t)\right]\right]}_{\text{one per timestep}} \]
Most of the KL between two Gaussians does not depend on \(\phi\), so it reduces to the distance between the means plus a constant:
\[ D_{KL}\!\left[\cdot\,\|\,\cdot\right] = \frac{1}{2\sigma_t^2}\left\| \underbrace{\frac{(1-\alpha_{t-1})\sqrt{1-\beta_t}}{1-\alpha_t}z_t + \frac{\sqrt{\alpha_{t-1}}\beta_t}{1-\alpha_t}x}_{\text{target}} \ -\ \underbrace{\class{hg-key}{f_t[z_t,\phi_t]}}_{\text{prediction}}\right\|^2 + C \]
A variational bound over \(T\) latents has become a per-step regression problem.

The kernel \(z_t = \sqrt{\alpha_t}x + \sqrt{1-\alpha_t}\,\epsilon\) rearranges to
\[x = \frac{1}{\sqrt{\alpha_t}}z_t - \frac{\sqrt{1-\alpha_t}}{\sqrt{\alpha_t}}\class{hg-alt}{\epsilon}\]
Substituting this into the target and simplifying collapses it to two terms:
\[ \frac{1-\alpha_{t-1}}{1-\alpha_t}\sqrt{1-\beta_t}\,z_t + \frac{\sqrt{\alpha_{t-1}}\beta_t}{1-\alpha_t}x \ =\ \frac{1}{\sqrt{1-\beta_t}}z_t - \frac{\beta_t}{\sqrt{1-\alpha_t}\sqrt{1-\beta_t}}\class{hg-alt}{\epsilon} \]
The target no longer mentions \(x\). It mentions \(z_t\), which the network sees, and \(\epsilon\), which it could predict.
Replace \(f_t\) by a network \(\class{hg-key}{g_t}\) that predicts the noise:
\[ f_t[z_t,\phi_t] = \frac{1}{\sqrt{1-\beta_t}}z_t - \frac{\beta_t}{\sqrt{1-\alpha_t}\sqrt{1-\beta_t}}\class{hg-key}{g_t[z_t,\phi_t]} \]
The \(z_t\) terms in target and prediction are now identical and cancel, leaving a scaled squared difference between true and predicted noise.
Dropping the per-timestep scaling factors, which is an empirical choice:
\[ L[\phi] = \sum_{i=1}^{I}\sum_{t=1}^{T} \left\| \class{hg-key}{g_t}\!\left[\sqrt{\alpha_t}\,x_i + \sqrt{1-\alpha_t}\,\epsilon_{it},\ \phi_t\right] - \epsilon_{it}\right\|^2 \]
Nothing in this line looks probabilistic. It is the variational bound, reparameterized.
Training
Training reaches any timestep in one operation; sampling runs \(T\) steps in series.

The \(T\) evaluations are serial, each depending on the last, so they do not parallelise. This is the main practical objection to diffusion models.



Classifier guidance
adds \(\sigma_t^2\,\partial \log Pr(c|z_t)/\partial z_t\) to the update; needs a classifier trained on noisy inputs
Classifier-free guidance
puts \(c\) inside \(g_t[z_t,\phi_t,c]\) and drops it at random during training, so one model does both
The next unit is CLIP, and the module closes with classifier-guided and classifier-free diffusion.