In-context learning (ICL) for text classification, which uses a few input-label demonstrations to describe a task, has demonstrated impressive performance on large language models (LLMs). However, the selection of in-context demonstrations plays a crucial role and can significantly affect LLMs' performance. Most existing demonstration selection methods primarily focus on semantic similarity between test inputs and demonstrations, often overlooking the importance of label distribution alignment. To address this limitation, we propose a two-stage demonstration selection method, TopK + Label Distribution Divergence (L2D), which leverages a fine-tuned BERT-like small language model (SLM) to generate label distributions and calculate their divergence for both test inputs and candidate demonstrations. This enables the selection of demonstrations that are not only semantically similar but also aligned in label distribution with the test input. Extensive experiments across seven text classification benchmarks show that our method consistently outperforms previous demonstration selection strategies. Further analysis reveals a positive correlation between the performance of LLMs and the accuracy of the underlying SLMs used for label distribution estimation.
翻译:文本分类的上下文学习(ICL)通过少量输入-标签演示示例来描述任务,已在大型语言模型(LLMs)上展现出卓越的性能。然而,上下文演示示例的选择至关重要,会显著影响LLMs的表现。现有的大多数演示选择方法主要关注测试输入与演示示例之间的语义相似性,往往忽视了标签分布对齐的重要性。为弥补这一不足,我们提出了一种两阶段的演示选择方法:TopK + 标签分布差异(L2D),该方法利用一个经过微调的类BERT小型语言模型(SLM)来生成标签分布,并计算测试输入与候选演示示例之间的分布差异。这使得所选演示示例不仅在语义上与测试输入相似,而且在标签分布上与之对齐。在七个文本分类基准数据集上的大量实验表明,我们的方法始终优于先前的演示选择策略。进一步分析揭示了LLMs的性能与用于标签分布估计的底层SLMs的准确性之间存在正相关关系。