arXiv:2601.01290cs.LG2026-01

通过对比分类器,揭示大模型如何靠上下文示例完成任务。

The Alchemy of Thought: Understanding In-Context Learning Through Supervised Classification

  • 用分类器模拟上下文学习,比较其与大模型行为差异。
  • 高相关示例下,大模型表现更像kNN而非梯度下降方法。
  • 低相关示例时,大模型凭借内置知识优于分类器。

上下文学习(ICL)已成为无需微调即可快速定制大语言模型的新范式。然而,尽管其有效性已被实证,我们仍不真正理解ICL的工作机制。本文通过将ICL行为与基于相同示例训练的监督分类器进行比较,探讨三个问题:(1)大模型在使用ICL时是否与这些分类器行为相似?(2)若相似,是梯度下降(GD)还是k近邻(kNN)分类器更接近?(3)当行为不一致时,哪些条件导致差异?以文本分类为案例,使用六个数据集和三种大模型,发现当示例相关性高时,大模型行为与分类器趋同。平均而言,ICL更接近kNN而非逻辑回归,提供了实证证据表明注意力机制的行为更类似kNN而非梯度下降。但当示例相关性低时,大模型表现优于这些分类器,可能因其可退回到参数化记忆,而分类器不具备此能力。

原文摘要 · Abstract (English)

In-context learning (ICL) has become a prominent paradigm to rapidly customize LLMs to new tasks without fine-tuning. However, despite the empirical evidence of its usefulness, we still do not truly understand how ICL works. In this paper, we compare the behavior of in-context learning with supervised classifiers trained on ICL demonstrations to investigate three research questions: (1) Do LLMs with ICL behave similarly to classifiers trained on the same examples? (2) If so, which classifiers are closer, those based on gradient descent (GD) or those based on k-nearest neighbors (kNN)? (3) When they do not behave similarly, what conditions are associated with differences in behavior? Using text classification as a use case, with six datasets and three LLMs, we observe that LLMs behave similarly to these classifiers when the relevance of demonstrations is high. On average, ICL is closer to kNN than logistic regression, giving empirical evidence that the attention mechanism behaves more similarly to kNN than GD. However, when demonstration relevance is low, LLMs perform better than these classifiers, likely because LLMs can back off to their parametric memory, a luxury these classifiers do not have.

大模型上下文学习分类器对比注意力机制

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