Evaluation Harnesses and Reproducibility › Worked Example: A Complete Manifest-to-Report Loop
Language AI HandbookAll chapters Reload the archive using separately held file digests. After checking the file set and bytes, check that the serialized inputs match the manifest and the item records match those inputs. Backend identity and library versions are declared runtime metadata. Comparing archive fields cannot establish what runtime served a past request. Regrade with the original policy to check that the stored responses still produce the recorded scores.
PythonIn [43]Expand
def reload_and_verify(bundle, trusted_digests, grader):
expected = {
"manifest.json",
"dataset.json",
"prompt.json",
"model_config.json",
"grader.json",
"run_policy.json",
"records.jsonl",
}
if (
set(trusted_digests) != expected
or {p.name for p in bundle.iterdir()} != expected
):
raise ValueError("Bundle files do not match the trusted manifest.")
loaded = {}
for name in sorted(expected):
contents = (bundle / name).read_bytes()
if hashlib.sha256(contents).hexdigest() != trusted_digests[name]:
raise ValueError(f"Bundle bytes changed at {name}.")
loaded[name] = contents
records = [
json.loads(row) for row in loaded.pop("records.jsonl").splitlines()
]
inputs = {name: json.loads(contents) for name, contents in loaded.items()}
check_bundle_inputs(inputs, records)
manifest = inputs["manifest.json"]
if grader.policy_digest() != manifest["grader_digest"]:
raise ValueError(
"Use the archived grader policy for this verification."
)
scores = []
for record in records:
score, status = grader.grade(record["response"], record["reference"])
if (score, status) != (record["score"], record["status"]):
raise ValueError(
f"Regrading changed the result for {record['item_id']}."
)
if status != "bad_reference":
scores.append(score)
if not scores:
raise ValueError("No graded tasks in this archive.")
return manifest["model_name"], sum(scores) / len(scores), len(scores)
name_a, acc_a_reload, n_a = reload_and_verify(path_a, trusted_a, grader)
name_b, acc_b_reload, n_b = reload_and_verify(path_b, trusted_b, grader)ConsoleOut [44]Expand
Reload mock-math-small: acc=0.714 over 7 items Reload mock-math-large: acc=0.857 over 7 items Matches in-memory report A: True Matches in-memory report B: True
The replay of the stored responses reproduces the scores with the original grader. The trusted file digests identify those bytes. An archive and untrusted checksums kept beside it can be altered together, so production systems need a protected reference or signature.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!