dspy

Build declarative language model programs with signatures and teleprompters for RAG pipelines.

Updated May 16, 2026
One-click install
npx skills add https://github.com/jaredcroxton/hermes-mirror --skill dspy-jaredcroxton
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/jaredcroxton/hermes-mirror/tree/main/agents/skills/mlops/research/dspy
Command: npx skills add https://github.com/jaredcroxton/hermes-mirror --skill dspy-jaredcroxton

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

DSPy helps teams move from brittle, manually written prompts to declarative LM programs that can be optimized using data for more reliable outputs.

Core Features & Use Cases

  • Declarative language model programming: define inputs/outputs via signatures and compose reusable modules for tasks like QA, extraction, and generation pipelines.
  • Automatic prompt optimization: use teleprompters to bootstrap demonstrations or iteratively improve instructions using a metric over training/validation sets.
  • RAG and multi-stage systems: combine retrieval, reasoning, reranking, and generation into modular pipelines that improve systematically over time.
  • Common use case: optimize a RAG-based research assistant so it retrieves better context and produces more accurate answers using a dataset of question-answer pairs with an evaluation metric.

Quick Start

Use the dspy skill to turn your question-answer task into an optimized declarative program by defining a DSPy signature and compiling it with BootstrapFewShot 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 optimize prompts automatically instead of writing them manually?

You can optimize prompts automatically by building declarative LM programs with DSPy signatures and compiling them using teleprompters like BootstrapFewShot over labeled training examples. This replaces manual prompt tuning with data-driven compilation.

What is declarative language model programming for RAG pipelines?

Declarative language model programming defines inputs and outputs via signatures, letting you compose reusable modules for retrieval, reasoning, and generation into modular RAG pipelines that improve systematically over time.

How do I build a RAG pipeline that improves retrieval and answer accuracy?

Build a RAG pipeline by defining a DSPy signature for your question-answering task, combining retrieval and generation modules, then compiling it with a teleprompter using a dataset of question-answer pairs and an evaluation metric.

Can I use DSPy with both OpenAI and Anthropic language models?

Yes, DSPy supports composing predictors across different LM providers including OpenAI and Anthropic. You can apply teleprompter-driven compilation and modular RAG workflows across these providers using the same declarative signatures.

Does prompt optimization with teleprompters require labeled training data?

Yes, teleprompters require labeled training and validation sets along with a defined evaluation metric. The teleprompter uses this data to bootstrap demonstrations or iteratively improve instructions for automatic prompt optimization.

What is the best way to structure multi-stage extraction and QA pipelines?

The best way to structure multi-stage pipelines is using DSPy to compose signatures, retrievers, and predictors into modular systems. This allows teleprompters to automatically optimize the entire pipeline for extraction and QA tasks.