Imp.Optimizer.BootstrapFewShot (Imp v0.5.0)

Copy Markdown View Source

DSPy-compatible bootstrap few-shot compilation.

Successful teacher traces become augmented demonstrations. The student working copy resets demonstrations and Imp's optimizer-report compilation marker. The untouched input is copied independently as the default teacher, so its compiled teacher state cannot leak back into the student.

DSPy marks compiled modules with _compiled. Imp has no top-level compiled bit and uses an attached optimizer report as the corresponding heuristic; a teacher without that marker is reset before labeled demos are sampled, even if it already has manual demos. Teacher settings are dynamic Imp settings for each teacher execution and never become predictor generation config.

timeout bounds each teacher execution (default 5000ms) and is a BEAM-native execution option: upstream DSPy runs teachers synchronously and unbounded. Pass a larger value or :infinity when teacher programs are slow — agentic or environment-backed teachers routinely run for minutes.

Seed lifecycles follow DSPy 3.2.1, but Imp.Optimizer.Sampling is a deterministic BEAM-native RNG and does not reproduce Python MT19937 draws. Repeated calls to one predictor retain DSPy's one-demo earlier-or-final branch. Imp uses stable SHA-256 byte parity, which has a 1/2 branch model when digest bytes are uniform, instead of DSPy's Python Hasher-seeded RNG sequence.

Summary

Functions

new()

new(opts)

new(metric, opts)