Topic Compositional Neural Language Model

Wenlin Wang, Zhe Gan, Wenqi Wang, Dinghan Shen, Jiaji Huang, Wei Ping, Sanjeev Satheesh, Lawrence Carin

Abstract

We propose a Topic Compositional Neural Language Model (TCNLM), a novel method designed to simultaneously capture both the global semantic meaning and the local word-ordering structure in a document. By combining a neural topic model with a recurrent neural network (RNN) through a factorized "Mixture-of-Experts" approach, the model captures both the "forest" (document-level semantics) and the "trees" (grammatical structure), leading to state-of-the-art text generation and lower perplexity.

Introduction

Traditional Recurrent Neural Networks (RNNs) are the workhorses of language modeling, but they suffer from a "short-term memory" problem. While they excel at predicting the next word based on immediate preceding context, they often lose track of the broader document's theme. For example, an RNN might generate a grammatically perfect sentence about "cooking" in the middle of a document about "quantum physics" because it lacks a global semantic compass.

Previous attempts to fix this—like feeding a topic vector into an RNN—often struggled with efficiency or failed to integrate the two tasks into a single, cohesive training process. The TCNLM addresses this by using global topics to directly influence the local word-prediction weights through a unified architecture.

Architecture and Methodology

The TCNLM consists of two primary components trained jointly under a Variational Autoencoder (VAE) framework:

Overview of the TCNLM architecture showing the joint Neural Topic Model and Neural Language Model.
  1. Neural Topic Model (NTM): This component looks at the document as a "bag-of-words" and maps it to a latent topic distribution ($t$). Unlike classical LDA, this uses a neural network to parameterize the distributions, making it more flexible and easier to train with backpropagation.
  2. Neural Language Model (NLM): This is an LSTM-based model using a Mixture-of-Experts (MoE) design. Each "expert" corresponds to a specific topic. The final weights used to predict the next word are a weighted combination of these experts, where the weights are determined by the document's topic distribution ($t$).

Matrix Factorization Innovation

Running separate LSTMs for every topic would be computationally prohibitive. To solve this, the authors used matrix factorization, decomposing large weight tensors into three smaller matrices ($W_a, W_b, W_c$). This allows the model to share "linguistic structure" across all topics while letting topic-specific factors ($W_b$) shift the model's behavior based on the theme. This factorization also acts as a form of regularization, forcing the model to find common patterns and preventing overfitting.

Experimental Evaluation

The authors evaluated their model on three diverse corpora:

  • APNEWS: Associated Press news articles (2009–2016).
  • IMDB: Movie reviews, which are highly subjective and thematic.
  • BNC (British National Corpus): A broad collection of written English from journals, books, and letters.

Key Results

  • Perplexity (PPL): TCNLM consistently achieved lower perplexity than standard LSTMs and previous state-of-the-art models like Topic-RNN across all three datasets.
  • Topic Coherence: Using the Normalized Pointwise Mutual Information (NPMI) metric, the TCNLM produced more coherent and meaningful topics than standard neural topic models.
Topic distribution for a sample from the IMDB dataset.
  • Efficiency: The factorized MoE approach outperformed naive implementations while using significantly fewer parameters and less computational power.
  • Qualitative Success: The model successfully generated sentences that were both grammatically correct and tightly coupled to their assigned topics (e.g., generating "the taliban's presence has earned a degree..." when prompted with "Army + Terrorism" topics).

Conclusion and Future Work

The TCNLM effectively bridges local syntax and global semantics. However, the authors noted that as RNNs scale in power, they may begin to ignore topic guidance in favor of local patterns. Future work could adapt this architecture for Machine Translation, where document-level context could help resolve ambiguous word meanings. While powerful, the model remains more complex to tune than standard LSTMs, particularly regarding the diversity regularizer used to ensure sharp, interpretable topics.

Summary updated

BibTeX
@inproceedings{wang2018topic,
  author = {Wenlin Wang and Zhe Gan and Wenqi Wang and Dinghan Shen and Jiaji Huang and Wei Ping and Sanjeev Satheesh and Lawrence Carin},
  title = {{Topic Compositional Neural Language Model}},
  booktitle = {International Conference on Artificial Intelligence and Statistics},
  year = {2018},
  url = {https://openreview.net/forum?id=3aEP8bIeRv},
}
Figure