DSPy (Declarative Self-improving Python) is a framework for programming language models rather than prompting them. Instead of hand-tuning prompt strings, you write compositional Python code that describes what each step of an AI system takes in and produces, and DSPy supplies algorithms that optimize the prompts and weights of the resulting program.
The same approach covers classifiers, retrieval-augmented generation (RAG) pipelines, and agent loops. Programs are built from signatures, which declare the inputs and outputs of a step, and modules, which implement a step and can be composed; a ReAct module adds tool use. A metric scores program outputs, and an optimizer such as GEPA uses it to improve the program, after which the compiled program can be saved and loaded.
The framework grows out of the Demonstrate-Search-Predict work on composing retrieval and language models, and its optimization methods are described in papers including DSPy: Compiling Declarative Language Model Calls into Self-Improving Pipelines (ICLR 2024), Optimizing Instructions and Demonstrations for Multi-Stage Language Model Programs, and GEPA: Reflective Prompt Evolution Can Outperform Reinforcement Learning.
Features
- Signatures: inline or class-based declarations of a step's input and output fields
- Modules: composable building blocks for LM calls that you swap and combine to change program behavior
- Tools with ReAct: an agent module that calls tools as part of its reasoning loop
- Metrics: scoring functions that define what a good output looks like for optimization
- Optimizers: algorithms such as GEPA that tune instructions, demonstrations, and weights against a metric
- Saving and loading: persist a compiled program and reload it for inference
Built with this
AutoFlow
pingcap/autoflow is a Graph RAG based and conversational knowledge base tool built with TiDB Serverless Vector Storage. Demo: https://tidb.a
Dspy CLI
Been a DSPy fan for a while because it matched how I already think about LLM systems: not as prompts, but as programs yo
Hermes Agent Self-Evolution
Evolves Hermes Agent skills and prompts with DSPy and GEPA, gated by tests and human PR review
Integrated by
CocoIndex
CocoIndex turns codebases, PDFs, Slack, inboxes, and videos into a continuously updated.
Future AGI
OpenTelemetry-based tracing and evaluation instrumentation for voice-AI applications.
Langfuse
Open-source platform for tracing, evaluating, and debugging LLM applications, self-hosted or cloud
Moss
Knowledge-retrieval service that injects semantic search results into an agent's LLM context.
