DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines

AI-generated keywords: ML community prompting language models DSPy programming model LM pipelines optimization

AI-generated Key Points

The license of the paper does not allow us to build upon its content and the key points are generated using the paper metadata rather than the full article.

  • The researchers are exploring techniques for training language models (LMs) to solve complex tasks.
  • Existing methods rely on hard-coded "prompt templates" discovered through trial and error.
  • DSPy is a programming model that abstracts LM pipelines as text transformation graphs.
  • LMs are invoked through declarative modules in DSPy, which can learn how to apply compositions of prompting, finetuning, augmentation, and reasoning techniques by creating and collecting demonstrations.
  • A compiler has been designed to optimize DSPy pipelines based on a given metric.
  • Two case studies demonstrate the effectiveness of DSPy programs in expressing and optimizing sophisticated LM pipelines.
  • DSPy programs can reason about math word problems, tackle multi-hop retrieval tasks, answer complex questions, and control agent loops.
  • DSPy pipelines outperformed standard few-shot prompting by over 25% and 65% in two case studies.
  • DSPy programs remained competitive with approaches relying on expert-written prompt chains for proprietary GPT-3.5 even when compiled for open and relatively small LMs like the 770M-parameter T5 and llama2-13b-chat models.
Also access our AI generated: Comprehensive summary, Lay summary, Blog-like article; or ask questions about this paper to our AI assistant.

Authors: Omar Khattab, Arnav Singhvi, Paridhi Maheshwari, Zhiyuan Zhang, Keshav Santhanam, Sri Vardhamanan, Saiful Haq, Ashutosh Sharma, Thomas T. Joshi, Hanna Moazam, Heather Miller, Matei Zaharia, Christopher Potts

Abstract: The ML community is rapidly exploring techniques for prompting language models (LMs) and for stacking them into pipelines that solve complex tasks. Unfortunately, existing LM pipelines are typically implemented using hard-coded "prompt templates", i.e. lengthy strings discovered via trial and error. Toward a more systematic approach for developing and optimizing LM pipelines, we introduce DSPy, a programming model that abstracts LM pipelines as text transformation graphs, i.e. imperative computational graphs where LMs are invoked through declarative modules. DSPy modules are parameterized, meaning they can learn (by creating and collecting demonstrations) how to apply compositions of prompting, finetuning, augmentation, and reasoning techniques. We design a compiler that will optimize any DSPy pipeline to maximize a given metric. We conduct two case studies, showing that succinct DSPy programs can express and optimize sophisticated LM pipelines that reason about math word problems, tackle multi-hop retrieval, answer complex questions, and control agent loops. Within minutes of compiling, a few lines of DSPy allow GPT-3.5 and llama2-13b-chat to self-bootstrap pipelines that outperform standard few-shot prompting (generally by over 25% and 65%, respectively) and pipelines with expert-created demonstrations (by up to 5-46% and 16-40%, respectively). On top of that, DSPy programs compiled to open and relatively small LMs like 770M-parameter T5 and llama2-13b-chat are competitive with approaches that rely on expert-written prompt chains for proprietary GPT-3.5. DSPy is available at https://github.com/stanfordnlp/dspy

Submitted to arXiv on 05 Oct. 2023

Ask questions about this paper to our AI assistant

You can also chat with multiple papers at once here.

The license of the paper does not allow us to build upon its content and the AI assistant only knows about the paper metadata rather than the full article.

AI assistant instructions?

Results of the summarizing process for the arXiv paper: 2310.03714v1

This paper's license doesn't allow us to build upon its content and the summarizing process is here made with the paper's metadata rather than the article.

The is actively exploring techniques for and building to solve complex tasks. However, existing often rely on hard-coded "prompt templates" discovered through trial and error. To address this limitation, researchers have introduced DSPy, a programming model that abstracts LM pipelines as text transformation graphs. In DSPy, LMs are invoked through declarative modules that can learn how to apply compositions of prompting, finetuning, augmentation, and reasoning techniques by creating and collecting demonstrations. To optimize DSPy pipelines, the researchers have designed a compiler that maximizes a given metric. They conducted two case studies to demonstrate the effectiveness of DSPy programs in expressing and optimizing sophisticated LM pipelines. These pipelines can reason about math word problems, tackle multi-hop retrieval tasks, answer complex questions, and control agent loops. Remarkably, within minutes of compiling a few lines of DSPy code, and were able to self-bootstrap pipelines that outperformed standard few-shot prompting by over 25% and 65%, respectively. Moreover, surpassed expert-created demonstrations by up to 5-46% and 16-40%, respectively.<br> <line-break> Even when compiled for open and relatively small LMs like the 770M-parameter T5 and llama2-13b-chat models,< kd>DSPy programs </ kd > remained competitive with approaches relying on expert-written prompt chains for proprietary GPT-3.5.
Created on 17 Feb. 2024
Available in other languages: fr

Assess the quality of the AI-generated content by voting

Score: 0

Why do we need votes?

Votes are used to determine whether we need to re-run our summarizing tools. If the count reaches -10, our tools can be restarted.

The previous summary was created more than a year ago and can be re-run (if necessary) by clicking on the Run button below.

The license of this specific paper does not allow us to build upon its content and the summarizing tools will be run using the paper metadata rather than the full article. However, it still does a good job, and you can also try our tools on papers with more open licenses.

Similar papers summarized with our AI tools

Navigate through even more similar papers through a

tree representation

Look for similar papers (in beta version)

By clicking on the button above, our algorithm will scan all papers in our database to find the closest based on the contents of the full papers and not just on metadata. Please note that it only works for papers that we have generated summaries for and you can rerun it from time to time to get a more accurate result while our database grows.

Disclaimer: The AI-based summarization tool and virtual assistant provided on this website may not always provide accurate and complete summaries or responses. We encourage you to carefully review and evaluate the generated content to ensure its quality and relevance to your needs.