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

reward_fn()

@type reward_fn() :: (map(), Dsxir.Prediction.t() -> number())

Functions

run(program, inputs, reward_fn, opts)

Run program up to :n times with diverse sampling, score each with reward_fn, and return the best-scoring attempt.