stanfordnlp/dspy
DSPy: The framework for programming—not prompting—language models
What it solves
DSPy replaces the brittle, manual process of "prompt engineering" with a systematic programming approach. It eliminates the need to constantly tweak text prompts by hand, allowing developers to build modular AI systems that automatically optimize their own performance.
How it works
Instead of writing static prompts, you define your AI system using compositional Python code. DSPy acts as a compiler that takes your code and "teaches" the language model how to deliver high-quality outputs. It uses algorithms to automatically optimize the prompts and weights of your pipeline, whether you are building simple classifiers, complex retrieval systems (RAG), or agent loops.
Who it’s for
It is designed for developers and researchers building modular AI applications who want to move away from trial-and-error prompting toward a more reliable, programmatic way of developing language model pipelines.
Highlights
- Declarative programming model for AI pipelines.
- Automated optimization of prompts and model weights.
- Supports complex architectures like RAG and agentic loops.
- Modular design that encourages code reuse and fast iteration.
- Built-in support for computational constraints to self-refine outputs.
Related
- Project
- Project
- Project
- Project
- Project