What a Nous.Eval.Optimizer.Strategy searches with: the splits, the
components it may change, and helpers that do the budget accounting and
enforce the split and safety rules.
evaluate/4evaluates a profile on case ids (train, val or the guard cases), charging the budget; it returns{:error, :budget_exhausted}once the search budget is spentpropose/4asks the reflector for new text for some components from a train evaluation's records, then lints it (Nous.Eval.Optimizer.Lint)generate/4asks for whole new versions (OPRO), each lintedderive/4turns proposed text into a sealed child profilefeasible/3runs the guard filter on a candidate
Fields a strategy reads: :train, :val (case ids), :components,
:base_text (component key => the agent's base text), :k,
:minibatch_size, :seed, :rng, :mode (:round_robin | :all | :coupled), :merge (max merges, 0 disables), :step, plus
strategy-specific :strategy_opts.
Summary
Functions
The text profile gives each optimized component (its own, else the base).
The child of parent with updates applied, sealed against the agent,
named like the optimization and carrying the optimizer's provenance.
Evaluates profile on case_ids, labelled split, within what is left
of the search budget (the :final phase may also use the reserve held
back for the acceptance test).
The guard filter: :ok when child does not regress the guard-tagged
cases relative to parent (or there are none), {:error, reason}
otherwise. Evaluations of the guard cases are cached per profile.
Asks for n complete versions of every component from scored history
([{profile, score}], best first) and example train inputs. Versions
that fail the lint or change nothing are dropped and reported as
rejections: {:ok, versions, rejections}.
The default guard filter: on every guard-tagged case, the share of
samples whose guard_verdict scores all passed must not drop. Cases
without a guard_verdict score are ignored.
Proposes new text for keys of parent from a train evaluation's
reflective records. Returns {:ok, %{key => text}} or {:error, reason}
(:budget_exhausted, :unparseable, :unrequested_component,
:empty_proposal, {:heldout_leak, key}, {:fence_marker, key}, ...).
Text identical to the parent's is dropped; a proposal that changes
nothing is {:error, :no_change}.
Types
@type t() :: %Nous.Eval.Optimizer.Context{ adapter: term(), adapter_state: term(), agent: term(), base_text: term(), cache: term(), components: term(), feedback: term(), guard: term(), guard_cases: term(), heldout: term(), k: term(), ledger: term(), merge: term(), minibatch_size: term(), mode: term(), name: term(), provenance: term(), reflector: term(), rng: term(), seed: term(), step: term(), strategy_opts: term(), train: term(), val: term() }
Functions
@spec current_text(t(), Nous.Profile.t()) :: %{required(String.t()) => String.t()}
The text profile gives each optimized component (its own, else the base).
@spec derive(t(), Nous.Profile.t(), %{required(String.t()) => String.t()}, map()) :: {:ok, Nous.Profile.t()} | {:error, term()}
The child of parent with updates applied, sealed against the agent,
named like the optimization and carrying the optimizer's provenance.
@spec evaluate(t(), Nous.Profile.t(), [String.t()], String.t(), :search | :final) :: {:ok, Nous.Eval.Optimizer.Evaluation.t()} | {:error, term()}
Evaluates profile on case_ids, labelled split, within what is left
of the search budget (the :final phase may also use the reserve held
back for the acceptance test).
Returns {:ok, evaluation} for a completed evaluation,
{:error, :budget_exhausted}, or {:error, {:evaluation_failed, reason}}
for an operational failure (the strategy should halt with it).
@spec feasible(t(), Nous.Eval.Optimizer.Candidate.t(), Nous.Profile.t()) :: :ok | {:error, term()}
The guard filter: :ok when child does not regress the guard-tagged
cases relative to parent (or there are none), {:error, reason}
otherwise. Evaluations of the guard cases are cached per profile.
@spec generate(t(), [{Nous.Profile.t(), float()}], [String.t()], pos_integer()) :: {:ok, [%{required(String.t()) => String.t()}], [term()]} | {:error, term()}
Asks for n complete versions of every component from scored history
([{profile, score}], best first) and example train inputs. Versions
that fail the lint or change nothing are dropped and reported as
rejections: {:ok, versions, rejections}.
@spec guard_non_regression( Nous.Eval.Optimizer.Evaluation.t(), Nous.Eval.Optimizer.Evaluation.t() ) :: :ok | {:error, term()}
The default guard filter: on every guard-tagged case, the share of
samples whose guard_verdict scores all passed must not drop. Cases
without a guard_verdict score are ignored.
@spec propose( t(), Nous.Eval.Optimizer.Candidate.t(), Nous.Eval.Optimizer.Evaluation.t(), [String.t()] ) :: {:ok, %{required(String.t()) => String.t()}} | {:error, term()}
Proposes new text for keys of parent from a train evaluation's
reflective records. Returns {:ok, %{key => text}} or {:error, reason}
(:budget_exhausted, :unparseable, :unrequested_component,
:empty_proposal, {:heldout_leak, key}, {:fence_marker, key}, ...).
Text identical to the parent's is dropped; a proposal that changes
nothing is {:error, :no_change}.