スキル一覧に戻る
Qredence

dspy-basics

by Qredence

1🍴 1📅 2026年1月23日
GitHubで見るManusで実行

SKILL.md


name: dspy-basics description: Core DSPy fundamentals for signature design, basic modules (Predict, ChainOfThought), and program composition patterns. Use when creating new signatures, building simple DSPy programs, or learning foundational DSPy concepts.

DSPy Basics

Core DSPy fundamentals for signature design, basic modules, and program composition.

Quick Start

Create a signature

import dspy

class MySignature(dspy.Signature):
    """Process input and produce output."""
    input_text = dspy.InputField(desc="Text to process")
    output_text = dspy.OutputField(desc="Processed result")

Use a basic module

# Simple prediction
predict = dspy.Predict(MySignature)
result = predict(input_text="Hello")
print(result.output_text)

# Chain of thought
cot = dspy.ChainOfThought(MySignature)
result = cot(input_text="Hello")
print(result.rationale)  # Reasoning steps
print(result.output_text)

Compose modules

class MyProgram(dspy.Module):
    def __init__(self):
        super().__init__()
        self.step1 = dspy.Predict(Step1Signature)
        self.step2 = dspy.Predict(Step2Signature)

    def forward(self, input_data):
        result1 = self.step1(input=input_data)
        result2 = self.step2(intermediate=result1.output)
        return dspy.Prediction(final_output=result2.output)

When to Use This Skill

Use this skill when:

  • Creating new DSPy signatures
  • Building simple DSPy programs with basic modules
  • Learning foundational DSPy concepts
  • Designing input/output contracts
  • Composing modules sequentially, conditionally, or in parallel

Core Concepts

Signatures

DSPy signatures define the input/output contract for your programs. They specify what data flows into and out of your modules.

Key components:

  • dspy.InputField: Data provided to program
  • dspy.OutputField: Data the program produces
  • Field descriptions: Clear explanations of each field's purpose
  • Type hints: Optional type annotations for validation

See: references/signatures.md for:

  • InputField vs OutputField usage
  • Type hints and validation
  • Design patterns and best practices

Basic Modules

DSPy provides built-in modules that implement common prompting strategies.

Core modules:

  • dspy.Predict: Direct prediction from LM
  • dspy.ChainOfThought: Enables reasoning before final output
  • dspy.ProgramOfThought: Multi-step reasoning with planning

See: references/programs.md for:

  • Module usage patterns
  • Composition strategies
  • Configuration options

Program Composition

DSPy programs are built by composing multiple modules together.

Composition patterns:

  • Sequential: Execute modules in order
  • Conditional: Branch based on intermediate results
  • Parallel: Execute multiple modules concurrently
  • Hierarchical: Compose modules from other modules

See: references/programs.md for detailed patterns

Templates

The templates/ directory provides boilerplate for new signatures:

  • signature-template.py: Starting point for new signatures with common patterns

Progressive Disclosure

This skill uses progressive disclosure to manage context efficiently:

  1. SKILL.md (this file): Quick reference and navigation (~2000 words)
  2. references/: Detailed technical docs loaded as needed

Load reference files only when you need detailed information on a specific topic.

  • dspy-optimization: Teleprompters, metrics, and optimization workflows
  • dspy-advanced: ReAct agents, tool calling, output refinement
  • dspy-configuration: LM setup, caching, and version management

スコア

総合スコア

60/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

+10
説明文

100文字以上の説明がある

0/10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です