dspy

Build declarative language-model pipelines with DSPy Signatures and automatic optimization.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/box755/simlens-research --skill dspy-box755
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/box755/simlens-research/tree/main/skill-packs/AI-Research-SKILLs/16-prompt-engineering/dspy
Command: npx skills add https://github.com/box755/simlens-research --skill dspy-box755

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

DSPy solves the problem of brittle, labor-intensive prompt engineering by letting you define model behavior declaratively and improve it automatically using data and evaluation metrics.

Core Features & Use Cases

  • Declarative LM programming with Signatures: define inputs and outputs as reusable task schemas rather than writing one-off prompts.
  • Modular multi-step systems: compose Predict, ChainOfThought, ProgramOfThought, ReAct, and retrieval modules into RAG and agent workflows.
  • Automatic prompt optimization and few-shot compilation: use teleprompters/optimizers (e.g., BootstrapFewShot, MIPRO, BootstrapFinetune) to search for better instructions using a validation metric.
  • Use Case: build a multi-hop RAG agent that retrieves relevant passages, generates an answer, and then optimizes the prompting strategy on labeled question-answer pairs for higher accuracy.

Quick Start

Use DSPy to compile an optimized question-answering module from your training examples by calling the relevant teleprompter compile method and providing a metric that checks answer correctness.

Frequently Asked Questions about dspy

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

FAQPage Schema
How do I reduce manual prompt engineering for language model pipelines?

Reduce manual prompt engineering by defining declarative task schemas and using automatic optimization. You define inputs and outputs as reusable schemas, then apply teleprompt optimizers to search for better instructions using a validation metric.

Can I build a multi-hop RAG agent with structured extraction using declarative programming?

Yes, you can build a multi-hop RAG agent with structured extraction using declarative programming. Compose Predict, ChainOfThought, ReAct, and retrieval modules into multi-step workflows that generate answers and optimize prompting strategies.

What is automatic prompt optimization and how does it work with few-shot compilation?

Automatic prompt optimization uses teleprompters like BootstrapFewShot and MIPRO to compile better instructions. It searches for improved few-shot examples by evaluating model outputs against a labeled trainset using a custom validation metric.

Do I need labeled training data to run teleprompt optimizers for multi-stage reasoning workflows?

Yes, running teleprompt optimizers for multi-stage reasoning workflows requires labeled training data. You must provide a labeled trainset and define a metric that checks output correctness to successfully compile and optimize the language model pipeline.

How do I define task inputs and outputs without writing one-off prompts?

Define task inputs and outputs without one-off prompts by using declarative Signatures. Signatures act as reusable task schemas that replace manual prompt writing, allowing you to configure language model providers and structure multi-step systems modularly.