dspy

Compile declarative DSPy program signatures into optimized prompt and few-shot pipelines.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

This Skill removes manual, trial-and-error prompt engineering by letting you define LM tasks declaratively and automatically optimize prompts using evaluation data.

Core Features & Use Cases

  • Declarative LM programs (signatures): Define input-to-output task schemas like question → answer, making pipelines easier to maintain and reuse.
  • Modular reasoning workflows: Compose building blocks such as Predict, ChainOfThought, ReAct (tool use), and ProgramOfThought (code execution) for different task types.
  • Automatic prompt optimization: Use DSPy teleprompters/optimizers to improve instruction text and few-shot examples based on a metric and training set.
  • RAG-ready patterns: Build retrieval-augmented generation pipelines and optimize them for better answer quality.

Use it when you need more reliable outputs for QA, classification, extraction, or multi-stage RAG/agent systems, especially when you can supply labeled examples and a scoring metric.

Quick Start

Ask an AI to generate a DSPy module for question answering, then compile it with BootstrapFewShot using your labeled question-answer examples and an exact-match metric.

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 instead of manual trial and error?

Automate prompt optimization by compiling declarative program signatures into self-improving pipelines using DSPy teleprompters, which automatically refine instruction text and few-shot examples based on a defined evaluation metric and training data.

How do I build a retrieval-augmented generation pipeline with consistent output quality?

Build a retrieval-augmented generation pipeline by composing modular reasoning blocks like ChainOfThought and ReAct, then apply automatic prompt optimization using teleprompters with a scoring metric over validation data to ensure consistent answer quality.

Can I use declarative LM programming for tool-using agents and structured extraction?

Declarative LM programming supports tool-using agents and structured extraction through modular workflows like ReAct and ProgramOfThought, allowing you to define input-to-output schemas and compile them for consistent execution quality.

What do I need to set up before compiling declarative LM programs for automatic optimization?

You need to define input-to-output task signatures, configure an LM provider backend like OpenAI or Anthropic, and supply labeled train/validation data alongside a custom evaluation metric to run the teleprompter optimization successfully.

Does automatic prompt optimization work with OpenAI and Anthropic models?

Automatic prompt optimization works with both OpenAI and Anthropic models, requiring you to configure the respective provider backend in your environment before executing the teleprompter compilation over your labeled dataset.

When should I avoid declarative LM programming for prompt pipelines?

Avoid declarative LM programming when you lack labeled examples or a clear scoring metric, as teleprompters require train/validation data and an evaluation function to successfully compile and optimize the declarative program signatures.