DSPy
DSPy is a Python framework for building AI systems by expressing tasks as structured signatures instead of prompts, enabling maintainable, modular programs with modules and optimizers that tune prompts and weights.
Visit stanfordnlp/dspyOverview
DSPy is a Python framework for building AI systems. Developers declare tasks as typed signatures and compose modules, then use optimizers to tune prompts and weights against a metric. The documentation covers tools, RAG, agents, multimodal fields, evaluation, and deployment topics.
Key Features
- Structured signatures declare tasks as typed inputs and outputs instead of prompts.
- Reusable modules such as Predict, ChainOfThought, and ReAct change execution strategy without rewriting the task.
- Optimizers compile a program against a metric to improve output quality.
- Programs can compose multiple signatures and modules using plain Python control flow.
- Documented capabilities include tool use, RAG pipelines, agent loops, and image fields for multimodal tasks.
Use Cases
- Building simple classifiers, sophisticated RAG pipelines, and agent loops.
- Extracting structured information from emails, support tickets, or other text.
- Creating tool-using agents with ReAct and function tools.
- Handling multimodal tasks that use images as signature fields.
Getting Started
- Install DSPy with pip install dspy.
- Follow the Getting Started documentation to build a first program and expand signatures.
Deployment & Requirements
- Requires Python 3.10 or newer.
Before You Adopt
- License: MIT. Review its terms before using, modifying, or distributing the project.
- Some optimization capabilities are explicitly labeled experimental.