Skip to content
BIASED

Latent Dirichlet allocation

Block 1 of 7~2 min

One topic per document is not enough

The topic Dirichlet processes ended with mixture models whose every object belongs to exactly one cluster. Apply that to text, with a whole document as the object, and each document gets exactly one theme. Real documents are not like that: a report on a football club's finances is about sport and about money at once. This topic builds a mixture of mixtures, in which every document mixes several shared themes in its own proportions.

A word of warning first. In this lesson a topic almost always means an LDA topic, a distribution over words; earlier lessons of the course are named in italics.

Text is treated as a bag of words: a document is the multiset of its tokens, and word order is thrown away. Take a vocabulary of V=4V = 4 words (team, goal, market, price) and two topics, each a probability vector over the vocabulary:

ϕ1=(0.45, 0.45, 0.05, 0.05) (sport),ϕ2=(0.05, 0.05, 0.45, 0.45) (economics).\phi_1 = (0.45,\ 0.45,\ 0.05,\ 0.05) \ \text{(sport)}, \qquad \phi_2 = (0.05,\ 0.05,\ 0.45,\ 0.45) \ \text{(economics)}.

A mixture of unigrams picks one topic per document with probabilities πk\pi_k and draws all the words from it:

p(wd)=∑k=1Kπk∏n=1Ndϕkwdn.p(w_d) = \sum_{k=1}^{K} \pi_k \prod_{n=1}^{N_d} \phi_{k w_{dn}}.

For the document "goal team price" with π=(0.5,0.5)\pi = (0.5, 0.5) this gives 0.5⋅0.010125+0.5⋅0.001125=0.0056250.5 \cdot 0.010125 + 0.5 \cdot 0.001125 = 0.005625. The sport topic alone explains "goal team" well but has to pay 0.050.05 for "price", and no single topic does better.

LDA instead gives each document its own topic proportions θd\theta_d and lets every word choose its topic separately. The probability of one word becomes a mixture:

p(wdn=w∣θd,ϕ)=∑k=1Kθdk ϕkw.p(w_{dn} = w \mid \theta_d, \phi) = \sum_{k=1}^{K} \theta_{dk}\, \phi_{kw}.

With θd=(2/3,1/3)\theta_d = (2/3, 1/3) the words "goal" and "team" get 23⋅0.45+13⋅0.05≈0.317\tfrac23 \cdot 0.45 + \tfrac13 \cdot 0.05 \approx 0.317 each, "price" gets ≈0.183\approx 0.183, and the document gets ≈0.0184\approx 0.0184: about 1.81.8 times what the sport topic alone gives and more than three times the mixture of unigrams.

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