Topic Coverage-based Demonstration Retrieval for In-Context Learning

Wonbin Kweon, SeongKu Kang, Runchu Tian, Pengcheng Jiang, Jiawei Han, Hwanjo Yu

Introduction

In-Context Learning (ICL) has become a cornerstone of Large Language Model (LLM) utility, allowing models to adapt to new tasks via a few-shot prompt. However, the effectiveness of ICL is highly sensitive to the specific demonstrations selected. Current retrieval strategies generally fall into two categories: similarity-based methods (e.g., BM25, TopK), which are computationally efficient but "model-blind," and uncertainty-based methods (e.g., ConE), which are "model-aware" but require expensive inference passes for every candidate example. Both approaches frequently suffer from informational redundancy, failing to address the specific knowledge gaps of the model.

The TopicK Framework

To address these limitations, we introduce TopicK, a framework that shifts the retrieval focus toward topic-level informational demands. TopicK identifies the specific topics required by a test input that the LLM likely lacks knowledge in, then retrieves demonstrations to fill those specific gaps.

Methodology

The TopicK process consists of three primary stages:

  1. Topical Knowledge Assessment: A global set of topics is mined from the candidate pool. A lightweight Topic Predictor (MLP) is trained to map text embeddings to topic distributions. Simultaneously, the LLM's inherent "Topical Knowledge" is estimated by measuring its zero-shot accuracy across these topics.
  2. Topic Coverage-based Retrieval: Demonstrations are selected iteratively based on a relevance score that prioritizes topics required by the test input, covered by the candidate, and currently "unknown" to the model (based on low zero-shot accuracy).
  3. Cumulative Coverage: The system tracks topics already covered by previously selected examples to ensure the next demonstration provides novel, non-redundant information.
Figure 1: A case study illustrating how TopicK identifies that the model already understands 'Carnivores' but lacks knowledge on 'Herbivores,' leading it to select a more helpful, non-redundant example compared to similarity or uncertainty-based baselines.

Experimental Results

TopicK was evaluated across six diverse datasets, including general domains (CommonsenseQA, SciQ), natural language inference (QNLI, MNLI), and specialized domains (MedMCQA, Law), using Llama-3.2 and Qwen-2.5 model families.

Performance and Efficiency

TopicK consistently outperformed both similarity-based and uncertainty-based baselines across all benchmarks. A key advantage is its efficiency; by using a lightweight predictor instead of full LLM inference at retrieval time, TopicK achieves "model-awareness" with minimal overhead. For example, on the QNLI dataset, TopicK was 37x faster than the leading uncertainty-based method, ConE, while delivering higher accuracy.

Figure 3: The time-accuracy trade-off across different datasets. TopicK (red star) consistently occupies the top-left quadrant, indicating superior accuracy with significantly lower retrieval time than other model-aware methods like ConE and MDL.

Specialized Domains and Closed-Source Models

The framework showed particularly strong gains in specialized medical and legal domains (up to 6.38% improvement), where model knowledge gaps are more pronounced. Furthermore, TopicK remains effective for closed-source models (e.g., GPT-4o-mini) by using zero-shot accuracy as a proxy for internal knowledge states.

Conclusion and Future Work

TopicK demonstrates that the most effective demonstrations are those that provide information the model lacks, rather than those that are simply similar to the input. While currently utilizing a flat topic structure, future iterations may explore hierarchical taxonomies to further refine knowledge assessment. TopicK provides a scalable, efficient path toward optimizing ICL for both open and closed-source LLMs.

Summary updated

BibTeX
@misc{kweon2025topic,
  author = {Wonbin Kweon and SeongKu Kang and Runchu Tian and Pengcheng Jiang and Jiawei Han and Hwanjo Yu},
  title = {{Topic Coverage-based Demonstration Retrieval for In-Context Learning}},
  year = {2025},
  eprint = {2509.12451},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2509.12451},
}
Figure