Semi-supervised LDA Topic Model

Machine Learning
Introduced by
Ramage, D.; Andrzejewski, D. et al.
Year
2009
Type
Semi-supervised probabilistic topic model
Family
Deep learning / NLP / CV

What does it do?

Semi-supervised LDA is a family of extensions of Latent Dirichlet Allocation that inject limited prior knowledge into topic discovery so that the learned topics align with categories the analyst cares about.

The two main routes are different. Seed-based or constraint-based approaches, such as Dirichlet Forest priors, encode knowledge about which words should have high or low probability in a topic. Document-label approaches, such as Labeled LDA, restrict each document's topics to its observed labels. The family sits between unsupervised topic modeling and full text classification, and it is most relevant when labeling the whole corpus is too costly.

The intuition behind the method

Standard LDA infers topics only from word co-occurrence, so the resulting topics may not match the categories a researcher cares about and may be hard to name. Semi-supervised variants let the analyst supply a little knowledge, such as a few seed words per intended topic, word constraints, or labels on some documents, without labeling the whole corpus. In the seed-based setting the knowledge acts as a prior that pulls topic-word distributions toward the specified themes, while the unlabeled text still shapes the topics through co-occurrence. Because the guidance is a prior rather than a hard assignment, the model can move away from the seeds when the data strongly disagree. Label-based models such as Labeled LDA instead constrain which topics a document may use.

History

Latent Dirichlet Allocation was introduced by Blei, Ng, and Jordan in 2003 and is the base model for the variants described here. In 2009, two distinct extensions appeared. Ramage, Hall, Nallapati and Manning described Labeled LDA, a supervised topic model for multi-labeled corpora in which topics are tied to observed document labels. Andrzejewski, Zhu, and Craven introduced Dirichlet Forest priors, which encode domain knowledge about which words should have high or low probability within a topic. Both lines of work responded to the cost of full supervision, and they were later used in computational social science and digital humanities.

When to use it

Choose semi-supervised LDA when you have a text corpus, a set of thematic categories you can name in advance, and too few labels to train a supervised classifier. It fits projects where topics must be readable and tied to a conceptual framework, such as policy or social science coding. Prefer it to standard LDA when topics need to match predefined categories, and prefer it to a supervised classifier when labeled data are scarce. Do not use it when enough labeled documents exist to train a classifier; a fine-tuned BERT-based model is usually the stronger choice then, because it also uses word order and context. Avoid it when no reliable seed knowledge exists, since poorly chosen seeds can make topics worse than those from unsupervised LDA.

Limitations and considerations

  • Topic quality depends on seed quality: ambiguous or cross-category seeds can pull several topics toward the same words.
  • The method still requires tuning of K, alpha, beta, and, for seeded priors, the seed strength lambda, and the best lambda depends on how distinctive the seeds are.
  • Because inference is iterative Gibbs sampling, it is slow on very large corpora. It inherits LDA's cost, so parallel or variational variants are needed at scale.
  • It cannot be expected to match a fully supervised classifier when large labeled datasets are available.
  • The bag-of-words representation ignores word order and syntax, which limits its ability to separate word senses or negation compared with transformer-based models.

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

Strengths

  • Uses domain knowledge with a light annotation burden: a set of seed words, word constraints or a few labeled documents is enough, and the rest of the corpus can remain unlabeled.
  • When the intended categories are known in advance, guided topics can be easier to interpret and to align with a theoretical framework than unsupervised LDA topics.
  • Inference uses collapsed Gibbs sampling as in standard LDA, so its computational profile is broadly similar to that of LDA.
  • The document-topic distributions it produces can be used as features in downstream models.
  • Knowledge input is flexible: seed words, word-level must-link or cannot-link constraints, or document labels can be used depending on what is available.

Applications

  • Political science: classifying legislative texts or news articles into predefined policy domains using seed vocabularies.
  • Healthcare: organizing clinical notes or patient feedback into symptom or treatment categories with minimal annotation.
  • Social media analysis: guiding topic discovery on Twitter or Reddit toward meaningful thematic clusters.
  • Digital humanities: aligning topics in historical corpora with theoretically motivated categories.
  • Market research: structuring open-ended survey responses into product-relevant themes using domain seed words.
  • Education: categorizing student feedback or academic papers into curriculum-aligned subject areas.

How it works

How it works

1

For each intended topic, the analyst specifies a small set of seed words or, in the label-based variant, documents with known labels. The seed vector s_k in the next step can be defined, for example, as an indicator over the vocabulary marking which words support topic k. Seeds should be distinctive to their category, because a word that appears under several categories gives the prior little discriminating information.

Formula
s_{k,w} = \mathbb{1}[w \in \mathcal{S}_k]
2

