# Dspy Optimizer Selection

> Use to choose or compare DSPy optimizers including LabeledFewShot, BootstrapFewShot, MIPROv2, SIMBA, GEPA, BootstrapFinetune, Ensemble, and BetterTogether.

- **Type:** Skill
- **Install:** `agentstack add skill-omidzamani-dspy-skills-dspy-optimizer-selection`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [OmidZamani](https://agentstack.voostack.com/s/omidzamani)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [OmidZamani](https://github.com/OmidZamani)
- **Source:** https://github.com/OmidZamani/dspy-skills/tree/master/skills/dspy-optimizer-selection

## Install

```sh
agentstack add skill-omidzamani-dspy-skills-dspy-optimizer-selection
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# DSPy Optimizer Selection

## Goal

Choose the smallest DSPy optimizer that matches the data, budget, and artifact being tuned. Establish a baseline before compiling anything.

## Selection Matrix

| Need | Start with | Notes |
|------|------------|-------|
| Include a few labeled examples | `dspy.LabeledFewShot` | Random labeled demos; useful as a baseline |
| About 10 examples | `dspy.BootstrapFewShot` | Teacher-generated demos with metric filtering |
| 50+ examples and stronger demo search | `dspy.BootstrapFewShotWithRandomSearch` | Searches multiple demo sets; alias: `dspy.BootstrapRS` |
| Per-input nearest demos | `dspy.KNNFewShot` | Retrieves nearby examples before bootstrapping |
| Instruction-only hill climbing | `dspy.COPRO` | Coordinate ascent over instructions |
| Instruction and demo search | `dspy.MIPROv2` | Bayesian search; install `dspy[optuna]` |
| Mini-batch introspective rules or demos | `dspy.SIMBA` | Uses output variability and self-reflection |
| Rich textual feedback and trace reflection | `dspy.GEPA` | Metric must accept five arguments |
| Distill prompts into model weights | `dspy.BootstrapFinetune` | Requires a fine-tunable LM and `set_lm()` |
| Combine candidate programs | `dspy.Ensemble` | Trades inference cost for robustness |
| Sequence prompt and weight optimization | `dspy.BetterTogether` | Meta-optimizer for configurable optimizer chains |

## Workflow

1. Split data into train and validation sets.
2. Evaluate the uncompiled program with [dspy-evaluation-suite](../dspy-evaluation-suite/SKILL.md).
3. Start with the least expensive optimizer that matches the need.
4. Save the compiled program and compare it against the baseline.
5. Escalate only when the measured gain justifies extra LM calls, fine-tuning, or inference cost.

## Common Paths

### Fast Demo Optimization

Use [dspy-bootstrap-fewshot](../dspy-bootstrap-fewshot/SKILL.md) for the first optimization pass. Move to `BootstrapFewShotWithRandomSearch` when enough examples are available to search multiple demo sets.

### Prompt Search

Use [dspy-miprov2-optimizer](../dspy-miprov2-optimizer/SKILL.md) for instruction and demonstration search. Install its optional dependency first:

```bash
pip install -U "dspy[optuna]>=3.2.1,<3.3"
```

### Reflective Optimization

Use [dspy-gepa-reflective](../dspy-gepa-reflective/SKILL.md) when failures can be described with actionable text. Use [dspy-simba-optimizer](../dspy-simba-optimizer/SKILL.md) for a smaller mini-batch introspective loop with numeric metrics.

### Prompt Plus Weight Optimization

Use [dspy-better-together](../dspy-better-together/SKILL.md) when a fine-tunable LM is available and prompt optimization alone has plateaued.

## Best Practices

1. Keep a held-out validation set.
2. Track optimization cost and inference cost separately.
3. Use reproducible seeds where supported.
4. Avoid claiming one optimizer is universally best; compare measured results.
5. Save intermediate candidates for expensive runs.

## Official Documentation

- **Optimizer guide**: https://dspy.ai/learn/optimization/optimizers/
- **Optimizer API index**: https://dspy.ai/api/optimizers/
- **DSPy releases**: https://github.com/stanfordnlp/dspy/releases

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [OmidZamani](https://github.com/OmidZamani)
- **Source:** [OmidZamani/dspy-skills](https://github.com/OmidZamani/dspy-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-omidzamani-dspy-skills-dspy-optimizer-selection
- Seller: https://agentstack.voostack.com/s/omidzamani
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
