dspy

Declares tasks as signatures and composes modular AI pipelines with teleprompter optimizers.

2|Updated Apr 25, 2026
One-click install
npx skills add https://github.com/john-data-chen/hermes-agent-backup --skill dspy-john-data-chen
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/john-data-chen/hermes-agent-backup/tree/main/skills/mlops/research/dspy
Command: npx skills add https://github.com/john-data-chen/hermes-agent-backup --skill dspy-john-data-chen

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

DSPy enables building modular, self-improving language-model pipelines by declaring tasks as signatures and composing multiple components into cohesive workflows, reducing ad-hoc prompting and brittle integrations.

Core Features & Use Cases

  • Declarative task definitions via signatures and field-based inputs/outputs for robust LM tooling.
  • Modular composition of Predict, ChainOfThought, ReAct, and other building blocks to create complex data-to-decision pipelines.
  • Optimizers (BootstrapFewShot, MIPRO, BootstrapFinetune, COPRO, KNNFewShot) to automatically improve prompts and, optionally, fine-tune models for RAG, agents, and classifiers.
  • Practical patterns for multi-stage pipelines, retrieval-augmented generation, agent systems, and structured information extraction.
  • Extensive references and real-world examples to guide production-ready deployments.

Quick Start

Create a simple DSPy module and run a BootstrapFewShot optimization on a small labeled trainset.

Frequently Asked Questions about dspy

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

FAQPage Schema
How does declarative LM programming work for building self-improving AI pipelines?

Declarative LM programming builds self-improving pipelines by defining tasks as signatures with field-based inputs and outputs, then composing modular components like ChainOfThought or ReAct into cohesive workflows. This replaces ad-hoc prompting with structured, optimizable modules.

How do I automatically optimize RAG and agent prompts without manual tuning?

You can automatically optimize RAG and agent prompts using teleprompter optimizers like BootstrapFewShot, MIPRO, and BootstrapFinetune. These optimizers leverage labeled training data to automatically generate and refine few-shot examples or fine-tune models for your pipelines.

Do I need labeled training data to use prompt optimizers for language model pipelines?

Yes, using prompt optimizers like BootstrapFewShot and MIPRO assumes you have labeled training data available. Providing a trainset allows the optimizers to automatically compile and improve your declarative LM modules for tasks such as classification and retrieval-augmented generation.

What is the best way to build modular AI pipelines for retrieval-augmented generation?

The best way to build modular RAG pipelines is by composing declarative building blocks such as Predict and ChainOfThought. This modular composition allows you to create complex data-to-decision workflows that can be systematically improved using teleprompter optimizers.

Can I fine-tune language models using declarative prompt optimization?

Yes, you can fine-tune language models using the BootstrapFinetune optimizer. Alongside prompt optimization techniques like BootstrapFewShot and MIPRO, BootstrapFinetune enables you to automatically improve and adapt models for RAG, agents, and classifiers.

When should I not use declarative self-improving prompts for my AI workflow?

You should avoid declarative self-improving prompts if you lack access to LM providers or labeled training data. This approach relies on available training data to run teleprompter optimizers, making it unsuitable for zero-shot workflows without evaluation sets.