Revisiting What Makes a Good Context Subset: A Sparse Latent Basis Perspective

Cen-Jhih Li, Siddhant Chaudhary, Aditya BhaskaraarXiv 2026

TL;DR

Instead of just picking the most similar examples for few-shot learning, this paper proposes the Sparse Latent Basis Hypothesis: an effective subset of demonstrations should collectively "reconstruct" the target query's representation. By using a greedy algorithm called Residual Explanation Search (RES), the authors show that selecting for collective complementarity often outperforms standard diversity-based methods, though the "best" selection strategy depends heavily on the task and which layer of the model you use for embeddings.

What Problem Does This Paper Address?

In-context learning (ICL) is notoriously sensitive. If you give a Large Language Model (LLM) the wrong few-shot examples, or even the right examples in the wrong order, performance can crater.

Most researchers currently pick examples using Top-k similarity (find the most similar items) or Maximal Marginal Relevance (MMR) (find similar items that are also different from each other). However, these are "pairwise" heuristics. We still lack a principled understanding of what a subset of examples should provide collectively. Does the model need three versions of the same logic, or three different pieces of a puzzle? This paper moves beyond pairwise metrics to explore a subset-level property: collective reconstruction.

Methods

The authors introduce the Sparse Latent Basis Hypothesis. They posit that a query $q$ can be viewed as a combination of latent requirements, and a good set of exemplars $S$ should act as a "basis" that can linearly reconstruct that query: $q \approx \sum_{x_i \in S} \alpha_i x_i$.

To test this, they use Residual Explanation Search (RES), a diagnostic procedure based on the "Matching Pursuit" algorithm:

  1. Initialize: Start with the query vector as your "residual."
  2. Search: Find the exemplar that has the highest alignment (inner product) with the current residual.
  3. Update: Subtract the projection of that exemplar from the residual.
  4. Repeat: The next search now looks for an exemplar that explains the remaining part of the query that the first one missed.

They compare RES against BM25 (lexical), Top-k (semantic similarity), and MMR (diversity) across eight different open-weight LLMs (like Llama 3 and Qwen 2.5).

Datasets

The study evaluates performance across seven diverse benchmarks:

  • Sentiment/Subjectivity: SST-2, SST-5, and SUBJ.
  • Natural Language Inference: QNLI.
  • Reasoning (Knowledge-intensive/Math): StrategyQA, AQUA, and MathQA.

Key Insights and Ideas

  • Complementarity > Dissimilarity: RES outperformed MMR in 34 out of 56 model-dataset pairs. This suggests that picking examples that "fill in the gaps" of a reconstruction (complementarity) is a more effective signal than simply picking examples that are "different" from each other (dissimilarity).
  • The "Surface Topic" Trap: In StrategyQA, all retrieval methods actually performed worse than zero-shot (no examples). Why? The authors found that the queries in StrategyQA often don't contain enough information to point toward the required external facts. Retrieval picks "semantically related" items (e.g., about Apollo missions) that don't actually contain the specific "missing link" needed to solve the logic.
  • Layer Matters: The choice of representation space is critical.
  • Middle layers of LLMs tend to be more "semantic," making them better suited for simple similarity retrieval (Top-k).
  • Last layers are more "prediction-oriented." Interestingly, RES and MMR performed better when using these last-layer representations, suggesting that "diversity" and "residual explanation" are more useful when operating in a space closer to the model's final output.
  • Templates Rule Math: For math-heavy tasks (AQUA, MathQA), Top-k and BM25 remained very strong. This is likely because these tasks rely on "reusable templates"—if you find one example with the same formula, you've already won, and "complementarity" adds little extra value.

Key Results

  • Sentiment Wins: RES showed its clearest advantage on sentiment tasks (SST-2/5), where queries often have multiple varied cues (e.g., a review that is "action-packed" but "by-the-books"). RES picks examples that cover these different facets.
  • Quantitative Edge: RES outperformed random selection in 49/56 pairs.
  • Solution Reconstruction: The authors performed a "post-hoc" analysis where they tried to reconstruct the full solution (including reasoning) using the selected examples. They found a high correlation between how well a subset could reconstruct the solution and the actual ICL performance, validating the "latent basis" intuition.

Limitations and Future Work

  • The Proxy Assumption: The method relies on the query representation being a good proxy for the task's requirements. As seen in StrategyQA, if the query is "vague" regarding the necessary knowledge, the whole approach struggles.
  • Linearity: The authors assume that contextual influences are additive/linear in latent space. While this is a useful diagnostic, the actual mechanism by which LLMs process prompts is likely far more complex.
  • Scale: The study focused on 5-shot learning with models up to 8B parameters. Whether these patterns hold for "many-shot" ICL (hundreds of examples) or frontier models (GPT-4, Claude 3) remains an open question.

The authors conclude that there is no "one size fits all" selector; instead, the best strategy is conditional on the task type and the specific representation space being used.

Summary updated

Abstract

Selecting context subsets is increasingly important in modern LLM inference, yet what makes a subset effective remains unclear. We study this question in the controlled setting of few-shot demonstration selection. We examine a hypothesis that demonstrations should collectively provide task-relevant information needed by a target query. Assuming that the query representation provides a useful proxy for these requirements, we formulate selection as sparse reconstruction and instantiate it with Residual Explanation Search (RES), a Matching-Pursuit-style diagnostic procedure. Across seven benchmarks and eight open-weight LLMs, no retrieval objective is universally best. RES outperforms MMR in 34 of 56 model--dataset pairs, with its clearest advantage on sentiment tasks, suggesting that query-conditioned collective reconstruction may capture useful complementarity that pairwise dissimilarity misses. Relevance-based retrieval remains strong on template-heavy reasoning benchmarks, while all retrieval methods underperform zero-shot prediction on average on StrategyQA, where a solution-reconstruction analysis is consistent with the query not exposing the required external knowledge. Target-model hidden states further show that retrieval objectives interact differently with representation spaces: middle-layer representations generally favor similarity retrieval, whereas last-layer representations are often stronger for residual- and diversity-based selection. These findings support a conditional, representation-dependent account of context subset quality rather than a universally superior selector.
BibTeX
@misc{li2026revisiting,
  author = {Cen-Jhih Li and Siddhant Chaudhary and Aditya Bhaskara},
  title = {{Revisiting What Makes a Good Context Subset: A Sparse Latent Basis Perspective}},
  year = {2026},
  eprint = {2611.19220},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2611.19220},
}
Figure