Supervised Topic Models

David M. Blei, Jon McAuliffe · DOI

Abstract

We introduce supervised latent Dirichlet allocation (sLDA), a statistical model of labelled documents. The model accommodates a variety of response types. We derive an approximate maximum-likelihood procedure for parameter estimation, which relies on variational methods to handle intractable posterior expectations. Prediction problems motivate this research: we use the fitted model to predict response values for new documents. We test sLDA on two real-world problems: movie ratings predicted from reviews, and the political tone of amendments in the U.S. Senate based on the amendment text. We illustrate the benefits of sLDA versus modern regularized regression, as well as versus an unsupervised LDA analysis followed by a separate regression.

Introduction

Standard Latent Dirichlet Allocation (LDA) has become a cornerstone for the unsupervised discovery of themes in large text corpora. By grouping words based on co-occurrence, LDA identifies latent topics that describe the underlying structure of a collection. However, LDA is inherently "blind" to external metadata or labels associated with documents. For instance, when analyzing movie reviews to predict star ratings, a standard LDA model might identify genre-based topics (e.g., "sci-fi" or "romance"). While these are valid themes, they may not be the most predictive of the reviewer's sentiment. To address this, we propose Supervised Latent Dirichlet Allocation (sLDA), which incorporates labels directly into the topic discovery process to find "predictive" themes that unsupervised models often overlook.

The sLDA Model

The sLDA model extends the traditional LDA framework by adding a response variable $Y_d$ to each document $d$. The generative process for sLDA is as follows:

  1. For each topic $k \in \{1, \dots, K\}$, draw a distribution over words $\beta_k \sim \text{Dirichlet}(\eta)$.
  2. For each document $d$: a. Draw topic proportions $\theta_d \sim \text{Dirichlet}(\alpha)$. b. For each word $n \in \{1, \dots, N\}$: i. Draw a topic assignment $Z_{d,n} \sim \text{Multinomial}(\theta_d)$. ii. Draw a word $W_{d,n} \sim \text{Multinomial}(\beta_{Z_{d,n}})$. c. Draw a response variable $Y_d \sim \text{GLM}(\bar{z}_d, \eta, \delta)$, where $\bar{z}_d = \frac{1}{N} \sum_{n=1}^N Z_{d,n}$ is the empirical topic frequency.
Plate notation for supervised latent Dirichlet allocation (sLDA).

By using a Generalized Linear Model (GLM) framework, sLDA can accommodate various response types, including continuous values (Gaussian), counts (Poisson), or categories (Multinomial). The key innovation is that the response depends on the actual topics assigned to the words in the document (the empirical frequency), forcing the latent topics to be both descriptive of the text and predictive of the label. Because the posterior distribution is intractable, we employ variational Expectation-Maximization (EM) for parameter estimation.

Experimental Evaluation

We evaluated sLDA on two distinct real-world datasets:

  • Movie Reviews: A dataset of 5,006 reviews paired with star ratings. The objective was to predict the numerical rating based on the review text.
  • U.S. Senate Amendments: Textual data from amendments in the 109th and 110th Senates. The labels were "ideal point" parameters representing the political position (liberal-to-conservative) of each amendment derived from voting records.

Results and Discussion

Our experiments revealed that sLDA consistently outperforms "two-stage" modeling, where unsupervised LDA is performed first followed by a separate regression. By "tuning" topics for the prediction task from the outset, sLDA identifies latent structures that are more relevant to the response variable.

On the movie review data, sLDA achieved a predictive $R^2$ of 0.432, slightly outperforming the state-of-the-art Lasso regression (0.426). The gains were even more pronounced in the Senate data; for the 109th Senate, sLDA showed an 80% improvement over the Lasso (0.27 vs 0.15 $pR^2$). This suggests that when the relationship between text and label is complex or subtle, the latent structure discovered by sLDA is significantly more powerful than raw word counts.

Furthermore, sLDA provides better interpretability. In the Senate data, sLDA identified that specific topics like "health care" were strongly associated with right-wing positions in the 110th Senate, whereas an unsupervised model might have simply grouped them under a generic "policy" theme, losing the political signal.

Conclusion

Supervised LDA offers a robust framework for joint topic discovery and response prediction. While it is more computationally intensive than standard LDA due to the coupling of topic assignments and document-level responses, the predictive gains and improved interpretability make it a valuable tool for labeled text analysis. Future work includes extending the model to non-canonical link functions and exploring semi-supervised settings where the model learns from a mix of labeled and unlabeled data.

Summary updated

BibTeX
@inproceedings{blei2007supervised,
  author = {David M. Blei and Jon McAuliffe},
  title = {{Supervised Topic Models}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2007},
  url = {https://openreview.net/forum?id=SJbst8b_-B},
}
Figure