mixle.task.harness module¶
Application harnesses – named, one-call replacements for the rigid-code shapes everyone has.
Each harness takes the code currently doing the job (the teacher) plus example data, and returns a
deployable object with the same honesty contract as solve(): answer locally when
confident, fall back to the teacher when not, report measured numbers.
replace_extractor()– the regex/parser scraper:teacher(text) -> {field: value}. Distills a token-level tagger (distill_extractor()); a prediction missing required fields falls back to the teacher.
replace_alerter()– the threshold rule over a sliding window:teacher(window) -> label. Windows the series and runs the fullsolve()loop (conformal + OOD gate) over window-records.
replace_matcher()– the dedup/matching rule:teacher(a, b) -> label. Encodes each pair as one record (both sides + numeric difference features) and runssolve().
Alerter and matcher return a real Solution (deploy/serve/improve all work);
the extractor returns an ExtractorHarness with the same call-or-fallback behavior.
- class ExtractorHarness(model, teacher, fields, required, holdout_f1, n_fallback=0, n_requests=0)[source]
Bases:
objectA distilled extractor in front of the parser it replaces: local extraction or teacher fallback.
- Parameters:
- model: Any
- holdout_f1: float
- n_fallback: int = 0
- n_requests: int = 0
- replace_extractor(teacher, texts, fields, *, required=None, holdout=0.25, seed=0, **distill_kw)[source]
Replace a regex/parser scraper with a distilled token-level extractor + teacher fallback.
The teacher labels the training texts; a held-out slice measures field-level F1 against the teacher. At call time a prediction missing any
requiredfield (default: allfields) falls back to the teacher — the same never-silently-wrong shape assolve().
- replace_alerter(teacher, series, *, window=16, stride=1, **solve_kw)[source]
Replace a threshold/heuristic alert rule over a sliding window with a calibrated model.
teacher(window) -> label(e.g."alert"/"ok") labels every window of the historical series; the returnedSolutionis called with a window (the latestwindowsamples) and answers locally only when conformally confident and in-distribution — otherwise it runs the rule.
- replace_matcher(teacher, pairs, **solve_kw)[source]
Replace a record-matching/dedup rule with a calibrated model over encoded pairs.
teacher(a, b) -> label(e.g."match"/"no-match") labels the example pairs; each pair is encoded as one record (both sides plus numeric-difference and same-value features, which is where matchers earn their keep). Call the result with(a, b): confident pairs answer locally, everything else runs the rule.