Sub topic 5
How LDA Imagines Documents Being Written
This chapter assumes you know tokenisation, stop words, basic probability distributions, and the idea of a vector representation. Latent Dirichlet Allocation (LDA) is a probabilistic model that explains documents as mixtures of topics. It works with word counts, so it does not read word order or sentence grammar.
The generative story
LDA describes a fictional process that could have produced the documents. The training algorithm observes only the documents and their words. It tries to infer the hidden topics and the topic assignment for each word.
For a collection with \(K\) topics, LDA imagines this process:
- For each topic, choose a probability distribution over the vocabulary.
- For each document, choose a probability distribution over the topics.
- For every word position in a document:
- Choose a topic using the document's topic distribution.
- Choose a word using that topic's word distribution.
The distributions over words and topics contain probabilities, not just labels.
| Symbol | Meaning |
|---|---|
| \(\phi_k\) | Topic \(k\)'s probability distribution over words |
| \(\theta_d\) | Document \(d\)'s probability distribution over topics |
| \(z_{dn}\) | Hidden topic chosen for word position \(n\) in document \(d\) |
| \(w_{dn}\) | Observed word at that position |
A document about football might have \(\theta_d = [0.8, 0.2]\), meaning it is mostly about a sports topic but also contains some political vocabulary. A topic might assign high probability to words such as team, match, and player.
The process is called generative because it defines how to generate synthetic documents. During training, LDA runs this idea backwards: given the observed words, it estimates the hidden topic distributions.
Why Dirichlet distributions appear
LDA uses a Dirichlet distribution to generate probability distributions. The prior for document-topic mixtures is called alpha, and the prior for topic-word distributions is called eta.
- A smaller alpha encourages documents to use only a few topics.
- A larger alpha allows each document to mix many topics.
- A smaller eta encourages each topic to concentrate on fewer words.
- A larger eta makes topics use a broader vocabulary.
These are prior beliefs, not fixed answers. The fitted model updates them using the corpus.
What LDA assumes
LDA treats word positions as exchangeable. This means that, after accounting for topic assignments, changing the order of words does not change the document representation. The sentence “the team won” and the same words in another order contribute the same counts.
This assumption makes LDA simple and useful for collections with repeated vocabulary. It also explains why LDA can miss meaning that depends on word order, phrases, or context.
Exercise
In LDA, what produces an observed word in a document?
Show answer
The document's topic distribution first selects a hidden topic, and that topic's word distribution selects the observed word.