Papers
Topics
Authors
Recent
Search
2000 character limit reached

Retrieval High-Quality Demonstrations (RAD)

Updated 7 July 2026
  • RAD is a retrieval-conditioned methodology that selects task-relevant examples from a large corpus instead of using fixed prompts.
  • It employs dual encoder, BM25, and cross-encoder techniques to optimize demonstration selection based on downstream conditional likelihood.
  • Empirical evaluations in NLP, imitation learning, and reinforcement learning show that RAD efficiently improves performance with fewer high-quality examples.

Retrieval High-quAlity Demonstrations (RAD) denotes a retrieval-conditioned methodology in which a model selects demonstrations, examples, or analogous high-value conditioning items specifically for a query, target task, or current state, rather than using a fixed prompt or uniformly sampled support set. In the in-context learning formulation, RAD is defined over a query space Q\mathcal Q, a retrieval corpus C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}, and a parametric retrieval function RθR_\theta, with the objective of choosing a subset Dk(q)CD_k(q)\subseteq \mathcal C of size kk that maximizes the probability of the correct answer under a frozen LLM: Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q) (Luo et al., 2024). Across the literature, the same acronym is instantiated in meta-training with dense demonstration retrieval (Mueller et al., 2023), passage re-ranking by difficulty-based prompt construction (Drozdov et al., 2023), textual-graph question answering with mixture-based demonstration selection (Wu et al., 23 Mar 2026), few-shot imitation via adaptive fusion of retrieved subsets (Kumar et al., 2 Aug 2025), and offline reinforcement learning with retrieval-guided planning toward high-return states (Guo et al., 21 Jul 2025). This suggests that RAD is best understood as a family of retrieval-and-conditioning designs rather than a single fixed algorithm.

1. Formal objective and conceptual scope

In the survey formulation, each candidate demonstration is a paired example d=(q,a)d=(q',a') in a corpus C\mathcal C, and retrieval is query-conditioned: for each query qq, RAD ranks the corpus with RθR_\theta and selects the top-C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}0 elements as demonstrations. The central optimization target is not retrieval quality in isolation, but the downstream conditional likelihood assigned by the frozen in-context LLM. This formalization makes demonstration retrieval a task-coupled selection problem rather than a generic nearest-neighbor lookup problem (Luo et al., 2024).

The same general logic appears outside text-only in-context learning. In few-shot imitation, the target set is a small set of expert demonstrations C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}1 and the prior data source is a large offline dataset C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}2; the objective is to learn a policy C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}3 with high expected performance on the target task by combining C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}4 with only a relevant subset of C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}5 (Kumar et al., 2 Aug 2025). In offline reinforcement learning, the retrieved object is no longer an input-output demonstration pair but a high-return state together with its return estimate and trajectory position, which is then used as a waypoint for diffusion-based planning (Guo et al., 21 Jul 2025). A plausible implication is that the defining feature of RAD is not the datatype of the retrieved item, but the use of retrieval to construct a conditioning set that is more task-relevant than a static alternative.

The survey literature assigns several expected benefits to RAD: demonstrations tailored to each query reduce mismatch relative to fixed sets; automated retrieval can reduce manual selection bias; and sparse indexes or approximate nearest neighbor methods make retrieval scalable to large corpora. At the same time, the survey identifies efficiency trade-offs, corpus-maintenance burdens, and open questions about universal retriever training across domains (Luo et al., 2024).

2. Retrieval models and supervision signals

The canonical RAD retrieval stack in language tasks includes three architecture families. Embedding-based retrieval uses a dual encoder with C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}6 and C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}7, scoring candidates with cosine similarity or inner product, C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}8. Sparse retrieval uses term-based methods such as BM25. Cross-encoder re-ranking jointly encodes C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}9 and produces a scalar score RθR_\theta0, typically in a two-stage pipeline that first retrieves top RθR_\theta1 candidates and then reranks them to obtain the final top-RθR_\theta2 demonstrations (Luo et al., 2024).

Training objectives in RAD are correspondingly heterogeneous. The survey enumerates contrastive InfoNCE losses, hard negative mining, list-wise ranking losses of the RθR_\theta3Rank style, KL-distillation from teacher language-model scores, and weighted combined objectives such as RθR_\theta4 (Luo et al., 2024). These objectives make explicit that the retriever is often trained against a notion of demonstration usefulness induced by another model rather than against raw semantic proximity alone.

