DSPy logo

DSPy

Free

The framework for programming—not prompting—foundation models ![GitHub Repo stars](https://img.shields.io/github/stars/stanfordnlp/dspy?style=social)

FreeFree tier
Type
Open Source

About DSPy

DSPy is a framework for programming—rather than prompting—language models, developed by the Stanford NLP group. It enables fast iteration on building modular AI systems and provides algorithms for optimizing prompts and weights. DSPy stands for Declarative Self-improving Python. Instead of writing brittle prompts, users write compositional Python code, and DSPy teaches the language model to deliver high-quality outputs. It supports building simple classifiers, sophisticated RAG pipelines, agent loops, multi-stage programs, and more. DSPy is open-source and available on GitHub.

Key Features

Compositional Python code replaces brittle prompts
Algorithms for optimizing prompts and weights of language models
Supports building classifiers, RAG pipelines, and agent loops
Self-improving pipelines that compile declarative LM calls
Declarative Self-improving Python (DSPy) paradigm
Fast iteration on modular AI systems

Pros & Cons

Pros
  • Eliminates the need for brittle, hand-crafted prompts
  • Modular and compositional approach to AI system design
  • Built-in algorithms for optimizing prompts and weights
  • Strong research backing from Stanford NLP
  • Open-source with active community and documentation
  • Supports a wide range of model architectures and tasks
Cons
  • Requires programming knowledge (Python) to use
  • Learning curve for understanding the declarative paradigm
  • May be overkill for very simple tasks where direct prompting suffices

Best For

Building simple text classifiersSophisticated retrieval-augmented generation (RAG) pipelinesAutonomous agent loopsMulti-stage language model programsFine-tuning and prompt optimization combinedGenerating Wikipedia-like articles from scratchExtreme multi-label classificationKnowledge-intensive NLP tasks

FAQ

What does DSPy stand for?
DSPy stands for Declarative Self-improving Python.
Is DSPy free to use?
Yes, DSPy is open-source and free. You can install it via pip or from the GitHub repository.
What can I build with DSPy?
DSPy can be used to build simple classifiers, retrieval-augmented generation (RAG) pipelines, agent loops, multi-stage language model programs, and more.
How does DSPy differ from prompting?
Instead of writing prompts manually, you write compositional Python code and DSPy optimizes the prompts and weights automatically.