Memory-Efficient Topic Modeling

Jia Zeng, Zhi-Qiang Liu, Xiao-Qin CaoarXiv 2012

Abstract

Latent Dirichlet Allocation (LDA) is a fundamental tool for discovering latent themes in large text corpora. However, traditional inference algorithms like Variational Bayes (VB) and Loopy Belief Propagation (BP) face significant scalability challenges due to their high memory consumption, which scales linearly with the number of topics and word occurrences. This paper introduces Tiny Belief Propagation (TBP), a memory-efficient algorithm that eliminates the need to store intermediate messages. By establishing a mathematical link between message-passing and Non-negative Matrix Factorization (NMF), TBP reduces message memory to zero, enabling the processing of massive datasets on standard consumer hardware without sacrificing predictive accuracy.

Introduction

As datasets grow to encompass millions of documents and thousands of topics, the memory bottleneck of standard LDA training becomes critical. State-of-the-art algorithms typically rely on a message-passing framework. To update model parameters, these methods must store and update "messages"—intermediate probability distributions—for every word occurrence in the corpus. For a large-scale model with hundreds of topics, this requirement can easily exceed 30GB of RAM, far surpassing the capacity of typical desktop computers.

Methodology: Tiny Belief Propagation

The proposed Tiny Belief Propagation (TBP) algorithm addresses this bottleneck through a novel approach to message handling called message absorption.

Message Approximation and Absorption

In standard BP, a message $\mu_{w,d,n}(k)$ is stored for each token $n$ of word $w$ in document $d$. TBP replaces these individual messages with an approximation derived from the current global topic distributions ($\phi$) and document-specific topic proportions ($\theta$).

Conceptual transition from standard Belief Propagation (A) to the approximated and absorbed messages in TBP (C).

As illustrated in the figure above, standard BP (A) tracks specific assignments. TBP moves toward an aggregated view (B) and finally to an approximated state (C) where the "message" is reconstructed on the fly from global parameters. This "absorption" means that the algorithm no longer needs to dedicate memory to storing previous states of word-topic assignments.

The NMF Connection

A key theoretical contribution of this work is demonstrating that LDA training under this approximation is mathematically equivalent to Non-negative Matrix Factorization (NMF) using Kullback-Leibler (KL) divergence. By stripping away complex Bayesian hyperparameters, the authors show that the update rules for TBP mirror the multiplicative updates used in NMF. This bridge allows LDA to benefit from the efficiency of matrix factorization techniques while retaining its probabilistic interpretability.

Experimental Results

The authors evaluated TBP against Variational Bayes (VB), Gibbs Sampling (GS), and standard BP across several large datasets, including ENRON, NYTimes, Wikipedia, and a 7GB version of the PubMed corpus.

Memory and Hardware Efficiency

The most striking result is the memory reduction. For a model with 100 topics, while VB and BP required over 1.4 GB of message memory, TBP required 0 MB. This gap widens significantly as the number of topics increases. This efficiency allowed the researchers to train a 10-topic model on the 7GB PubMed dataset using a machine with only 2GB of RAM—a task impossible for traditional BP or GS without specialized high-memory hardware.

Accuracy and Speed

TBP does not trade accuracy for efficiency. In terms of predictive perplexity, TBP consistently outperformed Variational Bayes and matched or exceeded the performance of Gibbs Sampling and standard BP. Furthermore, TBP avoids the computationally expensive digamma functions required by VB, maintaining a training speed competitive with the fastest existing implementations.

Conclusion

Tiny Belief Propagation represents a significant step forward in making large-scale topic modeling accessible. By eliminating the memory overhead of message passing through a clever approximation and NMF-based reformulation, TBP allows researchers to handle massive corpora on modest hardware. Future work may extend this "message absorption" principle to more complex hierarchical Bayesian models, potentially revolutionizing resource-constrained machine learning across various domains.

Summary updated

BibTeX
@misc{zeng2012memory,
  author = {Jia Zeng and Zhi-Qiang Liu and Xiao-Qin Cao},
  title = {{Memory-Efficient Topic Modeling}},
  year = {2012},
  eprint = {1206.1147},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1206.1147},
}
Figure