InSQuAD: In-Context Learning for Efficient Retrieval via Submodular Mutual Information to Enforce Quality and Diversity

Souradeep Nanda, Anay Majee, Rishabh K. Iyer2025

Abstract

In-Context Learning (ICL) has emerged as a dominant paradigm for utilizing Large Language Models (LLMs), yet its efficacy is highly sensitive to the selection and ordering of demonstration exemplars. Traditional retrieval methods often prioritize semantic relevance, leading to "semantic crowding" where redundant examples consume the limited context window without providing additional task coverage. We introduce InSQuAD (In-context Submodular Quality and Diversity), a unified framework that leverages Submodular Mutual Information (SMI) to select exemplars that are both highly relevant to the query and mutually diverse. InSQuAD comprises a selection strategy (InSQuaD-RETRIEVE) and a training paradigm (InSQuaD-LEARN) that fine-tunes retrieval models to inherently value diversity. Our experiments across nine benchmarks demonstrate accuracy gains of up to 21.6% and significantly faster inference compared to existing state-of-the-art selection methods.

Introduction

The performance of LLMs in few-shot settings is notoriously brittle, often fluctuating based on the specific examples provided in the prompt. Most current retrieval pipelines utilize off-the-shelf encoders to find the most similar examples to a given test query. However, this approach frequently results in a set of exemplars that are nearly identical to one another, failing to illustrate the breadth of the target task or the nuances of the decision boundary.

While some researchers have attempted to introduce diversity through multi-stage pipelines or iterative selection, these methods are often computationally expensive or decouple the concepts of quality and diversity. InSQuAD addresses these challenges by treating exemplar selection as a unified combinatorial optimization problem, ensuring that the selected set maximizes information gain relative to the query while minimizing internal redundancy.

Methodology

The InSQuAD framework is built upon the mathematical foundation of submodularity—a property characterizing "diminishing returns" where the marginal gain of adding an element to a set decreases as the set grows.

InSQuaD-RETRIEVE: Selection via SMI

At test time, InSQuAD-RETRIEVE employs Submodular Mutual Information (SMI) functions to select exemplars. SMI mathematically models the information coverage a subset provides for a target query. By maximizing this function, the system naturally identifies examples that are relevant (Quality) but distinct from those already selected (Diversity). To maintain computational efficiency, the framework utilizes a Greedy Optimization algorithm. This approach iteratively selects the most informative example given the current set, which also produces a natural ordering of exemplars—a critical factor for LLMs sensitive to the "lost in the middle" phenomenon.

InSQuaD-LEARN: Training for Diversity

Unlike traditional methods that use frozen retrievers, InSQuaD-LEARN fine-tunes the retrieval model using a novel likelihood-based loss inspired by Submodular Point Processes (SPPs). This training objective encourages the model to distinguish between sets of documents that provide high coverage and those that are redundant.

To facilitate this learning, the authors utilized the HotpotQA dataset, augmented with synthetic paraphrases generated by GPT-3.5. This adversarial data forces the retriever to recognize that a paraphrase of an existing exemplar adds no new information, thereby training the model to prioritize truly diverse demonstrations.

Experimental Evaluation

The framework was evaluated across nine diverse benchmarks spanning classification, multi-choice reasoning, and generation tasks:

  • Classification: MRPC, SST5, MNLI, DBpedia, RTE.
  • Multi-Choice: HellaSwag.
  • Generation/Dialogue: MWoZ, GeoQ, Xsum.

The researchers tested the framework against various LLM backbones, including Gemma (2B and 7B) and OpenAI’s Davinci-002, to ensure the findings were model-agnostic.

Key Results and Insights

  • Significant Accuracy Gains: InSQuAD consistently outperformed baseline methods like random selection and standard similarity-based retrieval. The framework achieved improvements of up to 21.6% on classification tasks and 16.4% on multi-choice tasks.
  • Computational Efficiency: By utilizing greedy optimization and efficient submodular functions (specifically the Graph-Cut variant), InSQuAD achieved inference speeds orders of magnitude faster than advanced selection methods like IDEAL or Vote-K.
  • Superiority of Graph-Cut: Among the various submodular functions tested, the Graph-Cut (GC) variant emerged as the most robust, providing the best balance of performance and ranking across all evaluated tasks.
  • Inherent Ordering: The greedy selection process naturally places the most informative examples in positions that maximize LLM attention, mitigating performance degradation often seen with poorly ordered prompts.

Conclusion and Future Work

InSQuAD demonstrates that submodular math provides a robust, efficient, and unified framework for optimizing In-Context Learning. By training retrievers to understand the relationship between documents rather than just query-document similarity, InSQuAD significantly improves the quality of few-shot prompts.

Future research may explore expanding the training data beyond HotpotQA to further enhance generalizability and investigating the specific task-dependent performance of different submodular functions. Additionally, addressing potential biases in the initial exemplar annotation phase remains a priority for ensuring the fairness and robustness of the retrieved demonstrations.

Summary updated

BibTeX
@misc{nanda2025insquad,
  author = {Souradeep Nanda and Anay Majee and Rishabh K. Iyer},
  title = {{InSQuAD: In-Context Learning for Efficient Retrieval via Submodular Mutual Information to Enforce Quality and Diversity}},
  year = {2025},
  eprint = {2508.21003},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2508.21003},
}
Figure