DSPy

Active
GitHub Python MIT

Description

Stanford NLP's programming model for LLM pipelines.

Key Features

  • Signature-based — Declare inputs and outputs
  • Optimizers — Auto-tune prompts
  • Multi-model — OpenAI, Anthropic, local
  • Reproducible — Save compiled artifacts
  • Composable — Modular design

Use Cases

💡 Auto-tune prompts for RAG pipelines.
💡 Optimize few-shot prompts for classification.
💡 Programmable LLM abstraction for paper reproduction.

Quick Start

# pip
pip install dspy
import dspy
lm = dspy.OpenAI(model='gpt-4o')
dspy.settings.configure(lm=lm)
classify = dspy.Predict('sentence -> sentiment')
print(classify(sentence='I love this product').sentiment)

Related Projects