dspy.BootstrapFewShot¶
dspy.BootstrapFewShot(metric=None, metric_threshold=None, teacher_settings: dict | None = None, max_bootstrapped_demos=4, max_labeled_demos=16, max_rounds=1, max_errors=None)
¶
Bases: Teleprompter
A Teleprompter class that composes a set of demos/examples to go into a predictor's prompt. These demos come from a combination of labeled examples in the training set, and bootstrapped demos.
Each bootstrap round copies the LM with a new rollout_id
at temperature=1.0
to
bypass caches and gather diverse traces.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
metric
|
Callable
|
A function that compares an expected value and predicted value, outputting the result of that comparison. |
None
|
metric_threshold
|
float
|
If the metric yields a numerical value, then check it against this threshold when deciding whether or not to accept a bootstrap example. Defaults to None. |
None
|
teacher_settings
|
dict
|
Settings for the |
None
|
max_bootstrapped_demos
|
int
|
Maximum number of bootstrapped demonstrations to include. Defaults to 4. |
4
|
max_labeled_demos
|
int
|
Maximum number of labeled demonstrations to include. Defaults to 16. |
16
|
max_rounds
|
int
|
Number of iterations to attempt generating the required bootstrap
examples. If unsuccessful after |
1
|
max_errors
|
Optional[int]
|
Maximum number of errors until program ends.
If |
None
|
Source code in dspy/teleprompt/bootstrap.py
:::