Skip to content
BIASED

Stochastic variational inference

Block 1 of 7~2 min

Global and local variables

The topic Latent Dirichlet allocation ended with a cost problem. Mean-field VI for LDA updates the proportions γd\gamma_d and responsibilities rdnr_{dn} of every document, and only then recomputes the topics λ\lambda. For a corpus of a million documents the topics move once per million local updates. This topic makes them move after every small batch.

The trick works for a whole class of models. Their joint density splits into a part shared by all objects and one factor per object:

p(x,z,θ)=p(θ)∏i=1np(xi,zi∣θ).p(x, z, \theta) = p(\theta) \prod_{i=1}^{n} p(x_i, z_i \mid \theta).

Here θ\theta are the global variables: every object depends on them. Each ziz_i is a local variable: it belongs to object xix_i alone, and given θ\theta the pair (xi,zi)(x_i, z_i) is independent of all other pairs. In LDA the topics ϕk\phi_k are global, while the proportions θd\theta_d and the assignments zdnz_{dn} of a document are local; so in LDA the global variables are written ϕ\phi, and the letter θd\theta_d keeps its LDA meaning.

The running example is the two-component Gaussian mixture of the topic EM and Bayesian PCA, now with a prior on the means. The components have unit variances, and to keep the example small their weights are fixed at 12\tfrac12. Each mean gets a broad prior:

μk∼N(0,σ02),σ02=100,zi∼Cat⁡(12,12),xi∣zi,μ∼N(μzi,1).\mu_k \sim \mathcal N(0, \sigma_0^2), \quad \sigma_0^2 = 100, \qquad z_i \sim \operatorname{Cat}(\tfrac12, \tfrac12), \qquad x_i \mid z_i, \mu \sim \mathcal N(\mu_{z_i}, 1).

The means θ=(μ1,μ2)\theta = (\mu_1, \mu_2) are global, the labels ziz_i are local.

The mean-field family mirrors the split: q(θ∣λ)∏iq(zi∣ξi)q(\theta \mid \lambda) \prod_i q(z_i \mid \xi_i), with a global variational parameter λ\lambda and local parameters ξi\xi_i (for the mixture, the responsibilities rik=q(zi=k)r_{ik} = q(z_i = k)). The ELBO splits the same way, into a global term and a sum of nn local ones:

L(λ,ξ)=Eq[log⁡p(θ)]−Eq[log⁡q(θ∣λ)]+∑i=1n(Eq[log⁡p(xi,zi∣θ)]−Eq[log⁡q(zi∣ξi)]).\mathcal L(\lambda, \xi) = \mathbb E_q[\log p(\theta)] - \mathbb E_q[\log q(\theta \mid \lambda)] + \sum_{i=1}^{n} \Big( \mathbb E_q[\log p(x_i, z_i \mid \theta)] - \mathbb E_q[\log q(z_i \mid \xi_i)] \Big).

Coordinate ascent from the topic Variational inference alternates two steps: update all nn local parameters, then update λ\lambda. The first pass is the most wasteful one: nn local updates are computed under a random initial λ\lambda, and all of them are used for a single global step.

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