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

Representative Demonstration Selection for In-Context Learning with Two-Stage Determinantal Point Process

Zhao Yang, Yuanzhe Zhang, Dianbo Sui, Cao Liu, Jun Zhao, Kang Liu

Introduction

In-Context Learning (ICL) has emerged as a powerful paradigm for utilizing Large Language Models (LLMs), allowing them to perform tasks by observing a few demonstrations within the prompt. However, the performance of ICL is highly sensitive to the choice and ordering of these examples. While retrieval-based methods—which select specific examples for each test instance—offer high accuracy, they are computationally expensive and hinder efficient batch processing. This paper introduces a two-stage Determinantal Point Process (DPP) framework designed to select a single, high-quality, and diverse set of "representative" demonstrations that work effectively across an entire task.

The Challenge: Efficiency vs. Accuracy

The current gold standard for demonstration selection is per-instance retrieval. Systems like BM25 or KATE search the training set for the most relevant examples for every new query. While effective, this approach introduces significant latency and high token costs because it prevents the use of KV-caching for the prompt across multiple queries.

The representative subset approach uses a fixed set of demonstrations for all test instances, enabling significant efficiency gains.

The authors propose shifting from per-instance retrieval to a "one-size-fits-most" representative subset. This allows for "batch prompting," where the demonstrations are processed once and cached, slashing token costs by up to 90% and speeding up inference.

The Two-Stage DPP Framework

To identify the optimal representative set, the researchers developed a two-stage selection process based on Determinantal Point Processes (DPP), a probabilistic tool that favors diversity by modeling "repulsion" between similar items.

  1. Stage 1: Semantic Filtering: The entire training set is embedded using Sentence-BERT. A DPP then selects a semantically diverse candidate subset, reducing the search space for the subsequent, more intensive stage.
  2. Stage 2: Quality and Influence Selection: The framework evaluates candidates based on an "Influence Score"—the degree to which an example improves the model's performance on other cases.
  3. Quality: Measured as the average influence an example exerts.
  4. Influence Diversity: Ensures the selected set covers a broad range of "influence patterns," helping the model handle diverse test cases rather than just the easiest ones.

Key Insights: Quality and Diversity

A critical finding of the study is that while high-quality examples are essential, diversity is equally important for generalization. Specifically, "influence diversity" prevents the prompt from becoming redundant.

Comparison of influence selection strategies across different model scales. Diverse-influence selection consistently outperforms similar-influence and random selection.

As shown in Figure 3, selecting examples with diverse influence patterns leads to higher average accuracy across various model sizes, including GPT2-xl, GPT-J, and GPT-NeoX. This suggests that a balanced set of demonstrations helps the model navigate a wider variety of "hard" cases.

Results and Performance

The two-stage DPP method was evaluated on six classification benchmarks (e.g., SST-2, AGNews, RTE). Key findings include:

  • Superiority over Baselines: The method outperformed standard representative selection techniques, such as K-means clustering, by 4% to 10%.
  • Efficiency Gains: Compared to retrieval-based methods, it achieved comparable accuracy while reducing token costs by 10x through batch prompting and KV-caching.
  • Reduced Sensitivity: The selected representative sets proved more stable and less sensitive to the order of examples than random sets.
  • Transferability: Demonstrations selected using smaller models (e.g., GPT-J) remained highly effective when used with much larger models like GPT-3 (text-davinci-003).

Conclusion

The two-stage DPP framework offers a compelling solution to the efficiency-accuracy trade-off in In-Context Learning. By selecting a fixed set of high-quality, diverse demonstrations, researchers can achieve the performance of complex retrieval systems at a fraction of the cost and latency. Future work will focus on making the calculation of influence scores more efficient for even larger datasets and black-box model APIs.

Summary updated

BibTeX
@inproceedings{yang2023representative,
  author = {Zhao Yang and Yuanzhe Zhang and Dianbo Sui and Cao Liu and Jun Zhao and Kang Liu},
  title = {{Representative Demonstration Selection for In-Context Learning with Two-Stage Determinantal Point Process}},
  booktitle = {Conference on Empirical Methods in Natural Language Processing},
  year = {2023},
  doi = {10.18653/v1/2023.emnlp-main.331},
}
Figure