Tune.Optimizers.BootstrapFewShot (Tune v0.5.0)

Copy Markdown View Source

Builds demonstrations from successful teacher trajectories.

The teacher is the program with labeled demonstrations (as LabeledFewShot with k: max_labeled_demos, unsampled), run under the explicit :teacher model configuration. For each training row, demonstrations built from that same row are removed from the teacher first. A trajectory is accepted only when the whole program succeeds and, when a metric is given, its score is at least accept_score. The final successful call of each predictor in an accepted trajectory becomes that predictor's bootstrapped demonstration, including intermediate predictors. Remaining slots are filled with labeled demonstrations from rows that were not bootstrapped.

Options:

  • :accept_score - required when a metric is given
  • :max_bootstrapped_demos - default 4
  • :max_labeled_demos - default 16
  • :max_rounds - passes over rows that were not yet accepted, default 1

The build is complete when every predictor has max_bootstrapped_demos bootstrapped demonstrations or every row was tried in every round. A build stopped by the call limit is an error with its partial report.

Differences from DSPy: rounds do not vary temperature or bypass caches; callers control provider caching explicitly through request options.

Summary

Functions

Builds bootstrapped demonstrations from examples and returns the program with them. Reused by search optimizers and KNNFewShot.

Functions

build(config, program, examples, ctx)

Builds bootstrapped demonstrations from examples and returns the program with them. Reused by search optimizers and KNNFewShot.