Which Examples to Annotate for In-Context Learning? Towards Effective and Efficient Selection

Costas Mavromatis, Balasubramaniam Srinivasan, Zhengyuan Shen, Jiani Zhang, Huzefa Rangwala, Christos Faloutsos, George Karypis · DOI

Introduction

Large Language Models (LLMs) have demonstrated remarkable capabilities in In-Context Learning (ICL), where they perform tasks based on a few provided examples without requiring parameter updates. However, the performance of ICL is highly sensitive to the choice of these examples. In real-world scenarios, obtaining high-quality labeled data is expensive and time-consuming. Traditional selection methods often rely on random sampling or simple semantic similarity, which can lead to redundant or "easy" examples that do not maximize the model's learning potential. This paper introduces ADAICL (Adaptive In-Context Learning), an algorithm designed to identify the most informative examples to annotate within a fixed budget.

The ADAICL Framework

ADAICL is a model-adaptive, optimization-free selection strategy that focuses on both the difficulty of examples and their diversity. The process operates in two primary stages:

  1. Uncertainty Sampling: The algorithm leverages the LLM's own internal confidence. By analyzing the output probabilities (logits) for an unlabeled pool of data, ADAICL identifies "hard" examples—those where the model is most uncertain.
  2. Diversity-based Selection (MAXCOVER): To ensure the selected examples represent the entire task space and avoid redundancy, ADAICL employs a Maximum Coverage strategy. It constructs a semantic graph using SBERT embeddings and identifies neighborhoods (egonets) around the uncertain examples. A greedy algorithm then selects the most representative points that "cover" the largest regions of model uncertainty.
Overview of the ADAICL selection process combining uncertainty sampling and MaxCover diversity.

An iterative variant, ADAICL+, further refines this by re-weighting examples. Once a region is covered, the importance of nearby examples is reduced, encouraging the selection process to explore the remaining unknown parts of the data manifold.

Experimental Evaluation

The effectiveness of ADAICL was evaluated across nine datasets spanning five distinct NLP tasks, including Topic Classification (AGNews, TREC), Sentiment Analysis (SST2, Amazon), Natural Language Inference (RTE, MRPC, MNLI), and generation tasks like Summarization (XSUM) and Math Reasoning (GSM8K). The researchers tested the algorithm against seven LLMs of varying sizes (1.3B to 65B parameters), including GPT-J, Falcon, and LLaMa, to ensure the findings were robust across different architectures.

Results and Impact

ADAICL consistently outperformed state-of-the-art (SOTA) selection methods, providing an average relative performance boost of 7.7% (4.4 absolute accuracy points).

Performance comparison of ADAICL against baselines across multiple NLP tasks and model architectures.

Key findings include:

  • Budget Efficiency: ADAICL is up to 3x more efficient than random sampling, achieving comparable performance with significantly fewer manual annotations.
  • Reduced Inference Costs: The method allows models to achieve superior results even when using 50% fewer examples in the final prompt, which is critical for managing tight context windows and reducing API costs.
  • Improved Calibration: Beyond accuracy, ADAICL helps align the model's confidence with its actual performance, reducing Expected Calibration Error (ECE) by exposing the model to examples it previously found confusing.

Limitations

Despite its advantages, ADAICL has specific requirements. It necessitates access to model logits, which may not be available in all commercial "black-box" APIs. Additionally, the diversity component is dependent on the quality of the underlying embedding model (e.g., SBERT). Future research may explore more dynamic neighborhood definitions and the impact of adversarial examples in the unlabeled pool.

Summary updated

BibTeX
@misc{mavromatis2023which,
  author = {Costas Mavromatis and Balasubramaniam Srinivasan and Zhengyuan Shen and Jiani Zhang and Huzefa Rangwala and Christos Faloutsos and George Karypis},
  title = {{Which Examples to Annotate for In-Context Learning? Towards Effective and Efficient Selection}},
  year = {2023},
  eprint = {2310.20046},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2310.20046},
}
Figure