This is an early release preview. You may encounter bugs.
DSPy logo
Unclaimed

Framework coding training

DSPy

Compose LM pipelines as declarative Python modules, then optimize their prompts and weights algorithmically

A+ 90/100 GitHub score ? This grade is derived from GitHub signals, not user votes. Open for the full breakdown.
No votes yet

01 / About

What DSPy is.

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

02 / Discussion CREDIBILITY-GATED

Discussion

Reading is open to everyone. Posting and voting need a verified identity or a GitHub grade of B or higher.

  • No discussions yet.

03 / Build

Build with DSPy.

Browse the catalogue for frameworks, tools, and harnesses, each scored on real GitHub credibility.

Get DSPy →

Browse the catalogue