mixle.inference.select module¶
Verifier-based selection — the generic test-time-compute selector.
Pure orchestration over a user score function: score every candidate, return the best (the
largest score, or the smallest when lower_is_better). This is the “best-of-N” / verifier pattern
that test-time-compute stacks lean on — generate several candidates, score each with a verifier, keep
the winner — with no assumption about what a candidate is (a string, a model, a plan, a sample).
When conformal_alpha is given, the result also carries a confident flag: whether the winner’s
lead over the runner-up clears a calibration band derived from the spread of the candidate scores
(a simple conformal/bootstrap SE band). A clear winner is confident=True; a near-tie is False.
- class SelectionResult(best, best_index, scores, confident=None, margin=None, band=None, _extras=<factory>)[source]
Bases:
objectResult of a
select_best()call.- Parameters:
- best
the winning candidate (the actual object, not its index).
- Type:
Any
- best_index
the position of the winner in the input
candidates.- Type:
- scores
per-candidate scores in input order (a numpy float array).
- Type:
- confident
whether the winner’s lead clears the conformal band —
Nonewhen noconformal_alphawas supplied.- Type:
bool | None
- margin
the winner’s lead over the runner-up (in score units, always
>= 0);Nonewhen there is a single candidate.- Type:
float | None
- band
the conformal/bootstrap band the margin was compared against —
Nonewhen noconformal_alphawas supplied or there is a single candidate.- Type:
float | None
- best: Any
- best_index: int
- scores: ndarray
- select_best(candidates, *, score, lower_is_better=False, conformal_alpha=None)[source]
Score each candidate and return the best, the verifier-based test-time-compute selector.
- Parameters:
candidates (Any) – an iterable of candidate objects (anything
scoreaccepts).score (Callable[[Any], float]) – a verifier
score(candidate) -> float; the winner maximizes it (or minimizes it whenlower_is_better).lower_is_better (bool) – if
True, the winner is the candidate with the smallest score.conformal_alpha (float | None) – optional miscoverage level in
(0, 1). When given, the result’sconfidentflag reports whether the winner’s lead over the runner-up exceeds a conformal/bootstrap band at confidence1 - conformal_alpha(az-scaled estimate of the score spread).None(default) leavesconfidentunset.
- Returns:
A
SelectionResult. It is also subscriptable (result["best"]), so callers may treat it as a small dict with keysbest,best_index,scores,confident.- Raises:
ValueError – if
candidatesis empty, orconformal_alphais outside(0, 1).- Return type:
SelectionResult