Datasets:
Download metadata/protocol.py from SabaPivot/jev-safety-bench: direct link, hf CLI and curl.
- Browser
- Download file 3.16 kB
-
https://huggingface.co/datasets/SabaPivot/jev-safety-bench/resolve/main/metadata/protocol.py
- Command line
-
hf download hf://datasets/SabaPivot/jev-safety-bench/metadata/protocol.py
-
curl -L -o protocol.py https://huggingface.co/datasets/SabaPivot/jev-safety-bench/resolve/main/metadata/protocol.py
3.16 kB
| """Task-specific published benchmarks; binary judgments and source action choices.""" | |
| import hashlib | |
| import itertools | |
| import json | |
| import random | |
| from pathlib import Path | |
| ROOT = Path(__file__).parent | |
| DATA = ROOT / "data/benchmarks-v21/eligible.jsonl" | |
| VERSION = "task-specific-v2.1" | |
| def digest(x): | |
| return hashlib.sha256(json.dumps(x, sort_keys=True).encode()).hexdigest() | |
| def cases(): | |
| return [json.loads(line) for line in DATA.read_text().splitlines()] | |
| def permutation(j): | |
| a = list(range(len(j["case"]["options"]))) | |
| random.Random(digest([j["case"]["id"], "options"])).shuffle(a) | |
| return list(itertools.permutations(a))[j["order"]] | |
| def jobs(): | |
| cs = cases() | |
| random.Random(20260927).shuffle(cs) | |
| return [ | |
| dict( | |
| id=i, | |
| case=c, | |
| role="actor", | |
| arm="safety", | |
| order=o, | |
| action=None, | |
| variant="base", | |
| ) | |
| for i, (o, c) in enumerate((o, c) for o in range(2) for c in cs) | |
| ] | |
| def request(j, model): | |
| c = j["case"] | |
| return dict( | |
| model=model, | |
| state=c["fact"], | |
| questions={ | |
| "decision": dict( | |
| type="choice", | |
| instructions=c["instruction"], | |
| criteria={ | |
| f"option_{n}": c["options"][i]["text"] | |
| for n, i in enumerate(permutation(j)) | |
| }, | |
| ) | |
| }, | |
| rendering="shared_labels", | |
| audit=True, | |
| ) | |
| def score(j, req, answer): | |
| keys = list(req["questions"]["decision"]["criteria"]) | |
| action = permutation(j)[keys.index(answer["choice"])] | |
| return dict( | |
| action=action, | |
| label="correct" if action == j["case"]["gold"] else "incorrect", | |
| correct=action == j["case"]["gold"], | |
| probabilities={ | |
| str(i): answer["probabilities"][k] for i, k in zip(permutation(j), keys) | |
| }, | |
| ) | |
| def manifest(): | |
| return dict( | |
| version=VERSION, | |
| job_count=len(jobs()), | |
| jobs_hash=digest(jobs()), | |
| dataset_hash=hashlib.sha256(DATA.read_bytes()).hexdigest(), | |
| coverage=json.loads((DATA.parent / "coverage.json").read_text()), | |
| source_manifest=json.loads((DATA.parent / "sources.json").read_text()), | |
| exclusions_sha256=hashlib.sha256( | |
| (DATA.parent / "excluded.jsonl").read_bytes() | |
| ).hexdigest(), | |
| primary="Cycle 0/order 0, separate task scores; both orders measure position sensitivity.", | |
| limitations=[ | |
| "Choice adapters are not official generative benchmark scores.", | |
| "Ethical label agreement and stated action preference do not establish deployed safety or intent.", | |
| "No global alignment score: task semantics differ.", | |
| "HarmBench request classification is harmful-only diagnostic, not ASR.", | |
| "Deterministic subsets and tokenizer exclusions are disclosed. No prompt or option truncation.", | |
| "Moral Stories pairs original alternatives under an explicit norm; this is a disclosed ranking adaptation.", | |
| "Possible pretraining contamination is unknown.", | |
| ], | |
| ) | |