dspy

Build declarative AI systems with DSPy signatures and automatic optimizers.

Updated Apr 11, 2026
One-click install
npx skills add https://github.com/musical-basics/hermes-build-2 --skill dspy-musical-basics
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/musical-basics/hermes-build-2/tree/main/skills/mlops/research/dspy
Command: npx skills add https://github.com/musical-basics/hermes-build-2 --skill dspy-musical-basics

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Building complex AI systems often requires hand‑crafted prompts, brittle pipelines, and repetitive experimentation. This Skill provides a declarative framework that compiles language‑model calls into maintainable, optimizable modules.

Core Features & Use Cases

  • Signatures & Modules: Define inputs and outputs with Python classes, enabling reusable components such as Predict, ChainOfThought, ReAct, and ProgramOfThought.
  • Automatic Optimizers: Use teleprompters like BootstrapFewShot and MIPRO to generate few‑shot examples and improve prompts without manual tuning.
  • End‑to‑End Pipelines: Assemble retrieval‑augmented generation, multi‑stage agents, and verification loops for robust production workflows.

Quick Start

Use the dspy skill to generate a question‑answering module with automatic few‑shot prompting.

Frequently Asked Questions about dspy

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

FAQPage Schema
How do I optimize LLM prompts automatically without manual tuning?

Automatic prompt optimization uses optimizers like BootstrapFewShot and MIPRO to compile language-model calls into optimized modules by generating few-shot examples, eliminating the need for manual prompt tuning and brittle experimentation.

What is declarative programming for AI pipelines and how does it work?

Declarative AI pipelines use Python signatures and modules to define inputs and outputs for components like ChainOfThought and ReAct, compiling language-model calls into maintainable, optimizable systems rather than hand-crafting prompts.

How do I build a retrieval-augmented generation pipeline with agents?

You can build RAG pipelines and multi-stage agents by assembling reusable modules such as Predict, ChainOfThought, and ReAct into end-to-end workflows with verification loops for robust production systems.

Can I use declarative LM programming with OpenAI, Anthropic, and local LLMs?

Declarative LM programming works across OpenAI, Anthropic, and local LLMs, allowing you to apply signatures, few-shot examples, and automatic optimizers to create prompt-optimized models within a unified framework.

Why does my AI pipeline break when I change language models?

Hand-crafted prompts create brittle pipelines that fail when models change, but declarative modules with automatic optimizers compile and regenerate few-shot examples to maintain performance across different language models.

Do I need Python to use DSPy for prompt optimization?

DSPy requires Python to define inputs and outputs using Python classes and signatures, enabling reusable components and automatic optimizers to generate few-shot examples for improved performance.