Skip to content

DSPy

A framework for programming language models with optimisable modules instead of hand-written prompts.

DSPy reframes the work: instead of hand-tuning prompt strings, you declare modules with typed inputs and outputs and let DSPy compile and optimise the prompts against a metric and examples.

It is a genuinely different mental model (closer to programming than prompting) and it shines when you have data to optimise against and care about squeezing out quality systematically.

Where it fits

A fit when prompt quality is critical, you have examples to optimise against, and you want that tuning done by a compiler rather than by hand.

Where it does not fit

The learning curve and the need for evaluation data make it heavy for a simple, one-off prompt.

Alternatives to DSPy

The closest options on the map, and where each fits instead.

Pairs with

Commonly used alongside it.