Skip to content
BIASED

Variational inference

Block 1 of 7~2 min

From the E-step to optimization

The topic EM and Bayesian PCA split the log-likelihood into a lower bound and a gap, and its E-step closed the gap by setting q(Z)=p(Z∣X,θ)q(Z) = p(Z \mid X, \theta). That step quietly assumed we can write the exact posterior over the latent variables. Often we cannot. A non-conjugate piece or a coupling between latent variables is enough to make the normalizing integral intractable. And once the parameters get priors too, they join the unknowns, and a posterior over everything at once is rarely available in closed form.

Variational inference keeps the decomposition and gives up exactness. Let ZZ now stand for all unknowns: latent variables and parameters alike. For any distribution q(Z)q(Z),

log⁡p(X)=L(q)+KL(q(Z) ∥ p(Z∣X)),L(q)=Eq[log⁡p(X,Z)]−Eq[log⁡q(Z)].\log p(X) = \mathcal L(q) + \mathrm{KL}\big(q(Z) \,\|\, p(Z \mid X)\big), \qquad \mathcal L(q) = \mathbb E_q[\log p(X, Z)] - \mathbb E_q[\log q(Z)].

The left side does not depend on qq. So raising the ELBO L(q)\mathcal L(q) lowers the KL to the posterior by exactly the same amount. We pick a variational family Q\mathcal Q of distributions we can handle and solve

q∗=arg⁡max⁡q∈QL(q).q^* = \arg\max_{q \in \mathcal Q} \mathcal L(q).

An integral we cannot take becomes an optimization we can run. If Q\mathcal Q happens to contain the true posterior, the optimum is the posterior itself, and we are back at the exact E-step of EM.

All of this is useful only if L(q)\mathcal L(q) can be evaluated while the posterior cannot. Read its definition once more with that question in mind; the check below asks exactly this.

If some parameters θ\theta stay point estimates, we can alternate: a variational E-step over q∈Qq \in \mathcal Q, then an M-step over θ\theta. This is variational EM. Each step raises the ELBO, but unlike exact EM the log-likelihood itself is no longer guaranteed to grow.

Answers are saved on the server and tied to this browser until you sign in.