What it does
DSPy provides signatures and modules for composing language-model programs. Optimizers can tune instructions and demonstrations against a metric and dataset.
Why it’s interesting
Treating prompts as program parameters encourages measurable iteration. Results depend on representative examples, metrics, and model access.
Real-world use case
Tune a question-answering pipeline against a small evaluation set before switching models.
What I can learn
- 01
Declarative input and output signatures
See how typed input and output fields define a task contract independently from prompt wording.
- 02
Prompt and demonstration optimization
Understand how an optimizer scores candidate instructions and examples against a metric to improve a program.
- 03
Composable and testable modules
Learn how predictors can be assembled into explicit-input/output modules that are easier to test and reuse.
One thing to explore
Signatures and optimizers
Follow the dspy/signatures implementation and connect it to the concepts above.
Explore the source (opens in a new tab)10-Minute Challenge
Define a structured predictor
Before you start: Python and a supported LLM provider API key; never commit the key.
- Install DSPy in a Python environment.
- Configure a supported model using an environment variable for its API key.
- Run a ChainOfThought predictor on one example and inspect structured fields.
pip install dspy