In collapsed Gibbs sampling for LDA, the topic of a word is resampled from . Where does each factor come from? What is its value for , , , , with , and ?
Probabilistic models, Topic models (LDA)
Level L3 Intermediate. Length Long. Nature Th+Mat Both.
What's being asked
Whether you understand the Dirichlet–multinomial predictive that gives the collapsed conditional, and can evaluate it.
Key idea
With and integrated out, a Dirichlet prior acts as pseudo-counts: . The conditional is the product of a document factor and a topic–word factor.
Steps
- The joint after integrating out and is a product of Dirichlet–multinomial terms. The conditional for one token comes from the ratio of this joint with and without that token.
- Document factor: is proportional to the chance that the topic is given the other topics in the document . The means we leave out the current token.
- Topic–word factor: is the chance that topic emits word . The denominator adds because there are words, each with a pseudo-count .
- Numbers for topic 1: .
- Numbers for topic 2: .
- Normalise: and . Topic 1 wins because the document is mostly topic 1 and topic 1 has used this word often.
- Sampling uses these probabilities, then increments the counts. Averaging and over later sweeps gives estimates.
Common mistakes
- Forgetting to remove the current token from the counts before computing the conditional.
- Omitting the denominator .
- Mixing up the two count tables. counts topic inside document only, whereas and count over the whole corpus.
How long your answer should be
A page. About 7 minutes.
Last checked on 4 December 2026.
Read this
Previous in Probabilistic models: For a bivariate Gaussian with zero means, unit variances and correlation , derive the Gibbs conditionals. Show that the sequence of values from a Gibbs sampler is an AR(1) process with coefficient . How many Gibbs steps per effectively independent sample are needed for ?
Next in Probabilistic models: The data are with known , and the prior is . For and sample mean , what is the posterior of and what is the predictive distribution of a new observation? How do you show that the posterior mean is a precision-weighted average?