What problem does it solve?
DSPy removes the ad-hoc, brittle process of manual prompt engineering by providing a declarative framework to compose, optimize, and maintain language-model-based systems across development and production.
Core Features & Use Cases
- Declarative Module Composition: Define Signatures and Modules to turn inputs into typed outputs and compose multi-stage pipelines for RAG, agents, classification, and summarization.
- Automatic Prompt & Module Optimization: Improve prompts and few-shot demonstrations programmatically using optimizers like BootstrapFewShot, MIPRO, and BootstrapFinetune.
- Multi-provider & Retrieval Integration: Swap LM providers (OpenAI, Anthropic, local runtimes), configure retrievers, and export optimized modules for production use.
- Use Case: Build a RAG-based QA system that retrieves top passages, applies ChainOfThought reasoning, and is automatically optimized with representative training examples.
Quick Start
Create a ChainOfThought QA module that retrieves three passages, answers concisely, and optimize it using BootstrapFewShot.