Pre-training is a Hot Topic: Contextualized Document Embeddings Improve Topic Coherence

Federico Bianchi, Silvia Terragni, Dirk Hovy

Introduction

Traditional topic modeling has long relied on the Bag-of-Words (BoW) assumption, which treats documents as unordered collections of tokens. While computationally efficient, this approach ignores the rich semantic and syntactic context inherent in natural language. Consequently, BoW-based models often struggle with polysemy (e.g., distinguishing "Apple" the corporation from "apple" the fruit) and fail to capture relationships between semantically similar but distinct words unless they frequently co-occur. This often results in incoherent topics that lack human interpretability.

To address these limitations, this work introduces CombinedTM, a neural topic model that bridges the gap between traditional statistical modeling and modern contextualized representations. By augmenting standard BoW inputs with embeddings from pre-trained language models like SBERT, CombinedTM significantly enhances the coherence and diversity of discovered topics.

Methodology: The CombinedTM Architecture

CombinedTM is built upon the framework of Neural ProdLDA, a Variational Autoencoder (VAE) designed for topic modeling. The primary innovation lies in the model's dual-input encoding strategy.

Architecture of the CombinedTM model, integrating contextualized embeddings with Bag-of-Words representations.

As illustrated in Figure 1, the model processes two distinct representations of a document:

  1. Bag-of-Words (BoW): A standard vector representing word frequencies.
  2. Contextualized Embeddings: A high-dimensional vector generated by SBERT (Sentence-BERT), which captures the semantic essence of the document.

The contextualized embedding is passed through a hidden layer to align its dimensionality with the vocabulary space before being concatenated with the BoW vector. This combined representation is then fed into the VAE's encoder to produce a latent topic distribution. During training, the decoder attempts to reconstruct the original BoW representation from this latent space. This "agnostic" architecture allows researchers to easily swap the underlying topic model or the pre-trained language model (e.g., BERT, RoBERTa) based on specific needs.

Experimental Setup

The model was evaluated across five diverse datasets to test its robustness in different linguistic contexts:

  • 20Newsgroups: A standard benchmark for document classification.
  • Wiki20K: Abstracts from English Wikipedia.
  • StackOverflow: Short, technical domain-specific text.
  • Tweets2011: Noisy, extremely short social media posts.
  • Google News: Brief news snippets.

Key Results and Discussion

The performance of CombinedTM was compared against several established baselines, including standard LDA, Neural Variational Document Model (NVDM), Embedded Topic Model (ETM), and MetaLDA. Performance was measured using Topic Coherence ($\tau$, specifically NPMI) and Topic Diversity ($\rho$).

Comparative performance across five datasets on coherence (tau), alpha, and diversity (rho) metrics.

As shown in Figure 4, CombinedTM achieved superior topic coherence ($\tau$) on four out of the five datasets. Notably, on the Google News dataset, it reached a coherence score of 0.1207, significantly outperforming the next best model, MLDA (0.0849). The model also demonstrated remarkable success on short-text datasets like Tweets and StackOverflow, where traditional models often fail due to sparse word co-occurrence.

Beyond coherence, CombinedTM maintained high topic diversity ($\rho$), ensuring that the discovered topics were distinct and representative of the entire corpus rather than converging on a few "safe" clusters. The results suggest a strong synergy between language model quality and topic modeling performance: as the underlying embeddings improve (e.g., using RoBERTa fine-tuned for semantic tasks), the resulting topics become increasingly coherent.

Conclusion and Future Directions

CombinedTM demonstrates that contextualization is a "secret sauce" for modern topic modeling. By leveraging the latent knowledge of pre-trained LLMs during the encoding phase, the model creates a more meaningful latent space for document clustering.

However, some limitations remain. Current SBERT architectures typically have a 512-token limit, which may lead to information loss in very long documents. Additionally, the computational cost is slightly higher than pure BoW models due to the overhead of processing embedding vectors. Future research could explore decoders that reconstruct contextual features rather than just BoW, or utilize generative LLMs to provide natural language descriptions of the discovered topics.

Summary updated

BibTeX
@inproceedings{bianchi2021pre,
  author = {Federico Bianchi and Silvia Terragni and Dirk Hovy},
  title = {{Pre-training is a Hot Topic: Contextualized Document Embeddings Improve Topic Coherence}},
  booktitle = {Annual Meeting of the Association for Computational Linguistics},
  year = {2021},
  doi = {10.18653/v1/2021.acl-short.96},
}
Figure