Demonstrate-Search-Predict (DSP): composing retrieval and LMs
Read first: Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks · Baleen: robust multi-hop retrieval via condensed retrieval
TL;DR. Rather than “retrieve, then stuff into the prompt”, DSP writes a short program in which a frozen LM and a frozen retriever pass text back and forth. Its three stages:
- Demonstrate: automatically bootstrap examples of every intermediate step.
- Search: issue queries, possibly over multiple hops.
- Predict: produce a grounded answer.
Why it matters now. DSP is the bridge between Baleen (multi-hop retrieval) and DSPy, which turned these hand-written programs into a general programming model with optimizers.
A worked trace (illustrative)
Section titled “A worked trace (illustrative)”A two-hop question, written as DSP’s three stages. The texts are made up to show the data flow; they are not from the paper.
- Demonstrate. Run the zero-shot program on training question “In which country was the director of Jaws born?” It writes hop 1 query
director of Jaws→ passage names Steven Spielberg; hop 2 querySteven Spielberg birthplace→ passage says Cincinnati, Ohio. The program answers “United States”, which matches the gold answer, so the whole trace (both queries, passages and the rationale) is kept as a demonstration. A trace whose final answer is wrong is discarded. - Search. For a test question, the LM, prompted with the kept demos, writes the hop 1 query; the retriever returns passages; the LM writes the hop 2 query conditioned on them, and so on. DSP samples several queries per hop and fuses their results.
- Predict. The LM answers from the gathered passages with chain-of-thought, sampling several answers and taking a majority vote (self-consistency).
Nothing was trained: the “learning” is only which traces end up as demonstrations.
Connections
Section titled “Connections”- Before: RAG, self-ask, Baleen.
- Contemporaries, not a lineage: ReAct (arXiv v1 2022-10-06), IRCoT (2022-12-20) and DSP (2022-12-28) appeared within twelve weeks of each other as independent ways to interleave LM reasoning with retrieval or actions. The sidebar order is a learning order, not a historical derivation.
- After: DSPy.
Questions to think through
These questions have no single right answer. Write or say your answer before you open the hints. Mark a question once you could defend your answer in a reading group.
- Mechanism
In DSP's Demonstrate stage, a training question's intermediate hop queries and passages are kept as demonstrations only if the zero-shot pipeline's final answer matches the gold answer. Why is this end-answer filter a usable weak-supervision signal for the hop queries, and in what ways can it admit bad demonstrations?
What a strong answer covers
- A correct final answer is evidence that the whole chain worked, so it labels hop queries and passages that nobody annotated. The paper presents this as simulating a forward pass and filtering, used in place of backpropagation.
- It needs a foothold: the LM and retriever must already handle the transformations zero-shot on at least one or two examples, otherwise nothing survives the filter.
- Failure 1: the LM answers from parametric memory and the hops were irrelevant, so useless queries are kept as demos.
- Failure 2: short or common answers (yes/no, years, famous entities) can match by chance, and the filter favours easy questions, which then serve as demos for hard ones.
- Mitigations: the open-QA program also requires the answer to appear in a retrieved passage before accepting an answer match; stronger options are per-hop gold-document checks or requiring that the answer is supported by a cited passage.
- Derive / compute
Assume a DSP multi-hop program runs 2 hops, each sampling n = 10 queries whose results are fused, then a final Predict with n = 20 self-consistency chain-of-thought samples. (a) How many LM completions and retriever queries does one test question cost? (b) If Demonstrate runs all 16 training questions once through the same pipeline, how much does it add to a 1,000-question evaluation? (c) With a 4,097-token window, 7 test passages of about 100 tokens, 200 tokens of instructions and 256 tokens reserved for output, how many demonstrations of about 600 tokens fit?
What a strong answer covers
- (a) 2 × 10 + 20 = 40 completions and 2 × 10 = 20 retriever queries per question.
- (b) 16 × 40 = 640 completions and 320 queries, against 40,000 completions for evaluation: about 1.6%. Annotating demos is nearly free compared with inference.
- (c) 4,097 − 256 − 200 − 700 ≈ 2,940 tokens, so about 4 demos. The paper says this window fits several (e.g., 3–5) demos that include their own passages and rationales.
- So the binding constraint is context, not compute. That is why DSP keeps only a few annotated demos (k = 3 for open-domain QA) even when more survive the filter.
- Critique
DSP reports HotPotQA EM of 51.4, against 36.9 for retrieve-then-read and 28.6 for self-ask with a refined prompt. Critique whether this isolates the value of DSP's Demonstrate–Search–Predict design, and give one experiment that could falsify the claim that bootstrapped demonstrations drive the gain.
What a strong answer covers
- Compute is not matched: DSP samples many queries per hop and 20 self-consistency answers, while retrieve-then-read makes one LM call over 2 passages.
- Five seeds of 200 questions each mean that seed and question subset vary together, and no confidence intervals separate them.
- Baselines were adapted by the authors (same ColBERTv2 index, refined self-ask prompt), so part of the gap reflects prompt-engineering effort per system.
- Falsifier: keep the program and sample counts fixed but replace bootstrapped demos with (i) random training questions showing only gold answers and (ii) hand-written hop demos. If (i) comes close to 51.4, the pipeline structure and self-consistency, not demonstration bootstrapping, explain most of the gain.
- Also give retrieve-then-read the same budget (20 self-consistency samples, same passage count) to separate architecture from compute.