A particularly explicit formulation of LM-supervised retrieval appears in Unified Demonstration Retriever (UDR). UDR uses a dual-encoder backbone initialized from BERT-base, prefixes each example with a task instruction RθR_\theta5, and scores a query-demo pair by inner product, RθR_\theta6. For supervision, it constructs candidate pools, lets the LLM compute RθR_\theta7 or the classification analogue RθR_\theta8, ranks the candidates by LM feedback, and trains with a list-wise contrastive loss plus an in-batch softmax loss. Multi-task sampling with probability proportional to RθR_\theta9 with Dk(q)CD_k(q)\subseteq \mathcal C0, together with iterative candidate mining using top-Dk(q)CD_k(q)\subseteq \mathcal C1 nearest neighbors and re-scoring by the LLM, turns RAD into a unified retriever across 30+ tasks in 13 families (Li et al., 2023).

This body of work establishes a central distinction within RAD: retrieval can be optimized either for representational similarity or for estimated downstream utility. The latter view, which dominates the stronger formulations, treats retrieval as a learned proxy for task-specific helpfulness.

3. Meta-training with retrieved demonstrations

The paper that explicitly introduces RAD as “Retrieval of high-quality Demonstrations” couples dense retrieval with meta-training for few-shot learning. Its retriever is a Dense Passage Retriever with a 12-layer BERT\textsubscript{base} query encoder Dk(q)CD_k(q)\subseteq \mathcal C2 and a second 12-layer BERT\textsubscript{base} demonstration encoder Dk(q)CD_k(q)\subseteq \mathcal C3; both map text to 768-dimensional vectors and use inner-product similarity. Given an input Dk(q)CD_k(q)\subseteq \mathcal C4, retrieval defines

Dk(q)CD_k(q)\subseteq \mathcal C5

and uses the top-Dk(q)CD_k(q)\subseteq \mathcal C6 highest-scoring demonstrations from a memory bank Dk(q)CD_k(q)\subseteq \mathcal C7 (Mueller et al., 2023).

The meta-training objective couples this retriever to a seq2seq generator, BART\textsubscript{large}, over a set Dk(q)CD_k(q)\subseteq \mathcal C8 of meta-training tasks: Dk(q)CD_k(q)\subseteq \mathcal C9 The model also approximates the marginal likelihood over retrieved demonstrations with a “RAG-Token” style factorization,

kk0

thereby avoiding a single concatenated prompt and instead aggregating over separate forward passes (Mueller et al., 2023).

The demonstration bank is constructed from UnifiedQA training splits from 16 QA tasks, excluding tasks used for final evaluation, and each entry is formatted as plain text with question, answer, and context. The retriever is initialized from DPR pre-trained on Wikipedia and fine-tuned on NaturalQuestions, with no further fine-tuning during meta-training or task fine-tuning. Retrieval uses approximate maximum inner-product search, such as FAISS, to fetch kk1 nearest neighbors; the paper reports experiments with kk2 and states that performance saturates around 5–10 demonstrations (Mueller et al., 2023).

Empirically, this RAD formulation outperforms several few-shot baselines. On SQuAD 16-shot, RAD reaches kk3 Fkk4, compared with kk5 for RAG-m and kk6 for FewshotQA of Chada and Natarajan. On classification, the reported average accuracy is kk7 for RAD, versus kk8 for RAG-m and kk9 for LM-BFF. An oracle-memory ablation raises SQuAD FDk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)0 from Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)1 to Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)2, which the paper interprets as headroom for better demonstration collection (Mueller et al., 2023).

4. Selection criteria beyond semantic proximity

A recurrent theme in RAD is that “high-quality” does not reduce to semantic similarity. PaRaDe, a passage re-ranking framework using demonstrations with LLMs, argues that difficulty can be a more informative selection principle than similarity. For each candidate demonstration Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)3, it defines a demonstration query likelihood

Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)4

and ranks demonstrations in ascending order of DQL, so that lower DQL corresponds to greater difficulty. Candidate demos are first pre-filtered by BM25 to roughly 30 items and then rescored by the frozen LLM; no dense embeddings or dual-encoders are used in this formulation (Drozdov et al., 2023).

