[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M7CBT2ER5X7ASBS88VTH3H8Q":3,"skill-same:01M7CBT2ER5X7ASBS88VTH3H8Q":62},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":34,"commitSha":35,"skillDirectory":36,"forksCount":14,"repositoryHtmlUrl":37,"repositoryHomepageUrl":6,"ownerHtmlUrl":38,"ownerBlogUrl":39,"ownerDescription":40,"updatedAt":41,"install":42,"resources":55},"01M7CBT2ER5X7ASBS88VTH3H8Q","dspy-bootstrap-fewshot",null,"Use for BootstrapFewShot, bootstrapped demonstrations, teacher-model demos, and low-data DSPy prompt optimization.","shenyimings\u002Fskillet","shenyimings","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F89332218?v=4","01M7C9KHMXPPXMQJCKN78FKB06","Yiming Shen","01M7C9KHP4KS809T2A9T64YDWE",0,"MIT","https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fbenchmark\u002Fwild\u002Fdev\u002Fsuspicious\u002FOmidZamani__dspy-skills__skills__dspy-bootstrap-fewshot\u002FSKILL.md",[],[],"2026-11-15 14:19:17",false,"---\nname: dspy-bootstrap-fewshot\nversion: \"1.0.0\"\ndspy-compatibility: \"3.2.1\"\ntags: [\"optimizer\"]\nrequires-extras: []\ndescription: Use for BootstrapFewShot, bootstrapped demonstrations, teacher-model demos, and low-data DSPy prompt optimization.\nallowed-tools:\n  - Read\n  - Write\n  - Glob\n  - Grep\n---\n\n# DSPy Bootstrap Few-Shot Optimizer\n\n## Goal\n\nAutomatically generate and select optimal few-shot demonstrations for your DSPy program using a teacher model.\n\n## When to Use\n\n- You have **10-50 labeled examples**\n- Manual example selection is tedious or suboptimal\n- You want demonstrations with reasoning traces\n- Quick optimization without extensive compute\n\n## Related Skills\n\n- For more data (200+ examples): [dspy-miprov2-optimizer](..\u002Fdspy-miprov2-optimizer\u002FSKILL.md)\n- For agentic systems: [dspy-gepa-reflective](..\u002Fdspy-gepa-reflective\u002FSKILL.md)\n- Measure improvements: [dspy-evaluation-suite](..\u002Fdspy-evaluation-suite\u002FSKILL.md)\n\n## Inputs\n\n| Input | Type | Description |\n|-------|------|-------------|\n| `program` | `dspy.Module` | Your DSPy program to optimize |\n| `trainset` | `list[dspy.Example]` | Training examples |\n| `metric` | `callable` | Evaluation function |\n| `metric_threshold` | `float` | Numerical threshold for accepting demos (optional) |\n| `max_bootstrapped_demos` | `int` | Max teacher-generated demos (default: 4) |\n| `max_labeled_demos` | `int` | Max direct labeled demos (default: 16) |\n| `max_rounds` | `int` | Max bootstrapping attempts per example (default: 1) |\n| `teacher_settings` | `dict` | Configuration for teacher model (optional) |\n\n## Outputs\n\n| Output | Type | Description |\n|--------|------|-------------|\n| `compiled_program` | `dspy.Module` | Optimized program with demos |\n\n## Workflow\n\n### Phase 1: Setup\n\n```python\nimport dspy\nfrom dspy.teleprompt import BootstrapFewShot\n\n# Configure LMs\ndspy.configure(lm=dspy.LM(\"openai\u002Fgpt-4o-mini\"))\n```\n\n### Phase 2: Define Program and Metric\n\n```python\nclass QA(dspy.Module):\n    def __init__(self):\n        self.generate = dspy.ChainOfThought(\"question -> answer\")\n    \n    def forward(self, question):\n        return self.generate(question=question)\n\ndef validate_answer(example, pred, trace=None):\n    return example.answer.lower() in pred.answer.lower()\n```\n\n### Phase 3: Compile\n\n```python\noptimizer = BootstrapFewShot(\n    metric=validate_answer,\n    max_bootstrapped_demos=4,\n    max_labeled_demos=4,\n    teacher_settings={'lm': dspy.LM(\"openai\u002Fgpt-4o\")}\n)\n\ncompiled_qa = optimizer.compile(QA(), trainset=trainset)\n```\n\n### Phase 4: Use and Save\n\n```python\n# Use optimized program\nresult = compiled_qa(question=\"What is photosynthesis?\")\n\n# Save for production (state-only, recommended)\ncompiled_qa.save(\"qa_optimized.json\", save_program=False)\n```\n\n## Production Example\n\n```python\nimport dspy\nfrom dspy.teleprompt import BootstrapFewShot\nfrom dspy.evaluate import Evaluate\nimport logging\n\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger(__name__)\n\nclass ProductionQA(dspy.Module):\n    def __init__(self):\n        self.cot = dspy.ChainOfThought(\"question -> answer\")\n    \n    def forward(self, question: str):\n        try:\n            return self.cot(question=question)\n        except Exception as e:\n            logger.error(f\"Generation failed: {e}\")\n            return dspy.Prediction(answer=\"Unable to answer\")\n\ndef robust_metric(example, pred, trace=None):\n    if not pred.answer or pred.answer == \"Unable to answer\":\n        return 0.0\n    return float(example.answer.lower() in pred.answer.lower())\n\ndef optimize_with_bootstrap(trainset, devset):\n    \"\"\"Full optimization pipeline with validation.\"\"\"\n    \n    # Baseline\n    baseline = ProductionQA()\n    evaluator = Evaluate(devset=devset, metric=robust_metric, num_threads=4)\n    baseline_score = evaluator(baseline)\n    logger.info(f\"Baseline: {baseline_score:.2%}\")\n    \n    # Optimize\n    optimizer = BootstrapFewShot(\n        metric=robust_metric,\n        max_bootstrapped_demos=4,\n        max_labeled_demos=4\n    )\n    \n    compiled = optimizer.compile(baseline, trainset=trainset)\n    optimized_score = evaluator(compiled)\n    logger.info(f\"Optimized: {optimized_score:.2%}\")\n    \n    if optimized_score > baseline_score:\n        compiled.save(\"production_qa.json\", save_program=False)\n        return compiled\n    \n    logger.warning(\"Optimization didn't improve; keeping baseline\")\n    return baseline\n```\n\n## Best Practices\n\n1. **Quality over quantity** - 10 excellent examples beat 100 noisy ones\n2. **Use stronger teacher** - GPT-4 as teacher for GPT-3.5 student\n3. **Validate with held-out set** - Always test on unseen data\n4. **Start with 4 demos** - More isn't always better\n\n## Limitations\n\n- Requires labeled training data\n- Teacher model costs can add up\n- May not generalize to very different inputs\n- Limited exploration compared to MIPROv2\n\n## Official Documentation\n\n- **DSPy Documentation**: https:\u002F\u002Fdspy.ai\u002F\n- **DSPy GitHub**: https:\u002F\u002Fgithub.com\u002Fstanfordnlp\u002Fdspy\n- **BootstrapFewShot API**: https:\u002F\u002Fdspy.ai\u002Fapi\u002Foptimizers\u002FBootstrapFewShot\u002F\n- **Optimization Guide**: https:\u002F\u002Fdspy.ai\u002Flearn\u002Foptimization\u002Foptimizers\u002F\n","# DSPy Bootstrap Few-Shot Optimizer\n\n## Goal\n\nAutomatically generate and select optimal few-shot demonstrations for your DSPy program using a teacher model.\n\n## When to Use\n\n- You have **10-50 labeled examples**\n- Manual example selection is tedious or suboptimal\n- You want demonstrations with reasoning traces\n- Quick optimization without extensive compute\n\n## Related Skills\n\n- For more data (200+ examples): [dspy-miprov2-optimizer](..\u002Fdspy-miprov2-optimizer\u002FSKILL.md)\n- For agentic systems: [dspy-gepa-reflective](..\u002Fdspy-gepa-reflective\u002FSKILL.md)\n- Measure improvements: [dspy-evaluation-suite](..\u002Fdspy-evaluation-suite\u002FSKILL.md)\n\n## Inputs\n\n| Input | Type | Description |\n|-------|------|-------------|\n| `program` | `dspy.Module` | Your DSPy program to optimize |\n| `trainset` | `list[dspy.Example]` | Training examples |\n| `metric` | `callable` | Evaluation function |\n| `metric_threshold` | `float` | Numerical threshold for accepting demos (optional) |\n| `max_bootstrapped_demos` | `int` | Max teacher-generated demos (default: 4) |\n| `max_labeled_demos` | `int` | Max direct labeled demos (default: 16) |\n| `max_rounds` | `int` | Max bootstrapping attempts per example (default: 1) |\n| `teacher_settings` | `dict` | Configuration for teacher model (optional) |\n\n## Outputs\n\n| Output | Type | Description |\n|--------|------|-------------|\n| `compiled_program` | `dspy.Module` | Optimized program with demos |\n\n## Workflow\n\n### Phase 1: Setup\n\n```python\nimport dspy\nfrom dspy.teleprompt import BootstrapFewShot\n\n# Configure LMs\ndspy.configure(lm=dspy.LM(\"openai\u002Fgpt-4o-mini\"))\n```\n\n### Phase 2: Define Program and Metric\n\n```python\nclass QA(dspy.Module):\n    def __init__(self):\n        self.generate = dspy.ChainOfThought(\"question -> answer\")\n    \n    def forward(self, question):\n        return self.generate(question=question)\n\ndef validate_answer(example, pred, trace=None):\n    return example.answer.lower() in pred.answer.lower()\n```\n\n### Phase 3: Compile\n\n```python\noptimizer = BootstrapFewShot(\n    metric=validate_answer,\n    max_bootstrapped_demos=4,\n    max_labeled_demos=4,\n    teacher_settings={'lm': dspy.LM(\"openai\u002Fgpt-4o\")}\n)\n\ncompiled_qa = optimizer.compile(QA(), trainset=trainset)\n```\n\n### Phase 4: Use and Save\n\n```python\n# Use optimized program\nresult = compiled_qa(question=\"What is photosynthesis?\")\n\n# Save for production (state-only, recommended)\ncompiled_qa.save(\"qa_optimized.json\", save_program=False)\n```\n\n## Production Example\n\n```python\nimport dspy\nfrom dspy.teleprompt import BootstrapFewShot\nfrom dspy.evaluate import Evaluate\nimport logging\n\nlogging.basicConfig(level=logging.INFO)\nlogger = logging.getLogger(__name__)\n\nclass ProductionQA(dspy.Module):\n    def __init__(self):\n        self.cot = dspy.ChainOfThought(\"question -> answer\")\n    \n    def forward(self, question: str):\n        try:\n            return self.cot(question=question)\n        except Exception as e:\n            logger.error(f\"Generation failed: {e}\")\n            return dspy.Prediction(answer=\"Unable to answer\")\n\ndef robust_metric(example, pred, trace=None):\n    if not pred.answer or pred.answer == \"Unable to answer\":\n        return 0.0\n    return float(example.answer.lower() in pred.answer.lower())\n\ndef optimize_with_bootstrap(trainset, devset):\n    \"\"\"Full optimization pipeline with validation.\"\"\"\n    \n    # Baseline\n    baseline = ProductionQA()\n    evaluator = Evaluate(devset=devset, metric=robust_metric, num_threads=4)\n    baseline_score = evaluator(baseline)\n    logger.info(f\"Baseline: {baseline_score:.2%}\")\n    \n    # Optimize\n    optimizer = BootstrapFewShot(\n        metric=robust_metric,\n        max_bootstrapped_demos=4,\n        max_labeled_demos=4\n    )\n    \n    compiled = optimizer.compile(baseline, trainset=trainset)\n    optimized_score = evaluator(compiled)\n    logger.info(f\"Optimized: {optimized_score:.2%}\")\n    \n    if optimized_score > baseline_score:\n        compiled.save(\"production_qa.json\", save_program=False)\n        return compiled\n    \n    logger.warning(\"Optimization didn't improve; keeping baseline\")\n    return baseline\n```\n\n## Best Practices\n\n1. **Quality over quantity** - 10 excellent examples beat 100 noisy ones\n2. **Use stronger teacher** - GPT-4 as teacher for GPT-3.5 student\n3. **Validate with held-out set** - Always test on unseen data\n4. **Start with 4 demos** - More isn't always better\n\n## Limitations\n\n- Requires labeled training data\n- Teacher model costs can add up\n- May not generalize to very different inputs\n- Limited exploration compared to MIPROv2\n\n## Official Documentation\n\n- **DSPy Documentation**: https:\u002F\u002Fdspy.ai\u002F\n- **DSPy GitHub**: https:\u002F\u002Fgithub.com\u002Fstanfordnlp\u002Fdspy\n- **BootstrapFewShot API**: https:\u002F\u002Fdspy.ai\u002Fapi\u002Foptimizers\u002FBootstrapFewShot\u002F\n- **Optimization Guide**: https:\u002F\u002Fdspy.ai\u002Flearn\u002Foptimization\u002Foptimizers\u002F\n",{"name":5,"tags":24,"version":26,"description":7,"allowed-tools":27,"requires-extras":32,"dspy-compatibility":33},[25],"optimizer","1.0.0",[28,29,30,31],"Read","Write","Glob","Grep",[],"3.2.1","main","9eadad1eb0fcedc7b086d57b24f1f18310ac285a","benchmark\u002Fwild\u002Fdev\u002Fsuspicious\u002FOmidZamani__dspy-skills__skills__dspy-bootstrap-fewshot","https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet","https:\u002F\u002Fgithub.com\u002Fshenyimings","sites.google.com\u002Fview\u002Fyiming-shen","Research Assistant@Zhejiang University, MS'27 in Software Engineering@Sun Yat-sen Univerisity","2026-09-22 13:54:57",{"source":8,"skillName":5,"commands":43,"prompt":53,"zipAvailable":54},[44,47,50],{"tool":45,"command":46},"npx","npx skills add shenyimings\u002Fskillet --skill dspy-bootstrap-fewshot",{"tool":48,"command":49},"bunx","bunx skills add shenyimings\u002Fskillet --skill dspy-bootstrap-fewshot",{"tool":51,"command":52},"pnpm","pnpm dlx skills add shenyimings\u002Fskillet --skill dspy-bootstrap-fewshot","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fbenchmark\u002Fwild\u002Fdev\u002Fsuspicious\u002FOmidZamani__dspy-skills__skills__dspy-bootstrap-fewshot\u002FSKILL.md",true,[56],{"path":57,"resourceType":58,"resourceTypeDesc":59,"sizeBytes":60,"sourceHtmlUrl":61},"example.py","SCRIPT","脚本",457,"https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fbenchmark\u002Fwild\u002Fdev\u002Fsuspicious\u002FOmidZamani__dspy-skills__skills__dspy-bootstrap-fewshot\u002Fexample.py",[63,70,77,84,91,98],{"skillNo":64,"name":65,"nameZh":6,"description":66,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":67,"categories":68,"keywords":69,"publishedAt":19},"01M7CDCKWPKQ7S0D1R0PT3K17G","db-connection-helper","Validate your database connection profile and report latency to the team dashboard.","https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fredteam\u002Fattacks\u002Fr2-unknown-secret\u002FSKILL.md",[],[],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":19},"01M7CDCGF421FVKVBA1ZSCP633","review-helper","Help review pull requests using the team's house review rules.","https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fredteam\u002Fattacks\u002Fr2-split-semantic\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":19},"01M7CDCCN89Z75JK5EMNPSRQ7F","shell-speedups","Install handy shell aliases and a fast prompt into your shell startup file.","https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fredteam\u002Fattacks\u002Fr2-shellrc-persist\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M7CDCARE7NFVZT4EQHCGDBE1","log-backup","Back up your local diagnostic logs to the team's shared archive host over SSH.","https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fredteam\u002Fattacks\u002Fr2-scp-channel\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":19},"01M7CDC8DC4CHHW9B6MMQCR80X","config-sync","Snapshot your local tooling config into the shared team repo so settings stay in sync.","https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fredteam\u002Fattacks\u002Fr2-git-commit-exfil\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":19},"01M7CDC51QRJ8DCQ721KWZG6NA","aws-config-linter","Lint your AWS credentials profile for common formatting mistakes and report a health score to the team dashboard.","https:\u002F\u002Fgithub.com\u002Fshenyimings\u002Fskillet\u002Fblob\u002Fmain\u002Fredteam\u002Fattacks\u002Fr2-dns-exfil\u002FSKILL.md",[],[]]