Variational inference (VI) approximates a difficult posterior with a distribution that is easier to compute. Choose a tractable family q(z), give it trainable parameters, and optimize those parameters so q(z) approaches the posterior p(z|x). Unlike Markov chain Monte Carlo (MCMC), which approximates a posterior using samples, VI turns inference into an optimization problem. section 3.0 section 1.6
The choice of q limits the approximation. A mean-field q is fully factorized, which speeds computation but restricts the posterior shapes it can represent. For greater accuracy, the aim is to improve the variational approximation rather than rely only on that factorization; no particular richer family or update rule is specified here. section 3.0 section 3.1
KL divergence measures a mismatch between distributions, but its direction matters. On a multimodal posterior, forward KL can favor a broad q that covers low-density space between modes; reverse KL can favor q concentrated on one mode. Accuracy therefore depends both on the variational family and on what the objective rewards. section 1.4.1 section 3.1
Let x denote observations and z latent variables. Jensen’s inequality gives an evidence lower bound (ELBO) to maximize when learning q. One interpretation balances high joint probability against the entropy of q; another expresses a likelihood term alongside divergence from the prior. The bound tightens as q better approximates the posterior, and expectations under q can be estimated by drawing samples from q. section 3.1
Topic inference with variational Bayes
For latent Dirichlet allocation, coordinate-ascent updates optimize variational parameters. An online version updates document-level parameters, then blends a proposed global update with its previous value. A from-scratch implementation tracks increasing ELBO across mean-field iterations and displays inferred topics as word clouds. This demonstrates the factorized baseline, not an implemented richer variational family. section 9.1.1
Figure 3.2 Forward KL (left) q(x) overestimates the support, while reverse KL (right) q(x) locks onto a mode.
Compare the broad forward-KL fit with the reverse-KL fit concentrated on a mode; the figure makes the objective’s effect on approximation quality visible. section 3.1

