Topic Analysis for Text with Side Data

Biyi Fang, Kripa Rajshekhar, Diego Klabjan · DOI

Abstract

Traditional topic modeling often ignores auxiliary metadata, or "side data," which can provide crucial context for document themes. We present nnLDA, a hybrid model that replaces the static Dirichlet prior of Latent Dirichlet Allocation (LDA) with a dynamic prior generated by a neural network. This architecture allows the model to capture non-linear relationships between metadata and topics. Experiments across five datasets demonstrate that nnLDA outperforms traditional LDA and Dirichlet-multinomial regression (DMR) in perplexity, classification accuracy, and human-perceived coherence.

Introduction

Topic modeling serves as a cornerstone for the unsupervised discovery of latent themes within large text corpora. Latent Dirichlet Allocation (LDA), the most prominent of these models, assumes a generative process where documents are mixtures of topics. However, a significant limitation of standard LDA is its inability to leverage "side data"—the rich metadata such as timestamps, geographic locations, or product categories that frequently accompany text. While models like Dirichlet-multinomial regression (DMR) attempt to incorporate this metadata, they often rely on simple linear projections that fail to capture complex, non-linear interactions between diverse features. This paper introduces nnLDA, a hybrid approach that integrates Deep Neural Networks (DNNs) into the LDA framework to dynamically generate topic priors based on document metadata.

The nnLDA Framework

The core innovation of nnLDA (hybrid neural network LDA) is the transformation of the document-topic prior. In standard LDA, the Dirichlet parameter $\alpha$ is a fixed hyperparameter. In nnLDA, $\alpha_d$ is a document-specific vector generated by a two-layer fully connected neural network.

The Generative Process

For every document, the neural network "looks" at the side data (input as one-hot encoded features) and suggests a specific topic distribution prior. The document then samples its topics based on this customized suggestion. This "upstream" approach allows the model to steer the topic discovery process; for example, if the side data indicates a review is about a "Burger," the model is primed to look for food-related topics rather than electronics.

Training and Inference

The authors developed an efficient Variational Expectation-Maximization (EM) algorithm for model training. In the E-step, the model estimates topic assignments for the words in the corpus. In the M-step, backpropagation is used to optimize the neural network's weights alongside the standard topic-word distributions. Crucially, the paper provides a mathematical proof showing that nnLDA's log-likelihood lower bound is guaranteed to be at least as good as (or better than) plain LDA for any dataset, provided the neural network is sufficiently expressive.

Experimental Evaluation

The model was evaluated on five distinct datasets, ranging from synthetic samples with known ground-truth topic groups to large-scale real-world feedback (the RR dataset with 10,000 samples).

Key Results

  • Perplexity: In almost all real-world datasets, nnLDA achieved lower perplexity—a measure of how well the model predicts a sample—than both LDA and DMR. As the number of topics increased, LDA's performance often deteriorated, while nnLDA remained stable.
  • Classification: Using the discovered topics to predict user ratings, nnLDA outperformed competitors. On the DCL dataset, nnLDA showed a dramatic improvement in F1 scores compared to the baseline.
  • Topic Grouping Clarity: On synthetic data, nnLDA was the only model able to clearly separate "seed topics." While LDA and DMR produced vague word clusters, nnLDA's clusters were highly distinguishable and aligned perfectly with the metadata categories.
  • Human Evaluation: A blind study involving 50 PhD students compared comments generated by the different models. For the WIP dataset, nnLDA generated "more reasonable" comments 26% more often than plain LDA and 20% more often than DMR.

Discussion and Limitations

While nnLDA offers superior flexibility over the linear link functions used in models like DMR, it does come with a marginal computational cost. The authors note that nnLDA is slightly slower to train (less than 10% slower) due to the backpropagation required for the neural network parameters. Furthermore, the model's performance boost is directly tied to the quality of the side data; if the metadata is noisy or irrelevant, the improvements over standard LDA may be minimal.

Conclusion

nnLDA represents a significant step forward in making topic models more context-aware. By bridging the gap between probabilistic topic modeling and deep learning, it provides a robust framework for metadata-aware text analysis. Future work may explore more complex architectures, such as Convolutional Neural Networks (CNNs) or Transformers, to process more complex side data types like images or sequential metadata.

Summary updated

BibTeX
@misc{fang2022topic,
  author = {Biyi Fang and Kripa Rajshekhar and Diego Klabjan},
  title = {{Topic Analysis for Text with Side Data}},
  year = {2022},
  eprint = {2203.00762},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2203.00762},
}
Figure