Topic Modeling for Short Texts with Large Language Models

Tomoki Doi, Masaru Isonuma, Hitomi YanakaStudent Research Workshop @ ACL 2024

Abstract

Topic modeling for short texts, such as tweets or news headlines, has long been a challenge due to data sparsity. Traditional statistical models like Latent Dirichlet Allocation (LDA) rely on word co-occurrence, which is often insufficient in brief documents. This paper introduces two novel prompting strategies—parallel and sequential—to leverage the semantic "world knowledge" of Large Language Models (LLMs) for this task. Our evaluation across three standard datasets shows that GPT-4 significantly outperforms traditional and neural topic models in coherence, producing more distinct and human-readable topics while maintaining high factuality.

Introduction

Traditional topic modeling techniques struggle with short texts because these documents contain very few words, leading to a lack of statistical overlap between related texts. While neural topic models like BERTopic have improved the situation, they still often produce "noisy" or overlapping topics. Large Language Models (LLMs) offer a potential solution because they understand context and semantic relationships learned during pre-training, rather than just counting words. The primary challenge lies in applying LLMs to large document sets that exceed their finite context windows.

Methodology

To handle large document sets, we propose two main workflows:

  1. Parallel Prompting: The document set is split into smaller subsets. The LLM identifies topics for each subset independently. Finally, a "merging" prompt is used where the LLM synthesizes all sub-topics into a final global set.
  2. Sequential Prompting: The LLM processes subsets one by one. In each step, it is provided with the current subset's documents and the topics identified from all previous subsets, with instructions to update the list as it encounters new information.
Overview of Parallel and Sequential prompting workflows for topic modeling.

We tested these methods using GPT-3.5 and GPT-4, refining prompts with specific "Goal" and "Detail" instructions to ensure the models remained focused on synthesis and updating rather than mere repetition.

Experimental Setup

The study evaluated these methods on three standard short-text datasets: Tweet (2,000 documents), GoogleNewsT (11,000 headlines), and StackOverFlow (19,000 technical questions). Beyond standard coherence ($C_v$) and diversity ($TU$) metrics, we introduced Document Coverage (DC) to measure representation and Factuality (Fa) to check for hallucinations.

Key Results and Insights

Our results demonstrate that GPT-4 achieves a coherence score ($C_v$) up to 40% higher than the best baseline models, such as BERTopic or TSCTM. Qualitatively, GPT-4 successfully separated complex clusters—such as a mixed "celebrity/holiday/gaming" cluster—into distinct, highly consistent topics.

Comparison of coherence (Cv) and topic uniqueness (TU) across models and datasets.

Parallel vs. Sequential Prompting

Parallel prompting consistently proved superior to sequential prompting. In the sequential approach, the LLM tended to "anchor" to the first set of topics it encountered and was hesitant to update them significantly, leading to lower document coverage. Parallel prompting avoids this bias by allowing independent topic extraction before a final synthesis phase.

Semantic Reasoning and Factuality

LLMs succeed where LDA fails because they recognize semantic clusters (e.g., "Kanye West" and "Kim Kardashian") even if the terms do not co-occur in the same short text. Furthermore, hallucination was found to be a non-issue; factuality scores remained above 95%. When LLMs did introduce new words, they were almost always synonyms or derivatives of words present in the original text.

Limitations and Future Work

Despite superior coherence, LLMs exhibited lower Document Coverage ($DC$) than traditional models, suggesting they may "cherry-pick" salient topics while ignoring obscure ones. Additionally, current workflows do not assign specific topics back to individual documents, and the cost of high-end APIs remains a barrier for massive datasets. Future research will focus on automated topic assignment and scaling these methods efficiently.

Summary updated

BibTeX
@inproceedings{doi2024topic,
  author = {Tomoki Doi and Masaru Isonuma and Hitomi Yanaka},
  title = {{Topic Modeling for Short Texts with Large Language Models}},
  booktitle = {Student Research Workshop @ ACL},
  year = {2024},
  doi = {10.18653/v1/2024.acl-srw.3},
}
Figure