dspy

Program language models declaratively and optimize prompts automatically.

Updated Apr 30, 2026
One-click install
npx skills add https://github.com/lxh755818-bot/obsidian-vault --skill dspy-lxh755818-bot
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy
Source: https://github.com/lxh755818-bot/obsidian-vault/tree/main/backup/skills/mlops/research/dspy
Command: npx skills add https://github.com/lxh755818-bot/obsidian-vault --skill dspy-lxh755818-bot

SYSTEM DOCUMENTATION & REQUIREMENTS

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

What problem does it solve?

The Skill unit dspy simplifies the creation of efficient AI workflows by allowing users to program language models declaratively, optimize prompts automatically, and build modular AI pipelines.

Core Features & Use Cases

  • Declarative Programming: Users can define AI tasks using high-level descriptions, rather than manual prompt engineering.
  • Prompt Optimization: Data-driven methods are used to automatically optimize prompts for better model performance.
  • Modular AI Pipelines: Users can create maintainable and portable AI workflows by breaking down tasks into modular components.
  • Use Case: Imagine you want to build a system that summarizes scientific papers. dspy allows you to create a pipeline that retrieves papers, extracts key information, and generates summaries, all with minimal code.

Quick Start

To start using dspy, first install the dependencies: pip install dspy openai anthropic. Then, define your signature for the task, such as: class Summarize(dspy.Signature): text = dspy.InputField(), summary = dspy.OutputField(desc="bullet points, 3-5 items"). Use the ChainOfThought module to apply reasoning: cot = dspy.ChainOfThought(Summarize).

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 without manual engineering?

Automatic prompt optimization uses data-driven methods to improve language model performance. You define AI tasks declaratively using high-level descriptions, and the system handles prompt tuning for better results.

How does declarative programming work for language models?

Declarative programming for language models lets you define tasks using high-level descriptions instead of manual prompt engineering. You specify inputs and outputs, and the system handles the underlying prompt logic.

What is the best way to build modular AI pipelines for complex tasks?

The best way to build modular AI pipelines is by breaking down complex tasks into portable components. This approach allows you to create maintainable workflows that retrieve data, extract information, and generate outputs.

Can I use OpenAI and Anthropic models with declarative AI workflows?

Yes, declarative AI workflows support OpenAI and Anthropic models. You need to install the required dependencies to integrate these language models into your modular pipeline construction.

How do I get started with declarative programming for AI summarization?

To start with declarative programming for AI summarization, install dependencies and define a task signature. Use modules like ChainOfThought to apply reasoning and generate bullet-point summaries from input text.

When should I use declarative programming over manual prompt engineering?

You should use declarative programming over manual prompt engineering when building complex AI systems. It simplifies development by automating prompt optimization and creating maintainable, modular pipelines for tasks like scientific paper summarization.