On passage re-ranking, PaRaDe reports that adding even one demonstration is significantly beneficial, and difficulty-based selection often surpasses zero-shot and semantic baselines. In nDCG@10, DBS 1-shot reaches Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)5 on TREC 2019 and Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)6 on TREC 2020, compared with Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)7 and Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)8 for the zero-shot baseline. The paper also reports that varying the number of demonstrations shows median benefit saturating by Dk(q)=argmaxDC, D=kPLM(aD;q)D_k(q)=\arg\max_{D\subseteq\mathcal C,\ |D|=k} P_{LM}(a^* \mid D; q)9, and that grouping demonstrations by DQL percentile yields monotonic improvement as difficulty increases (Drozdov et al., 2023).

A second alternative to nearest-neighbor selection appears in MixDemo for textual graph understanding and question answering. MixDemo partitions a demonstration pool d=(q,a)d=(q',a')0 into d=(q,a)d=(q',a')1 experts by K-means over sentence-BERT embeddings of textualized subgraphs and queries, chooses d=(q,a)d=(q',a')2 by minimizing within-cluster squared distance plus a complexity penalty, and computes a soft gating distribution

d=(q,a)d=(q',a')3

Training jointly optimizes a cross-entropy loss on gated cluster choice and a retrieval ranking loss that separates the correct expert centroid from the others (Wu et al., 23 Mar 2026).

MixDemo’s results support the claim that demonstration quality can depend on mixture structure and query-conditioned filtering rather than pure similarity. On the GraphQA benchmarks, MixDemo improves over G-Retriever from d=(q,a)d=(q',a')4 to d=(q,a)d=(q',a')5 on ExplaGraphs, from d=(q,a)d=(q',a')6 to d=(q,a)d=(q',a')7 on SceneGraphs, and from d=(q,a)d=(q',a')8 to d=(q,a)d=(q',a')9 on WebQSP, with all improvements reported as statistically significant at C\mathcal C0 via bootstrap resampling. Removing MoE gating reduces ExplaGraphs accuracy to C\mathcal C1, and replacing the query-aware encoder with vanilla GCN reduces it to C\mathcal C2 (Wu et al., 23 Mar 2026).

5. Cross-domain adaptations of the RAD pattern

RAD-style retrieval has been adapted to continuous-control and robotics settings in which the retrieved unit is not a text demonstration alone. COLLAGE, described as “Adaptive Fusion-based Retrieval for Augmented Policy Learning,” addresses few-shot imitation learning from a large offline dataset. It defines feature modalities C\mathcal C3 for visual, motion, shape, and language cues; segments target trajectories using a velocity-threshold heuristic; aligns target sub-trajectories to prior trajectories by subsequence-DTW with cost matrix C\mathcal C4; and collects the top-C\mathcal C5 prior sub-trajectories with lowest S-DTW cost to form modality-specific retrieved sets C\mathcal C6 (Kumar et al., 2 Aug 2025).

COLLAGE then estimates adaptive fusion weights by training one reference behavior-cloning policy per modality and evaluating how well each reference policy explains the few-shot target data. Specifically, for each modality it minimizes the behavior-cloning loss on C\mathcal C7, computes the negative log-likelihood C\mathcal C8 on the target demonstrations, and converts these losses to normalized weights

C\mathcal C9

The final policy is trained on the augmented dataset qq0 by importance sampling, first sampling a modality according to qq1 and then drawing uniformly from qq2 (Kumar et al., 2 Aug 2025).

The experimental results show that adaptive fusion outperforms both single-feature retrieval and non-adaptive fusion. On LIBERO-10 5-shot simulation, COLLAGE reaches qq3 average success versus qq4 for the best single-feature baseline, STRAP [visual], a qq5 absolute gain. On six real-world DROID tasks in the 5-shot setting, it reaches qq6 success versus qq7 for the best single-feature visual baseline and qq8 for uniform fusion, a qq9 gain. The paper also reports modality-specific ablations and practical guidance, including RθR_\theta0 in simulation and RθR_\theta1 in the real world, retrieval budget RθR_\theta2–RθR_\theta3, roughly RθR_\theta4k behavior-cloning gradient steps in simulation and RθR_\theta5k in the real world, and reference-policy training for about 100 epochs, approximately 40 minutes each (Kumar et al., 2 Aug 2025).

The acronym RAD is also used in offline reinforcement learning in a distinct but related sense. In this setting, the environment is modeled as an MDP RθR_\theta6 with an offline dataset of trajectories, and RAD dynamically retrieves high-return states from the dataset based on cosine similarity and discounted return estimates. Each indexed state stores its feature vector, trajectory ID, timestep index, and discounted return RθR_\theta7. At decision time, the method retrieves top-RθR_\theta8 similar states, filters them by proximity to the maximum retrieved return within RθR_\theta9, selects the target state C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}00 with the longest remaining trajectory segment, and uses a condition-guided diffusion model to plan from the current state C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}01 to C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}02 in C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}03 steps (Guo et al., 21 Jul 2025).

