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

Probabilistic Topic Modelling with Transformer Representations

Arik Reuter, Anton Thielmann, Christoph Weisser, Benjamin Säfken, Thomas KneibarXiv 2024

Abstract

Topic modelling was mostly dominated by Bayesian graphical models during the last decade. With the rise of transformers in Natural Language Processing, however, several successful models that rely on straightforward clustering approaches in transformer-based embedding spaces have emerged and consolidated the notion of topics as clusters of embedding vectors. We propose the Transformer-Representation Neural Topic Model (TNTM), which combines the benefits of topic representations in transformer-based embedding spaces and probabilistic modelling. Therefore, this approach unifies the powerful and versatile notion of topics based on transformer embeddings with fully probabilistic modelling, as in models such as Latent Dirichlet Allocation (LDA). We utilize the variational autoencoder (VAE) framework for improved inference speed and modelling flexibility. Experimental results show that our proposed model achieves results on par with various state-of-the-art approaches in terms of embedding coherence while maintaining almost perfect topic diversity. The corresponding source code is available at https://github.com/ArikReuter/TNTM.

Introduction

Topic modeling has traditionally been divided between two paradigms. Bayesian graphical models, such as Latent Dirichlet Allocation (LDA), offer a rigorous probabilistic framework but are limited by "Bag-of-Words" (BoW) representations that ignore semantic context. Conversely, modern clustering-based approaches (e.g., BERTopic) leverage powerful transformer embeddings but often lack a formal generative process, relying instead on heuristics.

The Transformer-Representation Neural Topic Model (TNTM) bridges this gap by unifying the structural rigor of probabilistic modeling with the semantic richness of transformer-based embeddings. By modeling topics as multivariate Gaussian distributions in a reduced transformer embedding space, TNTM achieves state-of-the-art topic coherence and maintains near-perfect topic diversity, even when scaled to hundreds of topics.

Methodology

TNTM introduces several key innovations to integrate probabilistic modeling with high-dimensional transformer spaces.

High-level architecture of the TNTM framework, illustrating the flow from corpus to topic distributions and parameters.

Contextualized Representations and Dimensionality Reduction

The model uses BERT to generate embeddings for every word in a corpus. To create a global vocabulary, contextual embeddings of the same word are averaged into a single representative vector. To combat the "curse of dimensionality," TNTM employs UMAP to project these embeddings into a lower-dimensional space (typically 15 dimensions), facilitating stable clustering and probabilistic modeling.

Gaussian Topic Modeling

Unlike LDA's discrete distributions over a fixed vocabulary, TNTM models each topic as a multivariate normal distribution $\mathcal{N}(\mu, \Sigma)$ within the embedding space. This allows the model to treat topics as continuous regions of semantic space. To avoid local minima, topic parameters are initialized using a Gaussian Mixture Model (GMM) fitted to the UMAP-reduced embeddings.

VAE Inference Framework

TNTM utilizes a Variational Autoencoder (VAE) for efficient inference. The encoder maps a document—represented either as BoW or via SBERT embeddings—to a topic distribution. By replacing the standard Dirichlet prior with a logistic-normal prior, the model leverages the "reparameterization trick," making it compatible with standard deep learning optimization.

The VAE inference framework for document-level topic assignment and reconstruction.

To ensure numerical stability during training, the authors implement mathematical optimizations such as log-sum-exp and log-softmax operations to prevent numerical underflow.

Experimental Results

The model was evaluated on the 20 Newsgroups and Reuters-21578 datasets against twelve baseline models, including LDA, ETM, and BERTopic.

Superior Coherence and Diversity

TNTM consistently outperformed baselines in Embedding Coherence, a metric measuring the cosine similarity of top-word embeddings. The authors argue this is more representative of human judgment than traditional NPMI for neural models.

Notably, TNTM demonstrates exceptional robustness to scale. While models like ETM often suffer from "component collapsing" at high topic counts, TNTM maintained a Topic Diversity score of 0.938 with 200 topics on the 20 Newsgroups dataset, compared to ETM's 0.006 and LDA's 0.568.

Encoder Flexibility

The use of SBERT document embeddings in the VAE encoder provided a small but consistent performance boost over simple BoW encoders, indicating that document-level context significantly aids accurate topic assignment.

Conclusion

TNTM successfully unifies transformer-based semantic representations with the formal generative processes of probabilistic topic modeling. By addressing numerical stability and leveraging the flexibility of VAEs, it provides a scalable and coherent alternative to both traditional Bayesian models and modern heuristic clustering approaches. Future work may explore more sophisticated VAE variants and the application of TNTM to short, sparse texts where traditional models often fail.

Summary updated

BibTeX
@misc{reuter2024probabilistic,
  author = {Arik Reuter and Anton Thielmann and Christoph Weisser and Benjamin Säfken and Thomas Kneib},
  title = {{Probabilistic Topic Modelling with Transformer Representations}},
  year = {2024},
  eprint = {2403.03737},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2403.03737},
}
Figure