hired.alignment.calibration_log#
Collect held-out (score, truth) pairs from answered clarifications and fit a calibrator.
calibrate_match() needs scored judgments with known
truth. The truth arrives when the candidate answers a clarifying question
(record_qa()): the record’s match_score
before the answer, plus what the answer established. CalibrationLog appends
each pair to the user’s info/calibration/pairs.jsonl and, once both classes have enough
pairs for the chosen levels, fits and persists a MatchCalibrator
(info/calibration/calibrator.json) that the hired-align workflow loads with
CalibrationLog.load_calibrator().
Keep these pairs out of anything used to tune the scoring: the conformal bound only holds for data the scorer never saw.
>>> import tempfile
>>> from hired.persistence.base import UserStore
>>> log = CalibrationLog(UserStore("t", root=tempfile.mkdtemp()))
>>> log.add(0.9, True, qa_id="qa-1")
>>> log.pairs()
[(0.9, True)]
>>> log.fit() is None # too few pairs for the default levels
True
Functions
|
Pairs a class needs for a finite threshold at |
Classes
|
The user's calibration pairs and fitted calibrator, kept under |
- class hired.alignment.calibration_log.CalibrationLog(store=None, *, false_accept_rate=0.05, miss_rate=0.1)[source]#
Bases:
objectThe user’s calibration pairs and fitted calibrator, kept under
info/calibration/.- add(match_score, truth, *, qa_id=None)[source]#
Append one pair (the score before the answer, the truth the answer established).
- Return type:
- add_and_refit(match_score, truth, *, qa_id=None)[source]#
add()a pair, then refit and persist when ready; return the calibrator.- Return type:
- fit(*, persist=False)[source]#
Fit on the logged pairs;
Noneuntilready().persistsaves the result.- Return type: