NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Semi-Supervised Prediction-Constrained Topic Models

Michael C. Hughes, Gabriel Hope, Leah Weiner, Thomas H. McCoy Jr., Roy H. Perlis, Erik B. Sudderth, Finale Doshi-VelezAISTATS 2018

Abstract

Supervisory signals can help topic models discover low-dimensional data representations which are useful for a specific prediction task. We propose a framework for training supervised latent Dirichlet allocation (sLDA) that treats prediction accuracy as a formal constraint. This Prediction-Constrained sLDA (PC-sLDA) forces the model to find topics that are predictive of labels even when the generative signal from the text is dominant or misspecified.

Introduction

Topic models like Latent Dirichlet Allocation (LDA) are widely used to extract interpretable themes from large text corpora. Supervised LDA (sLDA) extends this by incorporating labels to learn task-specific topics. However, sLDA often suffers from an "asymmetry" problem: the high dimensionality of text data (e.g., 1,000 words) overwhelms the sparse supervisory signal (e.g., one label). Consequently, the model prioritizes explaining the text over predicting the label. Furthermore, if the data violates LDA's "bag-of-words" assumptions, the learned topics may become irrelevant to the prediction task.

Methods: Prediction-Constrained Training

To address these issues, we introduce Prediction-Constrained (PC) training. Instead of maximizing the joint likelihood $p(\text{words}, \text{labels})$, we maximize the marginal likelihood of the words $p(\text{words})$ subject to a constraint on the predictive accuracy $p(\text{labels} | \text{words})$.

Using Karush-Kuhn-Tucker (KKT) conditions, we reformulate this as an unconstrained objective weighted by a scalar $\lambda$: $$\mathcal{L} = \log p(\text{words}) + \lambda \log p(\text{labels} | \text{words})$$ The $\lambda$ parameter allows for tuning the balance between data explanation and predictive power.

Effect of the $\lambda$ constraint on learned topics in the toy bars dataset. Higher $\lambda$ values force the model to ignore dominant but irrelevant patterns (bars) to find the predictive signal.

To ensure tractability, we use a Maximum A Posteriori (MAP) embedding of the topic distribution, calculated via an Exponentiated Gradient algorithm. Since this embedding is differentiable, the entire model can be optimized end-to-end using stochastic gradient descent.

Key Insights

A critical observation is that standard sLDA assumes labels are available during training to help explain words, a condition that does not hold at test time. PC-sLDA explicitly models the "words-to-labels" pipeline used during prediction, making it more robust.

Comparison of generative vs. predictive log-likelihoods in train and predict modes. PC-sLDA (red/orange) maintains low predictive loss across both modes.

Furthermore, the generative term $p(\text{words})$ allows the model to leverage unlabeled data (semi-supervision), which is particularly effective when labeled data is scarce (e.g., 5-10% of the corpus).

Experimental Results

We evaluated PC-sLDA across synthetic and real-world datasets:

  • Toy Bars: PC-sLDA was the only model to successfully ignore prominent bar patterns to identify the specific "signal" pixel required for prediction.
  • Text Classification: On Movie and Yelp reviews, PC-sLDA achieved accuracy comparable to high-dimensional Logistic Regression while maintaining topic interpretability. It significantly outperformed other supervised variants like MedLDA and BP-sLDA in low-label regimes.
  • Clinical EHR: In predicting antidepressant success from EHR codes, PC-sLDA discovered clinically relevant topics (e.g., "behavioral counseling") that generic models missed.

Conclusion

PC-sLDA provides a robust framework for supervised topic modeling by treating prediction as a constraint. This approach mitigates the swamping effect of large text data and improves performance under model misspecification. Future work includes applying this constraint-based framework to other latent variable models like Variational Autoencoders.

Summary updated

BibTeX
@inproceedings{hughes2018semi,
  author = {Michael C. Hughes and Gabriel Hope and Leah Weiner and Thomas H. McCoy Jr. and Roy H. Perlis and Erik B. Sudderth and Finale Doshi-Velez},
  title = {{Semi-Supervised Prediction-Constrained Topic Models}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2018},
  url = {https://openreview.net/forum?id=9ani9M17tZ},
}
Figure