In-Context Learning on a Budget: A Case Study in Token Classification

Uri Berger, Tal Baumel, Gabriel Stanovsky

TL;DR

In-context learning (ICL) research often assumes access to massive labeled datasets to pick the "best" examples, but real-world annotation is expensive. This paper introduces a "budget-constrained" framework for token classification, finding that a tiny pool of just ~200 labeled samples can achieve nearly 90% of the performance of using an entire training set, with random selection proving surprisingly difficult to beat.

What Problem Does This Paper Address?

Most research into In-Context Learning (ICL)—where a Large Language Model (LLM) learns a task from a few examples in a prompt—operates under an unrealistic assumption: that we already have thousands of annotated examples to choose from. In reality, if you are adapting a model to a new, specialized domain (like legal or medical text), you start with zero labels and a limited budget to pay experts for annotation.

The authors address the pool selection problem: Given a large corpus of raw, unannotated text and a fixed budget to label only k samples, which ones should you pick to maximize the LLM's performance? They focus specifically on token classification (e.g., identifying names, parts of speech, or grammatical structures), which is notoriously expensive to annotate because it requires word-by-word expertise.

Methods

The researchers proposed a four-step conceptual framework for "ICL on a Budget," as illustrated in their workflow:

Figure 1: Our proposed approach for ICL on a budget, illustrated in four steps: (1) we assume a large pool of raw train and potentially test texts in the target domain; (2) a pool selection strategy chooses a subset of k train texts to maximize downstream ICL performance; (3) annotations are collected for the selected pool; (4) an inference prompt is instantiated by choosing the nearest examples in the pool to the inference sample. We focus on step (2), experimenting with various pool selection strategies.

They compared four distinct strategies for selecting the annotation pool:

  1. Central: Selecting samples closest to the average embedding of the entire dataset.
  2. Cluster: Using k-means to group the data and picking a representative sample from each cluster to ensure broad coverage.
  3. Vote-k: A sophisticated two-step process that selects diverse samples while considering the LLM's own confidence levels.
  4. Random: Simply picking k samples at random.

Once the pool is selected and "annotated," the model performs inference by picking the most similar examples from that small pool to include in the prompt.

Datasets

The study utilized two primary English benchmarks to simulate the annotation process:

  • Ontonotes 5.0: Used for Named Entity Recognition (NER).
  • Universal Dependencies (en_ewt): Used for Dependency Parsing and Part-of-Speech (POS) tagging.

These datasets were treated as "raw text" pools, and the existing labels were only revealed for the samples selected by the budget strategies.

Key Insights and Ideas

  • Random is a Robust Baseline: Surprisingly, carefully designed selection strategies (like clustering) rarely outperformed simple random selection. For practitioners, this suggests that complex active learning setups might not be necessary for basic ICL pool building.
  • The Power of Small Pools: You don't need a massive library of examples. The authors found that a pool of just ~200 samples allowed LLMs to reach over 88% of the performance they would have achieved if they had access to the entire training set (the "Oracle" setup).
  • Label Diversity Matters: The researchers found a strong correlation between the "entropy" (diversity) of labels in the selected pool and the final performance. If your small pool contains a wide variety of entity types or grammatical structures, the model performs significantly better.
  • Format Sensitivity: While top-tier models like GPT-4 and Claude 3 Haiku handled the complex output formats of token classification well, smaller open-source models often failed to follow the requested formatting, making them less reliable for these specific tasks in an ICL setup.

Key Results

The study evaluated performance across several state-of-the-art models, showing how performance plateaus quickly as the pool size increases:

Figure 2: Results for NER (top), dependency parsing (center), and POS tagging (bottom) using Claude 3 Haiku (left), GPT4 (middle) and Gemini 1.5 Pro (right), as a function of the size of sample pool. In methods with a random component we run 3 trials and plot error bars showing the standard deviation. Oracle: using the full training set as the pool.
  • Efficiency: For NER, a pool of 220 samples was sufficient to approximate the full training corpus. For POS tagging and Dependency Parsing, only 138 samples were needed.
  • Performance Gap: While ICL on a budget is efficient, it still lags behind traditional fine-tuning. For example, GPT-4 using a 5% budget achieved only 40-44% of state-of-the-art performance for complex tasks like dependency parsing, though it reached 96% for the simpler task of POS tagging.

Limitations and Future Work

The authors acknowledge that their study was limited to token classification tasks. Other NLP tasks, like summarization or reasoning, might respond differently to these selection strategies. Additionally, the study highlighted a "formatting wall": many smaller LLMs could not be meaningfully evaluated because they couldn't consistently produce the complex structured output required for token classification (e.g., the specific bracketed tags used in NER).

Future work could explore whether these findings hold true for multi-lingual settings or if more advanced "model-in-the-loop" selection strategies could finally beat the random selection baseline.

Summary updated

BibTeX
@misc{berger2024context,
  author = {Uri Berger and Tal Baumel and Gabriel Stanovsky},
  title = {{In-Context Learning on a Budget: A Case Study in Token Classification}},
  year = {2024},
  eprint = {2406.13274},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2406.13274},
}
Figure