DSPy (2023) logo

DSPy (2023)

Free

Prompts as compilable programs — defines the engineering-first paradigm

FreeFree tier
Inputs: textOutputs: text
Type
Open Source

About DSPy (2023)

DSPy is a programming model and compiler that abstracts language model (LM) pipelines as text transformation graphs. Instead of relying on hard-coded prompt templates discovered via trial and error, DSPy introduces declarative modules that are parameterized and can learn how to apply compositions of prompting, finetuning, augmentation, and reasoning techniques. Its compiler automatically optimizes any DSPy pipeline to maximize a given metric, enabling self-improving pipelines that outperform few-shot prompting and expert-created demonstrations. The framework supports a variety of tasks including math word problems, multi-hop retrieval, complex question answering, and agent loops, and works with both proprietary (GPT-3.5) and open (llama2-13b-chat, T5) language models.

Key Features

Declarative modules that compose prompting, finetuning, augmentation, and reasoning techniques
Compiler optimizing any DSPy pipeline to maximize a given metric
Self-bootstrapping pipelines that learn from demonstrations
Support for both proprietary (GPT-3.5) and open (llama2-13b-chat, T5) language models
Outperforms standard few-shot prompting by over 25% (GPT-3.5) and 65% (llama2-13b-chat)

Pros & Cons

Pros
  • Significantly outperforms standard few-shot prompting and expert-created demonstrations
  • Self-improving pipelines without manual prompt engineering
  • Works effectively with relatively small open models (e.g., 770M-parameter T5, llama2-13b-chat)
  • Systematic, engineering-first approach to LM pipeline optimization

Best For

Solving math word problemsMulti-hop retrieval and question answeringComplex question answeringControlling agent loops

FAQ

What is DSPy?
DSPy is a programming model that abstracts language model pipelines as text transformation graphs. It uses declarative modules and a compiler to automatically optimize pipelines for a given metric.
How does DSPy optimize LM pipelines?
DSPy pipelines consist of parameterized modules that can learn to apply prompting, finetuning, augmentation, and reasoning. The DSPy compiler then optimizes the entire pipeline to maximize a specified metric by creating and collecting demonstrations.
What models does DSPy support?
DSPy has been demonstrated with GPT-3.5, llama2-13b-chat, and T5 (770M parameters). It is designed to work with any language model that can be invoked programmatically.