dspy

Build declarative LM programs with automatic prompt optimization and modular pipelines.

Updated Jul 10, 2026
One-click install
npx skills add https://github.com/AvaTar-ArTs/.Agent-skills --skill dspy-avatar-arts
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/AvaTar-ArTs/.Agent-skills/tree/main/skills/mlops/research/dspy
Command: npx skills add https://github.com/AvaTar-ArTs/.Agent-skills --skill dspy-avatar-arts

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve? Manual prompt engineering is brittle and hard to maintain when building complex AI systems like RAG pipelines, agents, or classifiers. This Skill teaches how to program language models declaratively with DSPy and optimize prompts automatically using data-driven methods instead of trial-and-error tuning. ## Core Features & Use Cases - Declarative LM Programming: Define tasks with signatures and compose modules like Predict, ChainOfThought, ReAct, and ProgramOfThought into multi-stage pipelines. - Automatic Prompt Optimization: Use optimizers such as BootstrapFewShot, MIPRO, and BootstrapFinetune to improve module performance from training examples and custom metrics. - Use Case: Build a multi-hop RAG system that retrieves documents, generates search queries, and produces answers, then optimize it with BootstrapFewShot on 50 labeled question-answer pairs to measurably improve accuracy. ## Quick Start Use the dspy skill to build a chain-of-thought question answering module and optimize it with BootstrapFewShot on my training examples.

Frequently Asked Questions about dspy

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

FAQPage Schema
How do I optimize prompts automatically with DSPy?

Use DSPy optimizers like BootstrapFewShot or MIPRO with a metric function and training examples. Call optimizer.compile on your module with the trainset, and DSPy generates few-shot demonstrations or improved instructions automatically.

What is the difference between DSPy Predict and ChainOfThought?

Predict makes direct LM calls without reasoning steps, making it faster for simple tasks. ChainOfThought generates a rationale before the answer, improving accuracy on reasoning tasks at roughly twice the latency.

DSPy vs LangChain for building LLM applications?

DSPy optimizes prompts automatically from data and offers typed signatures with high modularity, while LangChain relies on manual prompt engineering with prebuilt chains. Choose DSPy when you have training data and need systematic improvement.

Does DSPy support local models like Ollama?

Yes, DSPy supports local models through dspy.OllamaLocal by pointing to a local base URL such as http://localhost:11434. It also supports OpenAI, Anthropic, and other providers through dedicated LM classes.

How many training examples does DSPy optimization need?

BootstrapFewShot works with 10-50 examples, while MIPRO benefits from 50-200 examples plus a separate validation set. BootstrapFinetune for weight fine-tuning recommends 100 or more examples.

When should I not use DSPy?

Avoid DSPy for quick one-off prototypes where manual prompting suffices, or when you lack any training data for optimization. Simple chains with existing tools may be faster to build with lighter frameworks.