Datasets:
File size: 1,634 Bytes
611d454 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | #!/usr/bin/env python3
"""Rebuild every baseline prompt from the shipped data and compare its sha256 with the hash recorded
at run time. A full match means the shipped items and scripts/pocb.py reproduce, byte for byte, the
prompts the baseline judges saw. Exit 1 on any mismatch.
Usage: check_prompt_hashes.py
"""
import json
import sys
from pathlib import Path
sys.path.insert(0, str(Path(__file__).resolve().parent))
from pocb import ROOT, load_jsonl, pairwise_prompt, pointwise_prompt, prompt_sha256 # noqa: E402
def main():
by_id = {it["id"]: it for it in load_jsonl(ROOT / "data/items.jsonl")}
pairs = {p["id"]: p for f in ("pairs.jsonl", "pairs_hard.jsonl") for p in load_jsonl(ROOT / "data" / f)}
n, bad = 0, []
for f in sorted((ROOT / "baselines/predictions").glob("*.jsonl")):
for r in load_jsonl(f):
if "prompt_sha256" in r:
n += 1
if prompt_sha256(pointwise_prompt(by_id[r["id"]])) != r["prompt_sha256"]:
bad.append((f.name, r["id"]))
for f in sorted((ROOT / "baselines/pairwise").glob("*.jsonl")):
for r in load_jsonl(f):
n += 1
p = pairs[r["pair_id"]]
P, U = by_id[p["proven_id"]], by_id[p["unproven_id"]]
prompt = pairwise_prompt(P, U) if r["order"] == "PU" else pairwise_prompt(U, P)
if prompt_sha256(prompt) != r["prompt_sha256"]:
bad.append((f.name, r["pair_id"], r["order"]))
print(json.dumps({"prompts_checked": n, "mismatches": len(bad), "first": bad[:5]}))
sys.exit(1 if bad else 0)
if __name__ == "__main__":
main()
|