DSPy
by Stanford NLP
Programming, not prompting. Declare what you want, compile prompts and weights against an objective.
OSS
DSPy
Added 17 May 2026
Overview
DSPy from Stanford NLP flips the prompt-engineering paradigm. You declare modules with input and output signatures, an objective, and a dataset. DSPy compiles prompts (and optionally weights) against the objective. The result is reliable, optimisable LLM pipelines that don't depend on someone's clever wording.
Best for
Best for
Teams who want to optimise their LLM pipelines like code, not edit prompts forever
Use cases
- Build a multi-stage pipeline that can be re-optimised when the model changes
- Replace fragile prompt chains with declarative modules
- Run prompt-and-weight optimisation against a real eval
- Standardise LLM workflows across a research team
Notes
Why it matters
Prompt engineering does not compose and does not optimise. DSPy is the clearest answer to “what does programming an LLM pipeline look like when you treat it like software.”
How teams use it in production
Start with a small, evaluable pipeline. Build the eval first. Then run DSPy optimisation against it. The eval is the asset; the pipeline is the artefact.
What to watch
DSPy’s ideas are leaking into every other framework. Whether the framework itself wins, or the patterns get absorbed, the declarative shift is real.
Pros
- Declarative model that survives provider swaps
- Real optimisation against an eval, not vibes
- Strong research backing, active development
- Pairs naturally with eval and observability tooling
Cons
- Steep learning curve, not a weekend hack
- Optimisation needs a real dataset and metric
- Smaller ecosystem than LangChain or LlamaIndex
Pairs with
Other entries in the index that connect to this one. Click through to see the chain.