Demonstrate-Search-Predict: Composing retrieval and language models for knowledge-intensive NLP

Omar Khattab, Keshav Santhanam, Xiang Lisa Li, David Hall, Percy Liang +2 more
12/28/2022
422 citations
cs.CLcs.IR

Official code: stanfordnlp/dspy (38,910 stars, Python, MIT, last commit 2026-05-04).

Abstract

Retrieval-augmented in-context learning has emerged as a powerful approach for addressing knowledge-intensive tasks using frozen language models (LM) and retrieval models (RM). Existing work has combined these in simple "retrieve-then-read" pipelines in which the RM retrieves passages that are inserted into the LM prompt.

Show full abstract

To begin to fully realize the potential of frozen LMs and RMs, we propose Demonstrate-Search-Predict (DSP), a framework that relies on passing natural language texts in sophisticated pipelines between an LM and an RM. DSP can express high-level programs that bootstrap pipeline-aware demonstrations, search for relevant passages, and generate grounded predictions, systematically breaking down problems into small transformations that the LM and RM can handle more reliably. We have written novel DSP programs for answering questions in open-domain, multi-hop, and conversational settings, establishing in early evaluations new state-of-the-art in-context learning results and delivering 37-120%, 8-39%, and 80-290% relative gains against the vanilla LM (GPT-3.5), a standard retrieve-then-read pipeline, and a contemporaneous self-ask pipeline, respectively. We release DSP at https://github.com/stanfordnlp/dsp

View on arXivView PDF

Code Implementations(1)

stanfordnlp/dspyOfficial100%
MIT

DSPy: The framework for programming—not prompting—language models

38,9103,481Python, JavaScriptJan 9, 20237 months agoMIT

Similar Papers

Cite this paper

@article{khattab2022demonstratesearchpredict,
  title  = {Demonstrate-Search-Predict: Composing retrieval and language models for knowledge-intensive NLP},
  author = {Omar Khattab and Keshav Santhanam and Xiang Lisa Li and David Hall and Percy Liang and Christopher Potts and Matei Zaharia},
  year   = {2022},
  eprint = {2212.14024},
  archivePrefix = {arXiv},
  url    = {https://arxiv.org/abs/2212.14024}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2212.14024.svg)](https://codeofpaper.com/paper/2212.14024)

Discussion