DSPy
A framework for programming language models with compositional Python code instead of hand-written prompts, with algorithms that optimize the prompts and weights of the resulting pipeline.
DSPy lets a developer build modular AI systems, such as classifiers, retrieval-augmented generation pipelines or agent loops, as Python code rather than as brittle hand-tuned prompt strings. The name stands for Declarative Self-improving Python: a program is written declaratively, and DSPy's optimizers then adjust its prompts and, where supported, model weights to improve output quality.
The project publishes a series of research papers behind its optimization techniques, including work on compiling declarative language model calls into self-improving pipelines, optimizing instructions and demonstrations for multi-stage programs, and reflective prompt evolution.
It installs from PyPI, is written in Python, and is licensed under the MIT license.