dspy

Build and optimize declarative language model programs with typed signatures and optimizer-driven prompt search.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

DSPy removes the guesswork from prompt engineering by letting you define language model tasks as reusable, testable programs instead of hand-tuned prompts. It helps you build systems that are easier to maintain, improve, and port across models.

Core Features & Use Cases

  • Declarative LM programming: Describe inputs and outputs with signatures, then let DSPy handle the prompting details.
  • Automated optimization: Improve prompts and few-shot examples with teleprompters such as BootstrapFewShot, MIPRO, and BootstrapFinetune.
  • Multi-stage AI workflows: Compose modules for RAG, agents, classification, structured extraction, and reasoning pipelines.
  • Real-world use case: A research team can build a question-answering system that retrieves documents, reasons over them, evaluates accuracy, and iteratively improves performance with training data.

Quick Start

Ask the assistant to create a DSPy-based Python example for a question-answering pipeline with retrieval, reasoning, and prompt optimization.

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 LLM pipelines?

Automated prompt optimization uses optimizer-driven prompt search to iteratively improve language model programs. Teleprompters like BootstrapFewShot and MIPRO automatically generate and validate few-shot examples to enhance multi-stage reasoning performance.

What is declarative language model programming and when do I need it?

Declarative language model programming defines inputs and outputs using typed signatures, abstracting prompt engineering details. You need it for modular pipelines, retrieval-augmented generation, and multi-stage reasoning workflows to ensure maintainable, repeatable performance.

How do I build multi-stage AI agents for retrieval-augmented generation?

Building multi-stage AI agents for retrieval-augmented generation involves composing declarative modules for document retrieval, reasoning, and classification. This approach satisfies typed signatures and integrates deterministically with external calculation tools.

Does automated prompt optimization work with existing evaluation metrics?

Automated prompt optimization works directly with existing evaluation metrics by applying optimizer-driven prompt search. Teleprompters evaluate candidate prompts against your defined metrics to iteratively bootstrap effective few-shot examples.

What is the best way to structure classification and structured prediction tasks?

The best way to structure classification and structured prediction tasks is using typed signatures to define expected inputs and outputs. This declarative approach allows optimizers to handle prompting details and evaluate accuracy automatically.

Why does hand-tuned prompt engineering fail to scale for complex reasoning pipelines?

Hand-tuned prompt engineering fails to scale for complex reasoning pipelines because manual adjustments are difficult to maintain and port across models. Declarative LM programming solves this by treating tasks as reusable, testable programs with automated optimization.