Text Clustering as Classification with LLMs

Chen Huang, Guoxiu He

TL;DR

This paper introduces a novel approach to text clustering that reframes it as a classification task, leveraging the in-context learning capabilities of Large Language Models (LLMs). By eliminating the need for fine-tuning embeddings or complex clustering algorithms, their method achieves competitive or superior performance while significantly reducing computational complexity and improving interpretability.

What Problem Does This Paper Address?

Text clustering is a crucial technique for organizing large amounts of unstructured text, especially when manual labeling is infeasible. Traditional methods often rely on transforming text into numerical embeddings and then applying algorithms like K-means or DBSCAN. However, these approaches face several challenges:

  • Computational Intensity: Fine-tuning embedding models for specific domains is expensive and requires labeled data.
  • Hyperparameter Sensitivity: Clustering algorithms often need careful manual tuning of parameters like the number of clusters and distance metrics.
  • Lack of Interpretability: The resulting clusters are often difficult to understand as they don't come with meaningful labels.

While recent work has explored using LLMs for text clustering, many still depend on external embedding models and traditional clustering techniques, inheriting their limitations. This paper aims to overcome these issues by proposing a purely LLM-driven approach that simplifies the process and enhances interpretability.

Methods

The proposed framework transforms text clustering into a two-stage classification problem, leveraging LLMs' generative and reasoning abilities:

  1. Label Generation Stage:
    • The LLM is prompted to generate a set of candidate labels for the input text data. This is done by processing the data in mini-batches to manage context length limitations.
  2. Crucially, the LLM is also prompted to merge semantically similar generated labels. This step is vital for controlling cluster granularity and avoiding redundant or overlapping labels.
  3. Text Classification Stage:
    • Once a refined set of potential cluster labels is established, the LLM is used again to classify each text sample into one of these generated labels.

This approach bypasses the need for:

  • Fine-tuning embedding models: The LLM's pre-trained knowledge is directly utilized.
  • Predefined cluster numbers: The LLM dynamically generates labels, allowing for adaptive clustering.
  • Complex clustering algorithms: The LLM handles both label generation and assignment.

Datasets

The authors evaluated their framework on five diverse datasets across various NLP tasks:

  • Topic Mining: ArxivS2S
  • Emotion Detection: GoEmo
  • Intent Discovery: Massive-I, MTOP-I
  • Domain Discovery: Massive-D

These datasets have varying numbers of true clusters, ranging from 18 to 102. The paper notes that some datasets, originally used for classification, were adapted for text clustering.

Key Insights and Ideas

  • Reframing Clustering as Classification: This is the core innovation. By treating clustering as a classification problem solvable by LLMs, the authors sidestep many traditional clustering challenges.
  • LLMs as Label Generators and Classifiers: The paper demonstrates that LLMs are capable of both generating meaningful, human-readable cluster labels and assigning texts to these labels, all within a single model.
  • Label Merging for Granularity Control: The explicit step of merging semantically similar labels is key to achieving appropriate cluster granularity and improving coherence, a significant improvement over methods that might produce overly fine-grained or coarse labels.
  • In-Context Learning is Sufficient: The framework relies on the LLM's in-context learning capabilities, eliminating the need for computationally expensive fine-tuning.

Key Results

  • Performance: The proposed framework achieved comparable or superior performance to state-of-the-art embedding-based clustering techniques and other LLM-based methods across all five datasets. For instance, it showed a significant accuracy improvement of 12.44% on ArxivS2S and doubled performance on MTOP-I compared to some baselines.
  • Interpretability: The LLM-generated labels provide human-readable insights into the clusters, enhancing interpretability.
  • Efficiency: The method significantly reduces computational complexity and resource requirements by avoiding fine-tuning and complex algorithms.
  • Near Upper-Bound Performance: The framework's performance was remarkably close to the theoretical upper bound achieved when using ground truth labels for classification, highlighting the effectiveness of its label generation and merging process.
  • Robustness: The framework showed robustness to variations in prompt phrasing and batch size.

Limitations and Future Work

  • API Costs: The reliance on LLM API calls can lead to increased costs, especially for large datasets, as the number of calls is proportional to the dataset size.
  • Fine-grained Control: While improved, the framework still lacks absolute fine-grained control over cluster granularity, and LLMs might not always perfectly merge synonymous labels or distinguish polysemous words.
  • Prompt Stability: Ensuring consistent and stable LLM responses across different prompts remains a broader challenge.

Future work includes:

  • Incorporating user feedback to improve label accuracy and granularity.
  • Exploring more cost-efficient strategies.
  • Developing finer-grained clustering methods.
  • Further enhancing prompt stability and consistency.

Summary updated

BibTeX
@inproceedings{huang2024text,
  author = {Chen HUANG and Chen Huang and Guoxiu He},
  title = {{Text Clustering as Classification with LLMs}},
  booktitle = {International ACM SIGIR Conference on Research and Development in Information Retrieval},
  year = {2024},
}
Figure