Introduction
Topic modeling is a fundamental task in natural language processing used to discover latent themes within large-scale text collections. However, existing methodologies often encounter a "Goldilocks" problem. Traditional Neural Topic Models (NTMs) are computationally efficient and provide a global view of the corpus, but they frequently produce noisy, overly general, or semantically ambiguous word clusters. Conversely, pure Large Language Model (LLM) approaches offer superior semantic coherence but are computationally ruinous at the document level and often fail to capture a consistent global perspective across an entire dataset.
This paper presents LLM-ITL (LLM-in-the-loop), a novel framework designed to bridge the gap between the global efficiency of NTMs and the semantic "common sense" of LLMs. By integrating an LLM into the NTM training process through an Optimal Transport-based alignment and a confidence-weighted refinement loop, the framework produces highly interpretable topics and labels while remaining orders of magnitude more efficient than document-level LLM analysis.
Methodology
The core of the LLM-ITL framework is its modular design, which augments existing NTM architectures rather than replacing them. The system utilizes a standard Variational Auto-Encoder (VAE) based topic model to learn document representations and global word distributions.
The workflow proceeds through several distinct phases:
- LLM-based Topic Suggestion: Periodically, the top words from the NTM's topics are sent to an LLM (e.g., Llama-3). Utilizing Chain-of-Thought (CoT) prompting, the LLM suggests a concise label and a "refined" set of words that better represent the underlying concept.
- OT-based Topic Alignment: This serves as the mathematical "glue" of the system. The authors employ Optimal Transport (OT) to align the NTM’s raw word distribution with the LLM’s refined suggestions. OT is particularly effective here as it measures the "cost" of transforming one distribution into another, even when the word sets do not perfectly overlap.
- Confidence-Weighted Refinement: To prevent the LLM from "hallucinating" or imposing irrelevant external knowledge, the model calculates a confidence score. This score considers Label Token Probability (the LLM's certainty) and Word Intrusion (the ratio of words the LLM discarded as irrelevant). If confidence is low, the LLM’s influence is automatically reduced.
- Warm-up Phase: The NTM is allowed to train independently for an initial period to capture the core structural properties of the corpus before the LLM-driven refinement begins.
Experimental Setup
The authors evaluated the LLM-ITL framework on four widely-used benchmark datasets: 20Newsgroup (20News) and Reuters-21578 (R8) for long-form documents, and DBpedia and AGNews for short-form text. To demonstrate the framework's modularity and broad applicability, it was integrated with eight different base NTMs, including NVDM, ETM, and SCHOLAR.
Results
The integration of LLM-ITL resulted in significant performance gains across all evaluated datasets and base models. The framework consistently improved both the interpretability of topics and the quality of document representations.
Key results include:
- Interpretability Boost: LLM-ITL significantly improved Topic Coherence ($C_V$). For instance, when applied to the ECRTM model on the 20News dataset, coherence increased by 70.6%.
- Preserving Representation: A critical concern in topic refinement is maintaining the model's ability to represent documents accurately. LLM-ITL maintained or slightly improved Topic Alignment (PN), indicating that the document-to-topic mappings remained high-quality.
- Efficiency Gains: By prompting the LLM only for topics (e.g., 50 topics) rather than every document, the framework reduces computational overhead from $O(N_{documents})$ to $O(K_{topics})$, making it viable for massive datasets.
- Superiority over Pure LLMs: On long-document datasets, LLM-ITL outperformed pure LLM-based models like TopicGPT in topic alignment, suggesting that the NTM's global view is superior to the LLM's local view for complex documents.
Discussion and Conclusion
LLM-ITL demonstrates that incorporating LLMs into the training loop of NTMs can drastically improve topic quality without the prohibitive costs associated with document-level LLM processing. While the framework introduces some latency and carries a potential risk of out-of-corpus bias, the use of confidence-weighted refinement and OT-based alignment provides effective safeguards. Future research will focus on enhancing the system's ability to handle significant divergences between the input corpus and the LLM’s pre-trained world model.
Summary updated