dspy-advanced-module-composition
Use for composing DSPy modules with Ensemble, MultiChainComparison, ensemble voting, sequential pipelines, and multi-program workflows.
Skill by OmidZamani
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/omidzamani-dspy-advanced-module-composition
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md and code. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Python package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/dspy-advanced-module-composition
What's inside
- Skill name
dspy-advanced-module-composition- Description
- Use for composing DSPy modules with Ensemble, MultiChainComparison, ensemble voting, sequential pipelines, and multi-program workflows.
- License
- MIT
- Instructions
- 282 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Agent Skills spec issues
- allowed-tools: must be a space-separated string
Files (2)
- SKILL.md
- example.py
SKILL.md (first lines)
# DSPy Advanced Module Composition
## Goal
Compose complex DSPy programs using the Ensemble optimizer, MultiChainComparison for reasoning synthesis, and sequential module patterns.
## When to Use
- Need consensus from multiple approaches
- Comparing different reasoning strategies
- Building robust pipelines with fallbacks
- Complex multi-step workflows with branching
- Ensemble methods for improved accuracy
## Related Skills
- Design modules: [dspy-custom-module-design](../dspy-custom-module-design/SKILL.md)
- Define signatures: [dspy-signature-designer](../dspy-signature-designer/SKILL.md)
- Evaluate performance: [dspy-evaluation-suite](../dspy-evaluation-suite/SKILL.md)
## Inputs
| Input | Type | Description |
|-------|------|-------------|
| `modules` | `list[dspy.Module]` | Modules to compose |
| `composition_type` | `str` | "ensemble", "sequential", "comparison" |
## Outputs
| Output | Type | Description |
|--------|------|-------------|
| `composed_program` | `dspy.Module` | Composed multi-module program |
## Workflow
### Phase 1: Ensemble Voting
Combine multiple programs using the Ensemble optimizer:
```python
import dspy
from dspy.teleprompt import Ensemble
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini"))
# Define a signature for the task
class BasicQA(dspy.Signature):
"""Answer questions with short factoid answers."""
question = dspy.InputField()
answer = dspy.OutputField()
# Create multiple program instances (should be optimized/compiled programs)
# For simple demonstration, we'll use different predictors
program1 = dspy.Predict(BasicQA)
program2 = dspy.ChainOfThought(BasicQA)
program3 = dspy.Predict(BasicQA)
# Ensemble is an optimizer that compiles programs together
ensemble = Ensemble(reduce_fn=dspy.majority)
ensembled_program = ensemble.compile([program1, program2, program3])
# Use the ensembled program
result = ensembled_program(question="What is 2 + 2?")
print(result.answer) # Voted answer
```
### Phase 2: MultiChainComparison
Compare multiple reasoning attempts:
```python
import dspy
class BasicQA(dspy.Signature):
"""Answer questions with short factoid answers."""
question = dspy.InputField()
answer = dspy.OutputField(desc="often between 1 and 5 words")
class ComparisonPipeline(dspy.Module):
def __init__(self):
# Generate multiple reasoning attempts
self.cot = dspy.ChainOfThought(BasicQA)
# Compare M attempts and select best
# Must pass a Signature class, not a string
self.compare = dspy.MultiChainComparison(
BasicQA,
M=3, # Number of attempts to compare
temperature=0.7
)
def forward(self, question):
# Generate multiple completions to compare
# Each completion must have rationale/reasoning field
completions = [
self.cot(question=question)
for _ in range(3)
]
# MultiChainComparison synthesizes them into best answer
# Pass completions as positional arg, not keyword arg
return self.compare(completions, question=question)
# Usage
dspy.configure(lm=dspy.LM("openai/gpt-4o-mini"))
pipeline = ComparisonPipeline()
result = pipeline(question="Explain quantum computing")
print(f"Best answer: {result.answer}")
print(f"Rationale: {result.rationale}")
```
### Phase 3: Sequential Composition
Chain modules for multi-step workflows:
```python
import dspy
# Define signatures for each stepFrom OmidZamani/dspy-skills, MIT.
More from OmidZamani/dspy-skills
- 0.674score
dspy-haystack-integration
OmidZamani
Use for integrating DSPy with Haystack, optimizing Haystack prompts, improving retrieval pipelines, and extracting DSPy prompts.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-adapters-multimodal
OmidZamani
Use for DSPy adapter selection, JSONAdapter, XMLAdapter, ChatAdapter, native function calling, structured outputs, and multimodal inputs like dspy.Image or…
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-evaluation-suite
OmidZamani
Use for evaluating DSPy programs with Evaluate, answer_exact_match, SemanticF1, custom metrics, baselines, and program comparisons.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-optimizer-selection
OmidZamani
Use to choose or compare DSPy optimizers including LabeledFewShot, BootstrapFewShot, MIPROv2, SIMBA, GEPA, BootstrapFinetune, Ensemble, and BetterTogether.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-production-deployment
OmidZamani
Use for deploying DSPy with save/load, configure_cache, restrict_pickle, track_usage, async execution, streaming, and production runtime controls.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-rag-pipeline
OmidZamani
Use for RAG pipelines, retrieval augmented generation, ColBERTv2, context retrieval, multi-hop RAG, and grounded DSPy answers.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-signature-designer
OmidZamani
Use for DSPy signatures, InputField, OutputField, typed inputs and outputs, signature classes, and Pydantic-style structured schemas.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-simba-optimizer
OmidZamani
Use for SIMBA optimization, mini-batch introspective optimization, self-reflective rules, stochastic ascent, and numeric-metric optimization.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-reasoning-modules
OmidZamani
Use for DSPy reasoning modules including RLM, ProgramOfThought, CodeAct, Parallel, sandboxed execution, and long-context workflows.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-custom-module-design
OmidZamani
Use for creating custom DSPy modules, extending dspy.Module, reusable components, stateful modules, serialization, and module testing.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-debugging-observability
OmidZamani
Use for debugging DSPy programs, inspect_history, tracing LLM calls, custom callbacks, observability, monitoring, and cost tracking.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-embedding-retrieval
OmidZamani
Use for DSPy retrieval with dspy.Embedder, dspy.Embeddings, FAISS indexes, semantic search, and local or hosted embedding models.
SkillCFreshness: C★ 124Claude Code +9
Signals
- Stars
- 124
- Forks
- 13
- Open issues
- 1
- Last commit (this folder)
- Jun 23, 2026 (4 months ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/OmidZamani/dspy-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from OmidZamani
- 0.674score
dspy-haystack-integration
OmidZamani
Use for integrating DSPy with Haystack, optimizing Haystack prompts, improving retrieval pipelines, and extracting DSPy prompts.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-finetune-bootstrap
OmidZamani
Use for BootstrapFinetune, fine-tuning DSPy models, teacher-student distillation, weight optimization, and lower-cost deployment.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-adapters-multimodal
OmidZamani
Use for DSPy adapter selection, JSONAdapter, XMLAdapter, ChatAdapter, native function calling, structured outputs, and multimodal inputs like dspy.Image or…
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-custom-module-design
OmidZamani
Use for creating custom DSPy modules, extending dspy.Module, reusable components, stateful modules, serialization, and module testing.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-debugging-observability
OmidZamani
Use for debugging DSPy programs, inspect_history, tracing LLM calls, custom callbacks, observability, monitoring, and cost tracking.
SkillCFreshness: C★ 124Claude Code +9 - 0.668score
dspy-embedding-retrieval
OmidZamani
Use for DSPy retrieval with dspy.Embedder, dspy.Embeddings, FAISS indexes, semantic search, and local or hosted embedding models.
SkillCFreshness: C★ 124Claude Code +9
Cite this page
dspy-advanced-module-composition skill. Agent Mart. https://agentmart.dev/skills/omidzamani-dspy-advanced-module-composition (last updated 2026-10-24)