dspy

Build and optimize declarative language model pipelines with DSPy.

1|Updated Apr 14, 2026
One-click install
npx skills add https://github.com/eddielueng/hermes-agent-zh --skill dspy-eddielueng
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/eddielueng/hermes-agent-zh/tree/main/skills/mlops/research/dspy
Command: npx skills add https://github.com/eddielueng/hermes-agent-zh --skill dspy-eddielueng

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

DSPy eliminates fragile, manual prompt engineering by letting you build language model systems with declarative components and then optimize them using data and objective metrics.

Core Features & Use Cases

  • Declarative LM programming: Define signatures (inputs → outputs) and compose modules for tasks like QA, extraction, and generation.
  • Automatic prompt optimization: Compile modules with optimizers that search for better instructions/few-shot examples using a metric over examples.
  • Modular pipelines for RAG and agents: Create maintainable systems with retrieval, multi-stage reasoning, and tool-using agent patterns.
  • Use case: Build a RAG question-answering system that retrieves relevant passages, generates answers from retrieved context, and then improves reliability by optimizing against a held-out evaluation metric.

Quick Start

Ask the AI assistant to build a simple DSPy RAG pipeline, then compile it using a small training set and a correctness metric you define.

Frequently Asked Questions about dspy

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

FAQPage Schema
How do I automate prompt optimization for language model pipelines instead of manual engineering?▼

Automatic prompt optimization compiles declarative LM pipelines using optimizers that search for better instructions and few-shot examples from a defined correctness metric. This eliminates fragile manual engineering by relying on objective data.

Can I build a RAG question-answering system using declarative programming with OpenAI or Anthropic models?▼

Yes, you can build a modular RAG pipeline declaratively with DSPy by defining input-output signatures and configuring an LM provider like OpenAI or Anthropic. The system retrieves passages, generates answers, and compiles for reliability.

How does declarative LM programming work for building modular agent systems?▼

Declarative LM programming works by defining signatures for inputs and outputs, then composing modules for tasks like extraction and reasoning. These modular components create maintainable agent workflows and multi-stage pipelines.

How do I evaluate and improve classification and extraction reliability against held-out metrics?▼

You evaluate reliability by defining a specific evaluation metric and compiling modules with optimizers against a held-out training set. The optimizer searches for improved instructions and examples to maximize extraction and classification accuracy.

What is the best way to structure tool-using agent workflows without writing fragile prompts?▼

The best way to structure agent workflows is defining declarative signatures and composing modular components for tool usage. Compiling these modules with appropriate optimizers and evaluation metrics eliminates the need for fragile manual prompts.

Do I need to provide training examples to compile and optimize structured extraction pipelines?▼

Yes, you need to provide a training set and define a correctness metric to compile and optimize the extraction pipelines. The optimizer uses these examples to automatically search for and generate better instructions and few-shot prompts.