Paper commentary
Stochastic Variational Inference
Stochastic variational inference fits topic models to massive document collections
- Problem Classical variational inference revisits every document before each global update. That makes one iteration grow with the full corpus, so it cannot handle collections of millions of articles.
- Method Stochastic variational inference samples one document at a time and updates its local parameters. It then moves the running global estimate toward an intermediate value with a decaying step size.
- Results On Nature, LDA with 100 topics reached -7.26 predictive log likelihood, while the HDP topic model reached -6.97 under the same settings.
Why full-data passes limit variational inference
Variational inference turns posterior inference into an optimization problem over a family of approximating distributions, and the classical solver for mean-field models alternates between two kinds of update. Each sweep revisits every data point to refresh its local parameters before the global parameters can move, so the cost of one iteration grows with the full corpus.
The corpora in the study are large: Nature holds 350,000 documents, the New York Times 1.8M and Wikipedia 3.8M.
The batch baseline therefore had to be restricted to a subset of 100,000 documents, which the authors treat as the size batch inference can handle. The aim is an algorithm that does not need that full pass before the global parameters start improving, while still computing closed-form updates from the same building blocks.
One sampled document per global step
Classical coordinate ascent sets each local parameter to an expectation under the current global approximation, and then sets the global parameters to the expected natural parameter of their complete conditional. Written out, the global step is \(\lambda = \mathbb{E}_q[\eta_g(x, z, \alpha)]\), so it depends on the local parameters of all observations.
The stochastic version draws one document at random, optimizes its local parameters with the current globals, and forms an intermediate global estimate as if that document were repeated N times. The running global estimate is then moved toward this intermediate value with step size \(\rho_t\): \(\lambda^{(t)} = (1-\rho_t)\lambda^{(t-1)} + \rho_t\hat{\lambda}\).
Because the update only needs the sampled context, each iteration touches a single local context, and an existing coordinate-ascent implementation can be reused for the local and intermediate steps.
When documents are sampled independently, the average of these noisy gradients equals the true gradient, so the subsampled step remains a valid stochastic optimization step. Larger minibatches serve two purposes: they spread the cost of updating the global parameters over more documents, and they make it less likely that small noisy steps settle in a poor local optimum.
The same procedure can fit the hyperparameter α by taking a noisy gradient step on the ELBO alongside λ, scaled by the step size.
Why the update follows the natural gradient
The Euclidean gradient measures change in raw parameter values, which can mislead when those parameters describe a probability distribution. The authors illustrate this with two normal pairs: N(0, 10000) and N(10, 10000) are nearly indistinguishable although their parameter vectors are 10 apart, while N(0, 0.01) and N(0.1, 0.01) barely overlap although their parameter vectors are only 0.1 apart.
The natural gradient instead uses the symmetrized KL divergence between the two distributions, given as Equation 18, which does not depend on how the distribution is parameterized. As the step size goes to zero, the steepest-ascent direction under this divergence points along the natural gradient. The authors note that the Euclidean gradient in the hyperparameter step could likewise be replaced by a natural gradient or a Newton step.
LDA and the HDP as instances of the algorithm
In LDA, each of K topics is drawn from a Dirichlet with parameter η, and each document draws its own topic proportions from a Dirichlet with parameter α. The document is the local context: its topic proportions and topic assignments are local hidden variables, while the topics are global.
The expected sufficient statistics and variational parameters for LDA are collected in Figure 5, which lists the updates for the assignments, the topic proportions and the topics.
The HDP topic model replaces a fixed topic count with an infinite set of topics, built from a top-level Dirichlet process whose atoms are topics and document-level Dirichlet processes that draw from it. Both levels use stick-breaking: corpus-level breaking proportions come from Beta(1, ω), and document-level breaking proportions come from Beta(1, α).
An infinite set of variational parameters cannot be stored, so the variational family is truncated at K corpus-level topics and T document-level components, with T expected to be much smaller than K.
In the stochastic HDP step, the intermediate topic parameter is \(\hat{\lambda}_k = \eta + D\sum_{i=1}^{T} \mathbb{E}_q[c_{kdi}] \sum_{n=1}^{N} \mathbb{E}_q[z_{idn}] w_{dn}\). The authors say this mirrors the LDA update, with the document's topic indices added.
Stochastic versus batch inference, and LDA versus HDP
The main LDA comparison uses 100 topics on three corpora, with stochastic inference on the full collection and batch inference restricted to 100,000 documents. The metric is predictive log likelihood on a held-out test set of 10,000 documents per corpus. The authors report that stochastic inference converged faster and to a better model, and the batch baseline in this comparison saw less of the data.
On Nature, the predictive log likelihood is -7.24 at 25 topics, -7.23 at 50, -7.26 at 100 and -7.86 at 300. At larger topic counts LDA overfits, and the authors say the HDP stays robust to this.
Under the same settings, the HDP topic model scored -6.97 on Nature, against -7.26 for 100-topic LDA on the same corpus. The HDP row is also above every LDA row on the New York Times and Wikipedia columns, with -7.38 and -7.07 for the HDP. The authors attribute part of this gap to the corpus-level breaking proportions, which let some topics be a priori more likely than others, whereas LDA's exchangeable prior treats all topics as equally common.
Forgetting rate and minibatch size
For the HDP topic model with batch size 500, the forgetting rate was varied on all three corpora, and values closer to one led to convergence to a better local optimum.
These sweeps are reported as curves, so the text gives the direction of each effect rather than exact scores.
Limits of the derivation and the evidence
The derivation assumes conjugate exponential-family models with closed-form coordinate updates, and nonconjugate models with richer priors are not covered by the general algorithm. The authors name collapsed variational inference and structured variational distributions as directions that move beyond closed-form updates and fully factorized posteriors, and they leave these open.
The forgetting-rate and batch-size sweeps were run with the other parameter fixed, for the HDP and for 100-topic LDA. The authors chose predictive log likelihood over held-out perplexity, and they say perplexity did not reveal the overfitting of LDA at large topic counts.
Stochastic variational inference is guaranteed to reach a local optimum, so the reported results do not establish a global optimum.
Paper info
- Authors
- Matt Hoffman, David M. Blei, Chong Wang, John Paisley
- Venue
- arXiv · Preprint
- First published
- 2012-6-29
- Added
- 2026-11-12
- Updated
- 2013-4-22
- Version
- v3
- arXiv
- 1206.7051
- Category
- stat.ML · cs.AI · stat.CO · stat.ME
- Original paper terms
- arXiv non-exclusive 1.0
- What we show
- Paper info and commentary
AI commentary is a separate explanation from the original paper and may contain errors. The original paper and figures follow each source's terms of use and any rights noted separately.
Quote from the paper
Matt Hoffman, David M. Blei, Chong Wang, John Paisley (2012). Stochastic Variational Inference. arXiv:1206.7051v3. https://arxiv.org/abs/1206.7051v3
BibTeX
@misc{hoffman2012stochastic,
title = {{Stochastic Variational Inference}},
author = {Matt Hoffman and David M. Blei and Chong Wang and John Paisley},
year = {2012},
eprint = {1206.7051},
archivePrefix = {arXiv},
url = {https://arxiv.org/abs/1206.7051v3}
}