Dsxir. Predictor. Sampling
(dsxir v0.4.0)
Copy Markdown
Shared sample-score-select core for Dsxir.Predictor.BestOfN and
Dsxir.Predictor.Refine. Runs a program's forward/2 up to n times
sequentially, each attempt under an :lm config carrying diversity
(temperature, cache: false, a fresh _dsxir_nonce) the same way
Dsxir.Optimizer.BootstrapFewShot does. Scores each attempt with
reward_fn, keeps the strictly-best, stops early on threshold, and
tolerates up to fail_count raising attempts before re-raising the last
error wrapped as Dsxir.Errors.Framework.PredictorError.
The optional :on_attempt hook is called at the start of each attempt with
the prior attempt's info (nil on the first) and returns a hints map (or
nil) pushed onto Dsxir.Settings for the upcoming attempt.
Summary
Functions
Run program up to :n times with diverse sampling, score each with reward_fn, and return the best-scoring attempt.
Types
@type reward_fn() :: (map(), Dsxir.Prediction.t() -> number())
Functions
@spec run(Dsxir.Program.t(), map(), reward_fn(), keyword()) :: {Dsxir.Program.t(), Dsxir.Prediction.t()}
Run program up to :n times with diverse sampling, score each with reward_fn, and return the best-scoring attempt.