Datasets:
Download scripts/check_prompt_hashes.py from cloudlabworks/proof-or-claim: direct link, hf CLI and curl.
- Browser
- Download file 1.63 kB
-
https://huggingface.co/datasets/cloudlabworks/proof-or-claim/resolve/main/scripts/check_prompt_hashes.py
- Command line
-
hf download hf://datasets/cloudlabworks/proof-or-claim/scripts/check_prompt_hashes.py
-
curl -L -o check_prompt_hashes.py https://huggingface.co/datasets/cloudlabworks/proof-or-claim/resolve/main/scripts/check_prompt_hashes.py
1.63 kB
| #!/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() | |