MLego: Interactive and Scalable Topic Exploration Through Model Reuse

Fei Ye, Jiapan Liu, Yinan Jing, Zhenying He, Weirao Wang, X. Sean WangarXiv 2025

TL;DR

MLego is an interactive query framework that drastically accelerates topic modeling by reusing and merging pre-trained models like Lego bricks instead of retraining them from scratch. By combining model materialization with hierarchical plan search and batch query optimization, it enables real-time, query-driven topic exploration on massive text datasets at interactive speeds.

What Problem Does This Paper Address?

Topic modeling—specifically Latent Dirichlet Allocation (LDA)—is a powerful tool for uncovering latent themes within massive text corpora, such as social media feeds or location-based reviews. However, training these models is computationally expensive and slow, often requiring hours even on distributed clusters.

This latency destroys the fluid interactivity required for Exploratory Data Analysis (EDA). For instance, if a travel analyst wants to repeatedly adjust geographical or temporal boundaries (e.g., comparing review topics "near the Louvre" versus "near Palais Garnier"), traditional systems force a complete model retraining cycle for every single ad-hoc modification. MLego addresses this bottleneck by eliminating the need to retrain from scratch for every query.

Methods

Instead of discarding models after a single use, MLego materializes and reuses them. When a user issues a query over a specific data range, MLego identifies existing sub-models that cover parts of that range, trains new models only for the uncovered data gaps, and merges them all together.

The framework introduces three core technical contributions:

  1. Model Merging Techniques: MLego supports order-independent model merging for two primary inference algorithms: Mean-field Variational Bayes (using a streaming, distributed Bayesian update framework) and Collapsed Gibbs Sampling (via Distributed Streaming Gibbs Sampling).
  2. Hierarchical Plan Search (PSOA/PSOA++): Finding the optimal combination of sub-models creates an exponential search space. MLego models this as a top-k optimization problem, utilizing a threshold algorithm to navigate a hierarchy of candidate plans while balancing performance loss against training time.
  3. Batch Query Optimization: For concurrent queries, MLego applies a heuristic reordering algorithm. It detects overlapping data ranges across multiple queries so that the underlying text segments are only trained once, maximizing shared computational benefits.

The overall system architecture is illustrated below:

Fig. 2. System architecture

Datasets

The authors evaluated MLego across six diverse real-world datasets:

  • PubMed & NYTimes: Standard topic modeling benchmarks representing short and long text profiles, respectively.
  • Amazon Fine Food Reviews, Wiki-movie-plot, & News Category: Datasets containing rich metadata attributes (time, ratings, categories) used to simulate OLAP and hierarchical query workloads.
  • Realnews: A massive dataset containing over 30 million documents, utilized specifically to test the framework's scalability.

Key Insights and Ideas

  • The Monotonicity of Merging: A foundational insight validated by the authors is that performance loss (measured via Log Predictive Probability) increases predictably and monotonically with the number of models merged. This mathematical behavior allows MLego to safely prune candidate plans using top-k threshold lists.
  • Shifting the Computational Bottleneck: When pre-trained model coverage is high (approaching 100%), the actual model merging takes only milliseconds. At this point, the bottleneck shifts entirely from model training to plan selection. This insight justifies the design of MLego's hierarchical plan search to keep query planning overhead negligible.
  • Query-Driven vs. User-Driven Analytics: While traditional visual analytics tools focus on letting users steer or visualize a single, statically pre-trained model, MLego enables a query-driven paradigm. The topic model itself is dynamically assembled on-the-fly based on the user's ad-hoc data filters.

Key Results

  • Substantial Speedups: MLego achieves orders-of-magnitude speedups in model construction time compared to training from scratch (ORIG) and significantly outperforms state-of-the-art distributed training systems like Tencent's LDA*.
  • Interactive Latency: When the query area is well-covered by existing materialized models, MLego delivers approximate topic models in milliseconds. Even at a modest 55% coverage ratio, MLego matches or beats baseline training efficiency.
  • Plan Search Efficiency: The proposed PSOA and PSOA++ algorithms demonstrate exponential speedups over naive plan enumeration (NAI), ensuring that the optimization process itself does not delay the user experience.

Limitations and Future Work

  • Algorithm Specificity: The current implementation and theoretical guarantees are tailored specifically to LDA. Extending this framework to modern deep-learning-based topic models (such as Neural Topic Models) remains an open challenge.
  • Simplified Cost Linearization: The framework relies on a linearized cost function combining time and performance loss. In highly heterogeneous production environments, more complex, non-linear cost models might be required to accurately predict training and merging overhead.

Summary updated

BibTeX
@misc{ye2025mlego,
  author = {Fei Ye and Jiapan Liu and Yinan Jing and Zhenying He and Weirao Wang and X. Sean Wang},
  title = {{MLego: Interactive and Scalable Topic Exploration Through Model Reuse}},
  year = {2025},
  eprint = {2508.07654},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.07654},
}
Figure