What problem does it solve?
DSPy eliminates brittle, manually-tuned prompt engineering by compiling declarative LM programs into self-improving pipelines driven by data and evaluation metrics.
Core Features & Use Cases
- Declarative LM programs: Define task structure as signatures (inputs → outputs) and compose modules like prediction, chain-of-thought, tool-using agents, and code-based reasoning.
- Automatic prompt optimization: Use teleprompters/optimizers such as BootstrapFewShot and MIPRO to improve performance using training sets and custom metrics.
- Production-ready RAG patterns: Build retrieval-augmented generation with multi-stage pipelines, reranking, and retriever configuration for better reliability.
- Use Case: You have a set of question-answer pairs and want a more reliable QA system; use DSPy to optimize your QA module and evaluate improvements against a held-out dev set.
Quick Start
Configure a DSPy module for your task, then run an optimizer like BootstrapFewShot using a metric that scores the correctness of outputs on your labeled examples.