What problem does it solve?
DSPy eliminates ad-hoc prompt engineering and brittle orchestration when building multi-component language-model systems by providing a declarative programming model, automated prompt optimizers, and modular building blocks for reliable pipelines.
Core Features & Use Cases
- Declarative LM Programming: Define structured Signatures and compose modules like Predict, ChainOfThought, ProgramOfThought, and ReAct to express tasks as input→output transforms.
- Automatic Prompt Optimization: Improve prompts and few-shot examples automatically using teleprompters such as BootstrapFewShot, MIPRO, and BootstrapFinetune to boost accuracy.
- Modular RAG & Agents: Build retrieval-augmented generation, reranking, multi-stage QA, and tool-using agents with reusable components and retrievers.
- Use Case: Assemble an optimized multi-hop RAG pipeline that retrieves relevant passages, reranks candidates, and produces verified answers, then iteratively optimize the prompts using labeled examples.
Quick Start
Use DSPy to create a ChainOfThought module that answers factual questions and optimize it with BootstrapFewShot using your labeled question-answer examples.