Coverage-based Example Selection for In-Context Learning

Shivanshu Gupta, Matt Gardner, Sameer Singh

Abstract

Standard in-context learning (ICL) often fails because it selects prompt examples that are redundant, missing key "salient aspects" needed to solve a complex query. This paper introduces SET-BSR, a training-free, coverage-based selection method that uses BERTScore-Recall and submodular optimization to pick a diverse set of examples that collectively cover all parts of a test input. On compositional tasks, this approach outperforms state-of-the-art trained methods by up to 17 points.

Introduction: The Redundancy Problem in ICL

Large Language Models (LLMs) are highly sensitive to the examples provided in their prompts. The standard approach for example selection involves finding the $k$ most similar candidates in a dataset using metrics like BM25 or cosine similarity. However, independent selection often leads to redundancy. For instance, if a test query is complex (e.g., "Schedule a meeting with Doug and his boss"), a similarity-based search might return multiple examples about "scheduling a meeting with Doug" but none showing how to "find a boss." This leaves the LLM without the necessary reasoning patterns to solve the full problem.

SET-BSR ensures that all salient parts of a complex query are covered by the selected examples, allowing the model to generate correct compositional logic.

Methods: Informativeness as Coverage

The authors propose a framework based on the principle of Informativeness as Coverage.

  1. BERTScore-Recall (BSR) as the Base Metric: Instead of using a single dense embedding for a whole sentence, the method uses token-level contextual embeddings. BSR measures how well the tokens in a candidate example "cover" the tokens in the test input. The authors find that Recall (how much of the test input is explained by the example) is a better signal for ICL than Precision or F1.
  2. Set-Level Selection (SET-BSR): To solve the redundancy problem, BSR is extended to a set-level metric. The goal is to select a set of examples $Z$ such that every token in the test input is well-covered by at least one example in the set.
  3. Submodular Optimization: The coverage function is proven to be "submodular," exhibiting diminishing returns. This allows for an efficient greedy algorithm to select the optimal set. In each step, the algorithm picks the example that provides the most new information relative to the examples already selected.

Experimental Setup

The study evaluates 15 datasets across 6 task categories, including semantic parsing (GeoQuery, SMCalFlow), numerical reasoning (GSM8K), and classification (QNLI, SST2). These were tested across 7 LLMs, ranging from GPT-Neo (2.7B) to LLaMA (13B) and massive models like Codex (175B).

Key Results and Insights

The experiments reveal that Similarity ≠ Informativeness. A "similar" example might just be a paraphrase that adds no new reasoning value. Coverage-based selection explicitly seeks out the "missing pieces" of the puzzle.

Test accuracy across various LLMs and split types (IID vs. COMP). SET-BSR (purple) consistently outperforms other methods, especially on compositional (COMP) tasks and with larger models like Codex.
  • Compositional Generalization: For complex tasks where no single example contains all the logic, SET-BSR outperformed independent ranking by up to 17 points on average across all LLMs. On the SMCalFlow-CS compositional split, SET-BSR improved accuracy by a staggering 49 points over cosine similarity when using Codex.
  • The "Synergy" of LLM Scale: The benefits of SET-BSR increase as LLMs get larger. While smaller models might struggle to combine information from different examples, larger models like Codex excel at it, leading to massive performance jumps.
  • Training-Free Superiority: Remarkably, this purely heuristic, greedy selection method outperformed state-of-the-art methods (like EPR and CEIL) that require task-specific training or LLM-specific fine-tuning.

Limitations and Future Work

While effective, BSR relies on token embeddings. If the "salient aspect" of a task is abstract or latent (not explicitly written in the text), BSR might fail to recognize it. Additionally, BSR's computational complexity is $O(L \cdot T \cdot d)$, which is slower than simple vector search and could be a bottleneck for extremely long documents. Future work could explore better characterizations of "salient aspects" beyond token embeddings for tasks like QNLI, where salience is relational rather than token-based.

Summary updated

BibTeX
@inproceedings{gupta2023coverage,
  author = {Shivanshu Gupta and Matt Gardner and Sameer Singh},
  title = {{Coverage-based Example Selection for In-Context Learning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.930},
}
Figure