← Back to all projects

DSPy

Programming with LLMs instead of hand-tuning prompt strings

OfficialMIT
Stars
38.9k
Forks
3.5k
Open issues
739
Last commit
30 Oct 2026

What is DSPy?

You declare what each step should do and supply a metric; the optimiser searches for the prompts and few-shot examples that maximise it. The payoff is that improving a pipeline becomes measurable rather than superstitious. It requires an evaluation set — without one there is nothing to optimise against.

What can you do with DSPy?

  • Compose modules instead of prompts — pip install dspy gives you Python modules you compose into classifiers, RAG pipelines or agent loops, leaving the prompt text as something the framework produces rather than something you hand-write.
  • Optimize weights, not only prompts — The framework includes algorithms for tuning model weights alongside prompts, with the Jul'24 paper covering how fine-tuning and prompt optimization work together.
  • Read the method before adopting — The README indexes the underlying research: GEPA (Jul'25) arguing that reflective prompt evolution can outperform reinforcement learning, the Jun'24 paper on optimizing instructions and demonstrations for multi-stage programs, and the Oct'23 paper on compiling declarative LM calls into self-improving pipelines.

Before you choose DSPy

  • Letting the framework write the prompts means its failures to read the answer back are yours to debug without having written that part. One such failure is reported from the introductory tutorial's own example.Reported in#1539

Star history

15 Aug to 30 Oct · +1.6k

37.2k38.9k

Frequently asked questions

Is DSPy free for commercial use?

DSPy is released under the MIT licence — OSI-approved open source, which permits commercial use.

How can DSPy be deployed?

DSPy is available as Self-hosted / Runs locally.