Large Language Models Enable Few-Shot Clustering

Vijay Viswanathan, Kiril Gashteovski, Carolin Lawrence, Tongshuang Wu, Graham Neubig · DOI

Introduction

Clustering is a fundamental yet often underspecified task in machine learning. Without explicit guidance, algorithms may group data based on features that do not align with a user's specific intent. For example, a set of news articles could be clustered by topic, sentiment, or writing style. While semi-supervised clustering attempts to resolve this ambiguity through human feedback (e.g., pairwise "must-link" or "cannot-link" constraints), the process is typically bottlenecked by the high cost and effort of manual labeling.

Comparison between traditional semi-supervised clustering and LLM-guided few-shot clustering.

This research explores how Large Language Models (LLMs) can alleviate this feedback bottleneck. By acting as "pseudo-oracles," LLMs can leverage their vast latent knowledge and few-shot reasoning capabilities to transform a handful of human demonstrations into a massive volume of high-quality guidance, significantly enhancing clustering performance across various domains.

LLM-Guided Methodologies

The authors investigated three primary ways to integrate LLMs into the clustering pipeline:

Keyphrase Expansion (Pre-Clustering)

This approach proved to be the most effective. Users provide a few examples of how they would describe documents for a specific task. The LLM then generates task-specific keyphrases for every document in the dataset. These keyphrases are embedded and concatenated with the original document vectors, effectively "steering" the embedding space toward the user's desired features.

The Keyphrase Expansion method: augmenting document vectors with task-specific LLM-generated keyphrases.

Pairwise Constraints (During Clustering)

In this scenario, the LLM predicts whether thousands of document pairs should reside in the same cluster based on a small set of human-labeled examples. These "pseudo-constraints" are then fed into a constrained clustering algorithm, such as PCKMeans.

Post-Correction (After Clustering)

The system identifies "low-confidence" points—those situated on the borders between clusters—and prompts the LLM to re-assign them to the most appropriate group based on representative examples. Interestingly, this method provided minimal benefit, as the LLM tended to struggle with the same difficult edge cases as the underlying clustering algorithm.

Key Insights and Results

The framework was evaluated on five datasets covering entity canonicalization, intent clustering, and topic grouping. Key findings include:

  • LLMs as Knowledge Injectors: The primary advantage of using LLMs is their ability to inject "world knowledge" into the process. For instance, an LLM can recognize the relationship between "B.A." and "Bachelor's degree," a semantic link often missed by standard text encoders.
  • The Necessity of Context: Both natural language instructions and few-shot demonstrations are essential for success. Omitting either component leads to inconsistent performance gains.
  • Economic Efficiency: LLM-guided clustering is significantly more efficient than human labeling. The researchers found that $41 of LLM API calls could generate 20,000 pairwise constraints—a task that would cost approximately 30 times more if performed by human workers.
  • State-of-the-Art Performance: The Keyphrase Clustering method achieved state-of-the-art results on entity canonicalization tasks (OPIEC59k and ReVerb45k) and significantly improved accuracy on social media topic grouping.

Conclusion and Future Directions

While LLMs provide a powerful tool for few-shot clustering, challenges remain regarding API costs and latency at extreme scales. Furthermore, models still exhibit some surface-form bias in cases of high polysemy. Future work may explore tighter integration of natural language instructions directly into clustering objective functions, moving beyond pre- and post-processing techniques.

Summary updated

BibTeX
@article{viswanathan2024large,
  author = {Vijay Viswanathan and Kiril Gashteovski and Carolin Lawrence and Tongshuang Wu and Graham Neubig},
  title = {{Large Language Models Enable Few-Shot Clustering}},
  journal = {Trans. Assoc. Comput. Linguistics},
  year = {2024},
  doi = {10.1162/tacl\_a\_00648},
}
Figure