dspy

Compile declarative DSPy programs into optimized LLM pipelines with teleprompters.

Updated Apr 9, 2026
One-click install
npx skills add https://github.com/MarbleSodas/Mavis --skill dspy-marblesodas
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/MarbleSodas/Mavis/tree/main/skills/mlops/research/dspy
Command: npx skills add https://github.com/MarbleSodas/Mavis --skill dspy-marblesodas

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires dspy, openai, anthropic, and includes references (resource) components.

What problem does it solve?

DSPy eliminates brittle, manually-tuned prompt engineering by compiling declarative LM programs into self-improving pipelines driven by data and evaluation metrics.

Core Features & Use Cases

  • Declarative LM programs: Define task structure as signatures (inputs → outputs) and compose modules like prediction, chain-of-thought, tool-using agents, and code-based reasoning.
  • Automatic prompt optimization: Use teleprompters/optimizers such as BootstrapFewShot and MIPRO to improve performance using training sets and custom metrics.
  • Production-ready RAG patterns: Build retrieval-augmented generation with multi-stage pipelines, reranking, and retriever configuration for better reliability.
  • Use Case: You have a set of question-answer pairs and want a more reliable QA system; use DSPy to optimize your QA module and evaluate improvements against a held-out dev set.

Quick Start

Configure a DSPy module for your task, then run an optimizer like BootstrapFewShot using a metric that scores the correctness of outputs on your labeled examples.

Frequently Asked Questions about dspy

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automatically optimize LLM prompts instead of manual tuning?▼

Automatic prompt optimization is achieved by defining declarative LM programs as signatures and running a teleprompter optimizer like BootstrapFewShot, which compiles your modules into reliable LLM pipelines using training data and evaluation metrics.

What is the best way to build reliable retrieval-augmented generation pipelines?▼

Building reliable RAG pipelines involves configuring declarative DSPy modules for multi-stage retrieval and reranking, then applying a teleprompter optimizer to improve generation quality against a held-out evaluation set.

How do I evaluate and improve question answering accuracy with labeled data?▼

To evaluate question answering accuracy, define a QA module using DSPy signatures, specify a custom evaluation metric to score correctness, and run an optimizer to produce a module that improves over time with your labeled examples.

Can I use OpenAI and Anthropic models with declarative LM programs?▼

Yes, declarative LM programs support wiring language model providers like OpenAI and Anthropic to execute tasks such as typed information extraction, multi-stage research agents, and code-based reasoning pipelines.

Why does my prompt performance degrade when switching to a new language model?▼

Prompt performance degrades because manually-tuned prompts are brittle; compiling declarative LM programs with a teleprompter optimizer automatically adjusts instructions and few-shot examples to fit the new model's behavior.

Do I need labeled examples to run automatic prompt optimization?▼

Yes, labeled examples are required to run automatic prompt optimization, as teleprompters like BootstrapFewShot and MIPRO rely on training sets and custom evaluation metrics to iteratively improve language model pipelines.