dspy-bootstrap-fewshot

Generate and select optimal few-shot demonstrations for DSPy programs.

120|13|Updated Dec 21, 2025
One-click install
npx skills add https://github.com/OmidZamani/dspy-skills --skill dspy-bootstrap-fewshot
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dspy-bootstrap-fewshot
Source: https://github.com/OmidZamani/dspy-skills/tree/main/skills/dspy-bootstrap-fewshot
Command: npx skills add https://github.com/OmidZamani/dspy-skills --skill dspy-bootstrap-fewshot

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill automatically generates and selects high-quality few-shot demonstrations using a teacher model to improve DSPy prompts.

Core Features & Use Cases

  • Auto-generation of bootstrapped and labeled demos
  • Supports teacher settings for generation quality
  • Easy integration into a DSPy workflow

Quick Start

  1. Configure LMs and define a simple QA module
  2. Create a BootstrapFewShot optimizer and compile with trainset
  3. Save the optimized program for production

Frequently Asked Questions about dspy-bootstrap-fewshot

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I automatically generate few-shot demonstrations for my DSPy program?

Few-shot demonstrations can be auto-generated using a teacher model to bootstrap optimal examples from your labeled data. This Skill automatically selects and generates high-quality demonstrations from 10-50 labeled examples, compiling them into your DSPy program without manual selection.

When should I use bootstrap few-shot optimization instead of manual demo selection?

Bootstrap few-shot optimization is ideal when manual demonstration selection becomes tedious, you have 10-50 labeled examples available, and you need demonstrations with reasoning traces for fast prompt optimization. It scales better than hand-picking demos and produces consistent results.

What inputs does a DSPy bootstrap optimizer need to work?

The optimizer requires a DSPy program (dspy.Module), a training set of labeled examples (list[dspy.Example]), and a metric function to evaluate quality. Optional parameters include max_bootstrapped_demos and max_labeled_demos to control the output size.

Can I control how many demonstrations the optimizer generates?

Yes, you can set max_bootstrapped_demos and max_labeled_demos parameters to limit the number of generated and labeled demonstrations. This lets you balance prompt quality against model latency and token cost in production.

What's the difference between bootstrapped and labeled demonstrations?

Bootstrapped demonstrations are generated by a teacher model from your training examples, while labeled demonstrations are hand-annotated examples from your dataset. The optimizer combines both types to create the most effective few-shot prompts.

Do I need to configure a teacher model for demonstration generation?

Yes, a teacher model setting controls the quality and reasoning depth of generated demonstrations. Configuring the teacher LM before compiling ensures the optimizer produces demonstrations with appropriate complexity for your task.