What problem does it solve?
DSPy removes brittle, manual prompt engineering by letting you define LM programs declaratively and automatically optimize them using feedback from data.
Core Features & Use Cases
- Declarative signatures and composable modules: Define inputs/outputs and build pipelines like QA, RAG, and multi-stage reasoning.
- Automatic prompt optimization with teleprompters: Improve performance by compiling modules against labeled examples and evaluation metrics.
- Reliable RAG and agent workflows: Combine retrieval, reasoning, tool-using patterns, reranking, and typed structured outputs.
Use Case: You want a higher-accuracy RAG QA system that retrieves relevant passages, generates grounded answers, and improves its prompting using a small set of question/answer examples.
Quick Start
Use DSPy to build a RAG question-answering pipeline that defines a signature, configures a retriever, and then compiles the module using BootstrapFewShot with your custom exact-match metric.