One common way to implement seeded guidance, used as an illustration on this page, is to scale the seed vector s_k by a strength parameter lambda and add it to the topic's Dirichlet parameter, as in the update formula. A larger lambda gives the seeded topic more prior mass, while a smaller lambda leaves more freedom to the corpus. This additive form is a simple formulation, not the published definition of either cited method. The Dirichlet Forest prior of Andrzejewski, Zhu and Craven is a mixture of Dirichlet tree distributions that encodes word-level knowledge about which words should have high or low probability within a topic. Labeled LDA instead restricts each document to the topics given by its observed labels.

Formula
\alpha_k \leftarrow \alpha_k + \lambda \cdot \mathbf{s}_k
3

Inference uses collapsed Gibbs sampling, as in standard LDA. For each word token, the topic label is resampled in proportion to the document-topic count plus the prior alpha_k, times the topic-word count plus beta, divided by the topic total plus V times beta, with all other assignments held fixed. The Dirichlet Forest prior also uses collapsed Gibbs sampling, with a modified sampler that accounts for the tree structure.

Formula
p(z_i=k \mid \mathbf{z}_{-i}, w_i) \propto (n_{d,k}^{-i}+\alpha_k)(n_{k,w_i}^{-i}+\beta) / (n_k^{-i}+V\beta)
4

After enough sampling iterations, the topic-word distributions phi are estimated from the smoothed counts n_{k,w} plus beta, normalised over the vocabulary. Seeded topics are expected to give more probability to their seed words, but the estimate is not forced to rank the seeds highest, so other co-occurring words can also appear at the top of a topic.

Formula
\phi_{k,w} = (n_{k,w}+\beta)/(n_k+V\beta)
5

Quality is usually checked with held-out perplexity, topic coherence measures such as NPMI, and manual inspection of each topic's top words. Perplexity and coherence do not always agree, so the interpretability check matters. For seeded topics, also check whether the seed words appear among the top words. If document labels exist, held-out classification accuracy based on the document-topic proportions gives a further check on label alignment.

Common pitfalls

  • Choosing K (number of topics) arbitrarily without evaluating perplexity or coherence across a range of values.
  • Using seeds that are too general (e.g., 'data', 'result') and appear across many topics, causing topic conflation.
  • Ignoring stopword removal and lemmatization, which pollute topic-word distributions with function words.
  • Evaluating only perplexity without human or coherence-based quality checks, since lower perplexity does not always mean more interpretable topics.
  • Treating document-topic proportions as ground-truth labels rather than soft probabilistic estimates.
  • Setting lambda so high that the seeds dominate and the corpus can no longer reshape the topics.

Frequently asked questions

How many seed words per topic are enough?

Use a few distinctive, domain-specific words per topic, and add more iteratively while checking coherence after each round. More seeds give stronger guidance but can over-constrain the model, so it is sensible to start small.

How do I choose the number of topics K?

Compare held-out perplexity and coherence (e.g., NPMI) across a range of candidate K values, and check that the top words of each topic make sense for your analysis. The statistically best K may not be the one that suits the research question.

What if my seeds produce worse topics than standard LDA?

Poor seed quality is the most common cause. Review seeds for ambiguity and cross-topic overlap, remove function words, and make sure each seed is genuinely distinctive to its category. Reducing the seed strength lambda also allows the model more freedom to deviate from the prior.

How do I choose the seed strength lambda?

As a heuristic, sweep lambda over a range of values spanning several orders of magnitude, and for each value record topic coherence and how many seed words remain among each topic's top words. Prefer a value where seeded topics stay interpretable and aligned with their seeds while still including corpus-driven words. If the top words are only the seeds, lambda is probably too strong.

Can I use this method with short texts such as tweets?

Short texts create sparse word co-occurrence patterns that make LDA unstable regardless of supervision. Consider aggregating short documents into pseudo-documents or using biterm topic models before applying semi-supervised guidance.

When should I switch to a fine-tuned BERT model instead?

When labeled examples are plentiful for each category, a fine-tuned BERT-based classifier is usually the stronger choice for accuracy. Semi-supervised LDA is more useful when labels are very scarce and interpretable topic distributions are also needed.

Related methods

Sources

  1. Ramage, D., Hall, D., Nallapati, R., & Manning, C. D. (2009). Labeled LDA: A supervised topic model for credit attribution in multi-labeled corpora. Proceedings of EMNLP, 248–256.

    Open publication reference
  2. Andrzejewski, D., Zhu, X., & Craven, M. (2009). Incorporating domain knowledge into topic modeling via Dirichlet Forest priors. Proceedings of ICML, 25–32.

    Open DOI reference