NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Finding Support Examples for In-Context Learning

Xiaonan Li, Xipeng Qiu

In-context learning (ICL) has emerged as a powerful paradigm, allowing Large Language Models (LLMs) to perform complex tasks using only a few demonstrations provided in the prompt. However, ICL is notoriously sensitive to the specific examples chosen and their sequence, with performance often swinging from state-of-the-art levels to near-random guessing based on minor prompt variations. This paper introduces LENS (fiLter-thEN-Search), a two-stage framework designed to identify "support examples"—a small, optimized set of demonstrations that maximize a language model's performance and stability.

The Challenge of Example Selection

Traditional machine learning relies on gradient-based updates to internal weights. In contrast, ICL happens entirely during the forward pass (inference) without any weight updates. This fundamental difference means that standard "coreset selection" methods used for fine-tuning do not translate well to the ICL setting.

Comparison between traditional supervised learning (left) and in-context learning (right).

As illustrated above, ICL relies on the model's ability to map a sequence of input-output pairs $(x_1, y_1, ...)$ to a new prediction. Because the search space for the best $k$ examples from a pool of thousands is combinatorially vast, most researchers resort to random sampling, which often yields suboptimal and unstable results.

The LENS Framework

LENS addresses this by identifying the "support vectors" of the ICL world through a two-stage process:

  1. Informative Examples Filtering: The authors introduce InfoScore, a metric that quantifies how much a specific example helps the model correctly predict other examples in the dataset. To manage computational costs, LENS employs Progressive Filtering, iteratively refining the candidate pool to avoid the $O(N^2)$ cost of comparing every example against every other example.
  2. Diversity-Guided Example Search: High-quality examples must also be non-redundant. LENS uses a beam search that balances InfoScore with a diversity penalty, ensuring the selected set covers various aspects of the task. This stage also optimizes the ordering of examples to find the most "persuasive" sequence for the model.

Key Results and Stability

The authors evaluated LENS across eight text classification datasets covering sentiment, subjectivity, and topic classification. LENS demonstrated a massive performance leap over standard random baselines. Across all benchmarks, the random baseline averaged 44.2% accuracy, while LENS achieved an average of 69.8%.

Performance distribution on the MR dataset: LENS (Ours) vs. Random sampling.

As shown in the violin plots for the MR dataset, LENS not only significantly improves median accuracy but also dramatically reduces sensitivity to example ordering. The "worst" ordering of LENS-selected examples is frequently superior to the "best" ordering of randomly sampled ones, indicating that LENS identifies fundamentally more robust representations of the task.

Insights and Transferability

The research offers several critical insights into the nature of ICL:

  • The Importance of Labels: While some studies suggest ICL works with random labels, this paper finds that for high-quality "support examples," correct labels are essential. Flipping labels on LENS-selected examples causes performance to crater.
  • Cross-Model Transferability: Support examples identified using a smaller, cheaper model (like GPT2-Large) perform exceptionally well when used in larger or different models (like GPT-Neo). This suggests that support examples capture model-agnostic task boundaries.

Conclusion

LENS provides a principled framework for moving beyond the "brittleness" of random example selection in ICL. By focusing on informativeness and diversity, LENS enables more reliable and high-performing few-shot learning, offering a scalable way to optimize prompts across various language models and tasks.

Summary updated

BibTeX
@inproceedings{li2023finding,
  author = {Xiaonan Li and Xipeng Qiu},
  title = {{Finding Support Examples for In-Context Learning}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.findings-emnlp.411},
}
Figure