dspy-bootstrap-few-shot

Installation
SKILL.md

Bootstrap Few-Shot Demonstrations

Guide the user through using dspy.BootstrapFewShot to automatically generate and select high-quality few-shot demonstrations for their DSPy program. This is the simplest optimizer and the recommended first step before trying heavier optimizers.

What is BootstrapFewShot

dspy.BootstrapFewShot takes your program, a training set, and a metric, then:

  1. Runs your program on each training example
  2. Keeps the traces (input/output pairs) where the metric passes
  3. Attaches the best traces as few-shot demonstrations to your program's predictors

The result is a copy of your program with working examples baked into the prompt — so the LM sees "here's how I solved similar problems" every time it runs.

optimizer = dspy.BootstrapFewShot(metric=metric, max_bootstrapped_demos=4)
optimized = optimizer.compile(my_program, trainset=trainset)
Related skills

More from lebsral/dspy-programming-not-prompting-lms-skills

Installs
5
GitHub Stars
5
First Seen
Mar 17, 2026