Resume incremental doctor model scoring
Homelab Main / validate (push) Successful in 1m16s Details
Homelab Main / running-update (push) Successful in 2s Details
Homelab Main / debian-ops (push) Failing after 4s Details

This commit is contained in:
juvenal.diaz 2026-11-13 08:23:08 -06:00
parent d7c8081b61
commit b619c41cbe
3 changed files with 39 additions and 0 deletions

View File

@ -169,6 +169,9 @@ The lab checks that the saved evidence, rubric, review IDs and judge match the
current suite, runs the new model with the baseline repeat count, and makes a
new combined report and ranking. It preserves the old reports. Previously
unscored answers remain unscored; reused scores retain the original judge's bias.
If judging stops after the combined report is saved, run `doctor-auto-rank` on
that combined report to reuse its referenced baseline scores and judge only the
new responses.
The ranking averages accuracy (0-2), uncertainty (0-2) and next step (0-1)
over all cases and repeats. Skipped, incomplete, unscored and wholly invalid

View File

@ -372,6 +372,11 @@ def auto_rank(path, prior_reviews=None):
"""Score blinded synthetic cases with an isolated local LLM judge."""
path = Path(path).resolve()
report = json.loads(path.read_text())
if prior_reviews is None and (report.get("baseline") or {}).get("ranking"):
previous = json.loads(Path(report["baseline"]["ranking"]).read_text())
if previous.get("judge", {}).get("model") != OLLAMA_MODEL or not isinstance(previous.get("reviews"), list):
raise RuntimeError("Prior ranking has no reusable scores from the expected judge")
prior_reviews = previous["reviews"]
lab.require_idle_ollama()
model_path = suite.model_from_modelfile(OLLAMA_MODEL)
if not model_path.is_file() or model_path.parent.name != "blobs" or model_path.stat().st_size >= MEMORY_MAX:

View File

@ -16,6 +16,37 @@ rank_spec.loader.exec_module(ranker)
class DoctorModelLabTests(unittest.TestCase):
def test_auto_rank_recovers_prior_scores_from_combined_report(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)
model_path = root / "blobs" / "model"
model_path.parent.mkdir()
model_path.write_bytes(b"GGUF")
prior = {"judge": {"model": lab.OLLAMA_MODEL}, "reviews": [
{"id": "old", "accuracy": 2, "uncertainty": 2, "next_step": 1}]}
prior_path = root / "prior.json"
prior_path.write_text(json.dumps(prior))
report = {"cases": ["one"], "repeats": 1, "review_rubric": {"one": "assess"},
"baseline": {"ranking": str(prior_path)}, "summary": {"old": {}, "new": {}},
"results": [{"backend": "old", "model": "old", "case": "one", "repeat": 1,
"review_id": "old", "contract": "valid"},
{"backend": "new", "model": "new", "case": "one", "repeat": 1,
"review_id": "new", "contract": "valid", "response": "{}"}]}
path = root / "report.json"
path.write_text(json.dumps(report))
(root / "one-1-new.tsv").write_text("synthetic evidence")
server = mock.Mock(low_memory=False, cgroup=None)
server.process.poll.return_value = None
with mock.patch.object(lab.lab, "require_idle_ollama"), \
mock.patch.object(lab.suite, "model_from_modelfile", return_value=model_path), \
mock.patch.object(lab.shutil, "which", return_value="/usr/bin/ollama"), \
mock.patch.object(lab, "ScopedServer", return_value=server), \
mock.patch.object(lab, "request", return_value={"response": '{"accuracy":2,"uncertainty":2,"next_step":1}'}) as request:
lab.auto_rank(path)
result = json.loads(next(root.glob("auto-ranking-*.json")).read_text())
self.assertEqual(result["reused_reviews"], 1)
self.assertEqual(request.call_count, 1)
def test_incremental_external_reuses_baseline_without_retesting(self):
with tempfile.TemporaryDirectory() as directory:
root = Path(directory)