stanfordnlp/dspy is a Python library for building modular language-model applications with compositional Python code. It supports prompt and model-weight optimization, as well as constructing retrieval-augmented generation pipelines, agent loops, and classifiers.
Project overview
It treats language-model application development as modular programming and provides optimization algorithms for prompts and model weights, addressing brittle hand-written prompts and slow iteration cycles.
Project type
AI Coding · RAG · Prompt Engineering
Use cases
Knowledge Q&A · Automation
Deployment
Refer to project documentation
License
MIT
Best for
Developers, AI engineers, and researchers who need to build language-model applications in compositional Python code.
Teams working on prompt optimization, model-weight optimization, retrieval-augmented generation pipelines, agent loops, or language-model classifiers.
Key capabilities
Lets developers build modular AI systems using compositional Python code rather than brittle prompts.
Provides algorithms for optimizing prompts used by language-model programs.
Provides algorithms for optimizing model weights within language-model applications.
Supports building retrieval-augmented generation pipelines as modular language-model programs.
Supports building agent loops as modular language-model programs.
Supports building simple classifiers with language models.
Limitations and risks
The README directs users to the external DSPy documentation site for detailed documentation.
The documented interface requires users to write compositional Python code.
Getting started
The README provides the command `pip install dspy` as the documented first step.
Evidence and sources
GitHub project description: DSPy: The framework for programming—not prompting—language models
README: DSPy is the framework for _programming—rather than prompting—language models_. It allows you to iterate fast on **building modular AI systems** and offers algorithms for **optimiz…
README: ```bash pip install dspy ```
README: To install the very latest from `main`: ```bash pip install git+https://github.com/stanfordnlp/dspy.git ```
README: If you're looking to understand the underlying research, this is a set of our papers: