DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines
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

TL;DR
DSPy is a programming model that transforms language model pipelines into optimized, self-improving text transformation graphs, enabling efficient development and significant performance improvements across complex tasks.
Contribution
Introduces DSPy, a declarative programming framework that abstracts LM pipelines as parameterized, optimizable text transformation graphs, facilitating systematic development and enhancement of LM-based solutions.
Findings
DSPy pipelines outperform standard few-shot prompting by over 25% and 65%.
DSPy enables small open models to match proprietary prompt chain performance.
DSPy programs can self-bootstrap and optimize complex reasoning tasks.
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…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Code & Models
Videos
Supercharging RAG with Generative Feedback Loops from Weaviate· youtube
Taxonomy
TopicsTopic Modeling · Natural Language Processing Techniques · Software Engineering Research
MethodsGated Linear Unit · {Dispute@FaQ-s}How to file a dispute with Expedia? · Multi-Head Attention · Attention Is All You Need · Cosine Annealing · Linear Warmup With Cosine Annealing · 15 Ways to Contact How can i speak to someone at Delta Airlines · Dropout · Byte Pair Encoding · Attention Dropout
