Learning from LDA using Deep Neural Networks

Dongxu Zhang, Tianyi Luo, Dong Wang, Rong Liu · DOI

Abstract

Latent Dirichlet Allocation (LDA) is a three-level hierarchical Bayesian model for topic inference. In spite of its great success, inferring the latent topic distribution with LDA is time-consuming. Motivated by the transfer learning approach proposed by Hinton et al. (2015), we present a novel method that uses LDA to supervise the training of a deep neural network (DNN), so that the DNN can approximate the costly LDA inference with less computation. Our experiments on a document classification task show that a simple DNN can learn the LDA behavior pretty well, while the inference is speeded up tens or hundreds of times.

Introduction

Latent Dirichlet Allocation (LDA) has long been a cornerstone of unsupervised topic modeling, providing high-quality semantic representations of document collections. However, its practical application in large-scale, real-time environments is hindered by significant computational overhead during inference. Calculating topic distributions for new documents requires iterative approximation methods like variational inference or Gibbs sampling, which are too slow for high-throughput online applications.

This paper proposes a "knowledge distillation" framework to bridge this gap. By treating a complex, pre-trained LDA model as a "teacher" and a fast Deep Neural Network (DNN) as a "student," we can transfer the semantic discovery capabilities of the Bayesian model into a high-speed neural architecture.

Methodology

The core idea is to use the output of an LDA model to supervise the training of a DNN.

  1. Teacher Model: A standard LDA model is trained on a corpus. For each document $d$, it generates a topic mixture $\theta(d)$, representing the probability distribution across $K$ topics.
  2. Student Model: A DNN (either DNN-2L with one hidden layer or DNN-3L with two) takes the raw Term Frequency (TF) vector of a document as input.
  3. Distillation Process: Instead of training the DNN on discrete class labels, it is trained to minimize the Cross-Entropy loss between its output and the teacher's $\theta(d)$. This allows the DNN to learn the "dark knowledge"—the subtle relationships between topics—captured by the LDA model.
  4. Architecture: The models use hyperbolic tangent (tanh) activations and a softmax output layer to produce a valid probability distribution.

Experimental Setup

The approach was evaluated on two standard text benchmarks: Reuters-21578 (55 classes) and 20 Newsgroups (20 classes). The researchers focused on "long documents" to ensure the LDA teacher provided high-quality supervision. Performance was measured by using the inferred topic vectors as features for an SVM classifier.

Results and Discussion

Accuracy and Approximation

The DNN student models successfully approximated the LDA teacher's performance. As shown in the accuracy plots, both DNN-2L and DNN-3L achieved classification accuracies nearly identical to the original LDA across different topic counts. Notably, all LDA-based models significantly outperformed Principal Component Analysis (PCA), indicating that the DNNs effectively captured the non-linear semantic structures discovered by the Bayesian process.

Accuracy comparison on Reuters-21578 and 20 Newsgroups datasets.

Computational Efficiency

The primary advantage of the DNN approach is inference speed. The DNN models achieved speedups ranging from 10x to 200x compared to standard LDA inference. This speed advantage scales with the complexity of the topic space; as the number of topics increases, the relative efficiency of the DNN becomes even more pronounced.

Speedup ratio of DNN models compared to LDA inference across different topic counts.

Qualitative Insights

Beyond quantitative metrics, qualitative analysis revealed that the DNN's hidden layers performed hierarchical feature discovery. Individual neurons were found to activate for clusters of semantically related words (e.g., "gold," "copper," "mine"), suggesting that the network internally reconstructs the concept of "topics" even without explicit symbolic guidance.

Conclusion and Future Work

This research demonstrates that deep neural networks can efficiently mimic complex Bayesian inference processes. While the DNN's performance may slightly lag when training data is sparse relative to a very high-dimensional topic space, the massive gains in inference speed make it a compelling choice for real-time applications. Future work could involve applying this distillation technique to more complex probabilistic models or using Bayesian priors to improve the interpretability of neural networks.

Summary updated

BibTeX
@misc{zhang2015learning,
  author = {Dongxu Zhang and Tianyi Luo and Dong Wang and Rong Liu},
  title = {{Learning from LDA using Deep Neural Networks}},
  year = {2015},
  eprint = {1508.01011},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1508.01011},
}
Figure