This offline RL variant reports an overall mean normalized return of C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}04 across the nine D4RL MuJoCo tasks, compared with C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}05 for Decision Diffuser, C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}06 for ReDiffuser, C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}07 for Trajectory Transformer, and C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}08 for Diffuser. The paper states that removing retrieval drops performance severely, that removing step estimation harms trajectory coherence, and that a hyperparameter study shows best performance at similarity threshold C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}09 and C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}10 (Guo et al., 21 Jul 2025). A plausible implication is that, in control settings, RAD generalizes from “retrieving demonstrations” to “retrieving strategically useful conditioning states.”

6. Empirical regularities, limitations, and recurrent misconceptions

Across the literature, several regularities recur. First, dynamic retrieval is repeatedly favored over fixed exemplars. The survey states that adaptivity reduces mismatch relative to fixed demonstration sets and improves robustness to demonstration order, formatting, and lexical gaps (Luo et al., 2024). UDR reports that its retrieved demonstrations show less than 1 point variance under random, ascending, or descending ordering, whereas random prompts can swing by tens of points, and that UDR with only 2 demonstrations still outperforms BM25 or EPR with 8 on generation tasks (Li et al., 2023).

Second, the literature repeatedly rejects the assumption that the best demonstrations are simply the most similar ones. COLLAGE explicitly identifies detrimental retrieval cases such as unrelated tasks with similar scene layouts and similar motions from tasks with divergent goals, and responds with adaptive late fusion over multiple cues (Kumar et al., 2 Aug 2025). PaRaDe replaces semantic similarity with hardness measured by low query likelihood (Drozdov et al., 2023). MixDemo uses expert clustering and query-conditioned gating to avoid irrelevant subgraph information (Wu et al., 23 Mar 2026). This suggests that RAD is increasingly characterized by relevance estimation under downstream objectives rather than by single-metric similarity.

Third, larger demonstration sets do not monotonically improve performance. The meta-training RAD paper reports marginal gains beyond C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}11 and saturation around 5–10 demonstrations (Mueller et al., 2023). PaRaDe reports that the median benefit saturates by C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}12 (Drozdov et al., 2023). In ExplaGraphs, MixDemo performs best at 2-shot, with accuracy dropping from C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}13 at 2-shot to C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}14 at 3-shot and C={d1,,dn}\mathcal C=\{d_1,\dots,d_n\}15 at 1-shot (Wu et al., 23 Mar 2026). The shared implication is that demonstration quality and interaction structure matter at least as much as raw prompt count.

Limitations are equally consistent. The survey emphasizes efficiency overhead from neural encoders and cross-encoders, training costs associated with mining positives and negatives, dependence on corpus currency and coverage, and failure modes on tasks such as commonsense reasoning where lexical similarity can mislead the model (Luo et al., 2024). The meta-training RAD paper notes the need for a large labeled demonstration bank and reduced effectiveness on very long, knowledge-intensive contexts such as TriviaQA and TextbookQA (Mueller et al., 2023). UDR identifies the dense retriever as a black box and notes that its training scores each demo in isolation even though inference uses a sequence of demos (Li et al., 2023). The offline RL RAD paper states that no formal convergence or optimality proofs are derived and that performance depends on the existence of reachable, high-value states in the dataset (Guo et al., 21 Jul 2025).

Open directions follow directly from these limitations. The survey identifies universal retriever training as an open challenge (Luo et al., 2024). The meta-training RAD paper proposes mixing Wikipedia-passage retrieval for knowledge tasks, dynamic bank expansion via generation, multilingual adaptation, and joint fine-tuning of DPR and BART (Mueller et al., 2023). PaRaDe suggests combining similarity and difficulty (Drozdov et al., 2023). UDR highlights modeling inter-demo interactions as a possible improvement (Li et al., 2023). In aggregate, these directions indicate that RAD remains an active research area centered on how retrieval, ranking, and conditioning should be optimized jointly for downstream reasoning, generation, and control.

Topic to Video (Beta)

No one has generated a video about this topic yet.

Whiteboard

No one has generated a whiteboard explanation for this topic yet.

Follow Topic

Get notified by email when new papers are published related to Retrieval High-quAlity Demonstrations (RAD).