arXiv:2510.08466cs.LG2025-10被引 1

用大模型注意力机制实现零样本聚类,支持文本与图像数据。

In-Context Clustering with Large Language Models

  • 利用大模型注意力矩阵捕捉输入间复杂关系,替代传统相似度度量。
  • 在文本编码的数值数据上,零样本聚类准确率媲美经典方法。
  • 支持文本条件的图像聚类,适用于多模态场景,适合研究者参考。

我们提出一种基于大模型的上下文聚类方法(ICC),可对来自不同分布的数据进行灵活聚类。与依赖预定义相似度度量的传统算法不同,ICC通过注意力机制捕捉输入间的复杂关系。实验表明,预训练大模型在文本编码的数值数据上展现出出色的零样本聚类能力,其注意力矩阵能清晰反映聚类模式。使用注意力矩阵进行谱聚类,性能表现意外地具有竞争力。我们进一步通过下一个词预测损失(NTP)微调,提升了大模型在数值和图像数据上的聚类能力。此外,大模型提示的灵活性使得实现文本条件的图像聚类成为可能,这是经典聚类方法所不具备的能力。本工作将上下文学习拓展至无监督场景,展示了大模型在聚类任务中的有效性和灵活性。代码已开源:https://agenticlearning.ai/icc。

原文摘要 · Abstract (English)

We propose In-Context Clustering (ICC), a flexible LLM-based procedure for clustering data from diverse distributions. Unlike traditional clustering algorithms constrained by predefined similarity measures, ICC flexibly captures complex relationships among inputs through an attention mechanism. We show that pretrained LLMs exhibit impressive zero-shot clustering capabilities on text-encoded numeric data, with attention matrices showing salient cluster patterns. Spectral clustering using attention matrices offers surprisingly competitive performance. We further enhance the clustering capabilities of LLMs on numeric and image data through fine-tuning using the Next Token Prediction (NTP) loss. Moreover, the flexibility of LLM prompting enables text-conditioned image clustering, a capability that classical clustering methods lack. Our work extends in-context learning to an unsupervised setting, showcasing the effectiveness and flexibility of LLMs for clustering. Our code is available at https://agenticlearning.ai/icc.

大模型聚类零样本多模态

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。