Notes

Latent Dirichlet Allocation (LDA)

Hand someone ten thousand news articles and ask what they are about, and nobody reads them all — they skim for recurring themes. Latent Dirichlet Allocation is a generative model that does this without supervision: it proposes that a small number of topics underlie the whole collection, then works out what they are.

The generative story
LDA assumes each document was produced by a two-step random process: draw a mixture of topics for the document, then for every word draw a topic from that mixture and a word from that topic's vocabulary distribution. Both draws come from Dirichlet priors, which is what pushes each document toward a few topics and each topic toward a few characteristic words. Training inverts the story — Gibbs sampling or variational inference recovers two things:

  • a document-topic distribution per document, giving the proportion of each theme in it;
  • a topic-word distribution per topic, whose highest-ranked words are what a human reads as the topic's label.

Using it
gensim's LdaModel and scikit-learn's LatentDirichletAllocation both consume a bag-of-words document-term matrix, so word order is discarded. Two decisions dominate the outcome: the number of topics, usually chosen by comparing topic coherence across candidate values, and the preprocessing — leave boilerplate and stopwords in and you get topics about the boilerplate.

Why it matters
Unlike a singular-value decomposition, LDA yields probabilities rather than signed coordinates, so a document's themes are interpretable as proportions that sum to one and a new document can be folded in under the same fitted model. It remains the standard tool for exploring an unlabelled corpus — organising a complaints archive, tracking what a parliament debated by decade — where no label set exists in advance.

Latent Dirichlet Allocation is a generative probabilistic model that treats each document as a mixture of latent topics and each topic as a distribution over words, both drawn from Dirichlet priors. Fitting it to a document-term matrix by Gibbs sampling or variational inference yields per-document topic proportions and per-topic word rankings. It is the standard unsupervised method for discovering the themes in an unlabelled corpus and representing documents by theme rather than by word.

A librarian handed a thousand unsorted articles could work out the main subjects without reading every page — just by noticing which words keep appearing together. Latent Dirichlet Allocation is software doing that. It looks at a big pile of documents and discovers a handful of recurring themes, with nobody telling it what to look for.

It also reports that each document is a blend: this article is mostly about elections and a little about the economy. That is how newsrooms and researchers get a map of an archive nobody has time to read, and how "more articles like this one" can work without anyone labelling them.