dspy-labeled-few-shot
Installation
SKILL.md
Hand-Picked Demonstrations with dspy.LabeledFewShot
Guide the user through using dspy.LabeledFewShot -- the simplest DSPy optimizer. It takes labeled examples you provide and attaches them as few-shot demonstrations to your program's predictors. No bootstrapping, no metric, no LM calls during optimization.
Step 1 — Gather context
Before writing code, ask:
- How many hand-picked examples do you have? This sets a good
kvalue — typically 25-50% of trainset size, capped at the default of 16. - Are these examples hand-curated or programmatically generated? If generated,
dspy.BootstrapFewShotmay be better — it evaluates examples against a metric and keeps only the ones that help. - Does your program have multiple predictors with different signatures? Every predictor gets the same demos, so all fields across all signatures must exist in the training examples.
- Have you measured zero-shot accuracy yet? Useful to know the baseline before adding demonstrations.
What is LabeledFewShot
dspy.LabeledFewShot is an optimizer that takes a set of labeled training examples and injects them directly as few-shot demonstrations into every predictor in your DSPy program.