Topic Modeling — Latent Dirichlet Allocation

Machine Learning
Introduced by
Blei, Ng & Jordan
Year
2003
Type
Generative probabilistic topic model

What does it do?

Latent Dirichlet Allocation (LDA) is a generative probabilistic model introduced by Blei, Ng and Jordan (2003) to uncover the latent topics in a collection of documents.

It represents each document as a mixture of topics and each topic as a distribution over words, so an unlabelled corpus can be summarised as a set of interpretable themes.

The intuition behind the method

Document collections usually concern a small number of recurring themes, but those themes are rarely labelled. LDA assumes that each document is a blend of several hidden topics and that each topic favours certain words. Formally, each document's topic proportions are drawn from a Dirichlet prior with parameter α, each topic's word distribution is drawn from a Dirichlet prior with parameter β, and the number of topics k is fixed in advance. Words are treated as exchangeable within a document, so word order is ignored. By working backwards from which words tend to occur together across documents, the model estimates both the topics and how strongly each document draws on them, without anyone tagging the text in advance.

History

LDA was introduced by Blei, Ng and Jordan in 2003 as a generative probabilistic model for collections of discrete data such as text corpora. It became a foundational method in probabilistic topic modeling, representing each document as a finite mixture over an underlying set of latent topics.

When to use it

Choose LDA when you have a collection of text documents and want to explore the themes running through it without predefined categories. It suits exploratory and descriptive work on unstructured text. Do not use it without text data, such as purely numerical or categorical records. Avoid it on a very small corpus, because few documents tend to yield unstable topics; in that case a simple word-frequency analysis is more transparent. The corpus size needed for stable topics depends on document length and vocabulary. Only use LDA if you are prepared to choose k and to judge whether the resulting topics are interpretable. If the aim is to assign documents to known categories, a supervised classification approach is usually more appropriate.

Limitations and considerations

  • The bag-of-words representation discards word order and syntax, so phrases, negation and context are not modelled.
  • The number of topics k must be specified before fitting; the model does not determine it.
  • Inference is approximate and sensitive to starting values and settings, so different runs may yield somewhat different topics that need to be compared.
  • Topic labels are assigned by the analyst from word lists, so interpretation involves subjective judgement.

Source conditions do not replace independent scientific review or validation by an analysis engine.

Strengths

  • Finds themes in an unlabelled corpus without manually coded categories, which is useful when the categories are not known in advance.
  • Gives each document a proportion over topics, so a text that spans several themes is represented as such rather than forced into a single category.
  • Describes each topic by its highest-weighted words, so the output can be inspected directly.

Applications

  • Grouping large collections of articles, abstracts or reports by their dominant themes.
  • Organising and summarising document archives by the topics they contain.
  • Exploratory analysis of open-ended survey responses or interview transcripts.
  • Examining how topic prevalence differs across sources or changes over time, where documents carry source or date information.

How it works

How it works

1

The raw text is lowercased, cleaned of noise, and split into word tokens. Very frequent function words (stopwords) are usually removed, because otherwise they would dominate the topics without carrying thematic meaning.

2

Each document is converted into a bag-of-words vector of term counts. Word order is discarded; the model works only with how often each term occurs in each document.

3

The number of topics k is fixed before fitting and has to be chosen deliberately. In practice, models are fitted for several candidate values of k and their coherence scores are compared, with the most interpretable and well-separated set of topics preferred. The score is a guide to that judgement rather than an automatic answer.

4

The model is fitted to the document-term counts using approximate inference, which estimates for each document a mixture over the k topics and for each topic a distribution over the vocabulary. Common implementations use variational inference or collapsed Gibbs sampling. The Dirichlet hyperparameters α and β, which control how concentrated document mixtures and topic word distributions are, are usually set or checked before fitting. Because inference is approximate and depends on its starting values, repeated runs can produce somewhat different topics.

Formula
p(\theta, z, w \mid \alpha, \beta) = p(\theta \mid \alpha) \prod_{n=1}^{N} p(z_n \mid \theta)\, p(w_n \mid z_n, \beta)
5

Each topic is read through its highest-weighted words and given a label by the analyst, and each document is described by its proportions over the topics. These labels are a human judgement and should be checked against the documents that load most heavily on each topic.

Common pitfalls

  • Running LDA on a very small corpus produces unstable topics; with little text, a simple word-frequency analysis is more transparent.
  • Choosing k without comparing candidate values can produce topics that are too broad, or that split one theme into fragments.
  • Skipping preprocessing lets stopwords and generic high-frequency terms dominate the topics and make them uninformative.
  • Treating a topic label as settled meaning: a list of top words is evidence for a theme, but the label should be checked against representative documents.
  • Applying LDA to data that contain no text; a qualitative thematic analysis is the appropriate alternative in that case.

Frequently asked questions

How do I choose the number of topics k?

k is set before fitting and should be chosen deliberately rather than guessed. A common approach is to fit the model for several candidate values of k, compare their coherence scores, and then keep the value that gives the most interpretable, well-separated topics on inspection.

How many documents does LDA need?

Very small corpora tend to produce unstable topics, and in that case a simple frequency analysis may be the safer starting point. The size needed for stable topics depends on document length and vocabulary, so check whether the main topics recur across repeated runs.

What does LDA actually output?

For every document it estimates a distribution over the k topics, and for every topic a distribution over the vocabulary. You read each topic through its highest-weighted words to label it, and describe each document by its mixture of topics.

Can I use LDA without text data?

No. LDA operates on a corpus of text documents represented as word counts. Without text data, topic modeling cannot be applied, and a qualitative thematic analysis is the appropriate alternative.

Related methods

Sources

  1. Blei, D.M., Ng, A.Y. & Jordan, M.I. (2003). Latent Dirichlet Allocation. Journal of Machine Learning Research, 3, 993-1022.

    Open publication reference
  2. Intelligent-and-Fuzzy-Systems, p. 164

  3. Intelligent-and-Fuzzy-Systems, p. 170