The Role of Diversity in In-Context Learning for Large Language Models

Wenyang Xiao, Haoyu Zhao, Lingxiao Huang
5/26/2025
cs.CLcs.AIcs.LG

No confident code implementation found for this paper.

Abstract

In-context learning (ICL) is a crucial capability of current large language models (LLMs), where the selection of examples plays a key role in performance. While most existing approaches focus on selecting the most similar examples to the query, the impact of diversity in example selection remains underexplored.

Show full abstract

We systematically investigate the role of diversity in in-context example selection through experiments across a range of tasks, from sentiment classification to more challenging math and code problems. Experiments on Llama-3.1, Gemma-2, and Mistral-v0.3 families of models show that diversity-aware selection methods improve performance, particularly on complex tasks like math and code, and enhance robustness to out-of-distribution queries. To support these findings, we introduce a theoretical framework that explains the benefits of incorporating diversity in in-context example selection.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{xiao2025role,
  title  = {The Role of Diversity in In-Context Learning for Large Language Models},
  author = {Wenyang Xiao and Haoyu Zhao and Lingxiao Huang},
  year   = {2025},
  eprint = {2505.19426},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2505.19426v2}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2505.19426.svg)](https://codeofpaper.com/paper/2505.19426)

Discussion