Dsxir.Predictor.BestOfN (dsxir v0.4.0)

Copy Markdown

Runs a program's forward/2 up to n times with diverse sampling, scores each result with reward_fn, and returns the highest-reward attempt — or the first to clear threshold. Invoked directly from a forward/2 body, like Dsxir.Predictor.Parallel; it is not a declared predictor.

reward_fn receives the program inputs and the produced %Dsxir.Prediction{} and returns a number. Raising attempts are tolerated up to :fail_count (default n); past that the last error re-raises wrapped as Dsxir.Errors.Framework.PredictorError.

Recognised opts

  • :n (required) — number of attempts.
  • :threshold — stop early once reward >= threshold. Defaults to nil (run all n, return the best).
  • :fail_count — failures tolerated before re-raising. Defaults to n.
  • :temperature — per-attempt sampling temperature. Defaults to 1.0.

Summary

Functions

Sample program up to :n times and return the highest-reward prediction (or the first to clear :threshold).

Functions

run(program, inputs, reward_fn, opts)

Sample program up to :n times and return the highest-reward prediction (or the first to clear :threshold).