
Library Stanford NLP
DSPy
Stanford NLP framework for programming language-model pipelines in Python and optimizing their prompts and weights.
What it is
DSPy (Declarative Self-improving Python) is a framework for building modular AI systems by writing Python code instead of hand-tuned prompts. You declare tasks as typed signatures, choose modules such as Predict, ChainOfThought or ReAct to run them, and use optimizers like GEPA or MIPROv2 to improve prompts and weights against examples and a metric. It is aimed at developers and researchers building classifiers, RAG pipelines and agent loops.
What it's useful for
Replacing brittle prompt strings with testable modules, or automatically optimizing a multi-step LLM pipeline against a labelled dataset.
Key features
- Signatures: typed inputs and outputs instead of prompts
- Modules such as dspy.Predict, dspy.ChainOfThought and dspy.ReAct
- Optimizers such as GEPA and MIPROv2
- Works for classifiers, RAG pipelines and agent loops
- Provider/model string configuration via dspy.LM
How to use it
pip install dspyCommands are copied from the official documentation. Check the docs for the latest version before running them.
Limitations to know
- Recent releases changed the LM integration; a migration guide covers breaking changes
Alternatives
Open-source framework for building LLM agents and apps with a standard interface across model providers.
Open-source Python framework for building LLM agents, event-driven workflows and RAG over your own data.
deepset's open-source Python framework for building RAG pipelines and agent workflows with explicit control over context.
MCP servers for this
MCP reference server that gives an AI client controlled read/write access to chosen local directories.
Open-source MCP server that gives coding agents simplified Figma layout and styling data to implement designs.
AWS Labs' collection of open-source MCP servers for AWS docs, the AWS API, infrastructure as code, databases, costs and more.
Skills for this
Hugging Face's Agent Skills for the Hub CLI, datasets, model training, evaluation, Spaces and SageMaker deployment.
Related resources
Anthropic's family of proprietary large language models (Opus, Sonnet, Haiku tiers) for reasoning, coding and agents.
Open-source Postgres extension that adds a vector type plus exact and approximate nearest-neighbor search.
Arize's source-available, self-hosted AI observability tool for OpenTelemetry tracing, evals, datasets and prompts.
Open-source Python library for building AI agents that browse and act on websites, with an optional hosted cloud.