Datasets:
Easier runs and opt-in result sharing (caibench_share.py), new card opening
#4
by compressionawareintelligence - opened
- README.md +18 -2
- caibench_share.py +284 -0
- results/README.md +14 -4
- run_api.py +3 -0
- run_local.py +5 -0
- score_headline.py +4 -0
README.md
CHANGED
|
@@ -210,7 +210,21 @@ configs:
|
|
| 210 |
|
| 211 |
> **First results (four small open models, preregistered):** three of the four obeyed a coworker's "withdrawal" of a manager's written authorization 94–100% of the time, and the two larger ones paid insurance claims under coverage that only started *after* the loss 69–72% of the time. Frontier-model runs are next; see [Findings](#findings).
|
| 212 |
|
| 213 |
-
**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 214 |
|
| 215 |
- **No LLM judge.** Every gold label is computed by an executable rule.
|
| 216 |
- **Disposition-proof.** Every index is a paired contrast on identical text, so always-yes, always-no, always-ask, obeying anyone and never updating all score 0 or less (checked in `baselines_*.txt`).
|
|
@@ -308,6 +322,7 @@ python3 caibench_twins.py score --responses replies.jsonl # replies from any
|
|
| 308 |
## Load it
|
| 309 |
|
| 310 |
```python
|
|
|
|
| 311 |
from datasets import load_dataset
|
| 312 |
|
| 313 |
REPO = "compressionawareintelligence/cai-semantic-equivalence-benchmark"
|
|
@@ -464,7 +479,8 @@ For `claims`, append each tool call to the reply as a line `[tool_call] <name> <
|
|
| 464 |
| | How | Best for |
|
| 465 |
|---|---|---|
|
| 466 |
| Pull request | Add your run under `results/submissions/` and open a PR in the Community tab. Steps in [results/README.md](results/README.md). | Any harness: the native runners, lm-eval, Inspect, or a private seed |
|
| 467 |
-
| One
|
|
|
|
| 468 |
|
| 469 |
**What a submission must include.** We rescore every submission from its raw replies, so a score alone is not enough:
|
| 470 |
|
|
|
|
| 210 |
|
| 211 |
> **First results (four small open models, preregistered):** three of the four obeyed a coworker's "withdrawal" of a manager's written authorization 94–100% of the time, and the two larger ones paid insurance claims under coverage that only started *after* the loss 69–72% of the time. Frontier-model runs are next; see [Findings](#findings).
|
| 212 |
|
| 213 |
+
> **Access:** free and open, gated with instant automatic approval. Log in, accept the short form at the top of this page once, and everything below works. `load_dataset` and the download need that login.
|
| 214 |
+
|
| 215 |
+
**Run it tonight.** Five commands, standard-library Python, any hosted or local model. The `headline` subset is 1,274 prompts; add `--plan` to see the exact call count before spending anything.
|
| 216 |
+
|
| 217 |
+
```bash
|
| 218 |
+
pip install -U huggingface_hub && huggingface-cli login
|
| 219 |
+
hf download compressionawareintelligence/cai-semantic-equivalence-benchmark --repo-type dataset --local-dir cai-bench && cd cai-bench
|
| 220 |
+
python3 run_api.py --model openai:gpt-4.1-mini --splits headline # or anthropic:, gemini:, groq:, compatible:MODEL --base-url URL
|
| 221 |
+
python3 score_headline.py results/openai_gpt-4.1-mini
|
| 222 |
+
python3 caibench_share.py results/openai_gpt-4.1-mini --name "Your Name" --model-version 2025-04-14 --open-pr # optional: asks first
|
| 223 |
+
```
|
| 224 |
+
|
| 225 |
+
**No frontier model is on the leaderboard yet.** The first verified run of any hosted frontier model, or any open model above 8B, gets its own row, credited to you, and is scored against the preregistered predictions. See [Share your results](#share-your-results).
|
| 226 |
+
|
| 227 |
+
**Or try it by hand in a minute:** paste any of the eight scenarios in [TWINS_PASTE.md](TWINS_PASTE.md) into a chat model and check it against the answer key.
|
| 228 |
|
| 229 |
- **No LLM judge.** Every gold label is computed by an executable rule.
|
| 230 |
- **Disposition-proof.** Every index is a paired contrast on identical text, so always-yes, always-no, always-ask, obeying anyone and never updating all score 0 or less (checked in `baselines_*.txt`).
|
|
|
|
| 322 |
## Load it
|
| 323 |
|
| 324 |
```python
|
| 325 |
+
# gated with instant approval: accept the form on the dataset page once, then `huggingface-cli login` (or set HF_TOKEN)
|
| 326 |
from datasets import load_dataset
|
| 327 |
|
| 328 |
REPO = "compressionawareintelligence/cai-semantic-equivalence-benchmark"
|
|
|
|
| 479 |
| | How | Best for |
|
| 480 |
|---|---|---|
|
| 481 |
| Pull request | Add your run under `results/submissions/` and open a PR in the Community tab. Steps in [results/README.md](results/README.md). | Any harness: the native runners, lm-eval, Inspect, or a private seed |
|
| 482 |
+
| One command | `python3 caibench_share.py results/<model> --name "…" --model-version … --open-pr` builds the submission, shows you everything it contains, and asks before opening the PR under your account. Without `--open-pr` it sends nothing. | Runs made with `run_api.py` or `run_local.py` |
|
| 483 |
+
| One flag (next contradish release) | `contradish benchmark --share` will do the same for contradish runs: off by default, shows what it sends, asks first. | Runs made with contradish |
|
| 484 |
|
| 485 |
**What a submission must include.** We rescore every submission from its raw replies, so a score alone is not enough:
|
| 486 |
|
caibench_share.py
ADDED
|
@@ -0,0 +1,284 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Package a CAI-Bench run for the leaderboard, and (only if you ask) open the pull request for you.
|
| 3 |
+
|
| 4 |
+
python3 caibench_share.py results/openai_gpt-4.1-mini build the submission folder, send nothing
|
| 5 |
+
python3 caibench_share.py results/openai_gpt-4.1-mini --open-pr the same, then ask before opening a PR
|
| 6 |
+
|
| 7 |
+
Nothing leaves your machine unless you pass --open-pr AND answer "y" to the prompt. The folder written to
|
| 8 |
+
share/ is exactly what would be uploaded, so you can read every byte first.
|
| 9 |
+
|
| 10 |
+
What the submission contains (results/README.md has the full format):
|
| 11 |
+
submission.json model, settings, CAI-Bench version and data hashes, runner (you fill in name/org)
|
| 12 |
+
raw/ the runner's own reply files for each split, unchanged except that a custom
|
| 13 |
+
base_url is replaced by "custom" (it can reveal a private endpoint)
|
| 14 |
+
scores.json the official scorer's output for the run
|
| 15 |
+
|
| 16 |
+
What it never contains: API keys, environment variables, file paths, hostnames, timing beyond what the runner
|
| 17 |
+
already records per reply, or anything from outside the results directory you point it at.
|
| 18 |
+
|
| 19 |
+
Standard library only, except --open-pr, which needs `pip install huggingface_hub` and `huggingface-cli login`.
|
| 20 |
+
"""
|
| 21 |
+
import argparse
|
| 22 |
+
import datetime as dt
|
| 23 |
+
import hashlib
|
| 24 |
+
import json
|
| 25 |
+
import re
|
| 26 |
+
import shutil
|
| 27 |
+
import subprocess
|
| 28 |
+
import sys
|
| 29 |
+
from pathlib import Path
|
| 30 |
+
|
| 31 |
+
HERE = Path(__file__).resolve().parent
|
| 32 |
+
REPO_ID = "compressionawareintelligence/cai-semantic-equivalence-benchmark"
|
| 33 |
+
CAI_BENCH_VERSION = "5.6.0"
|
| 34 |
+
SECRET_PATTERNS = re.compile(r"(sk-[A-Za-z0-9_\-]{16,}|sk-ant-[A-Za-z0-9_\-]{16,}|hf_[A-Za-z0-9]{20,}|AKIA[0-9A-Z]{16}"
|
| 35 |
+
r"|AIza[0-9A-Za-z_\-]{30,}|gsk_[A-Za-z0-9]{20,}|xai-[A-Za-z0-9]{20,})")
|
| 36 |
+
|
| 37 |
+
|
| 38 |
+
# ---------------------------------------------------------------- helpers the runners import
|
| 39 |
+
|
| 40 |
+
DOWNLOAD_HELP = f"""
|
| 41 |
+
CAI-Bench's data files were not found next to this script ({{missing}}).
|
| 42 |
+
|
| 43 |
+
The dataset is free, but gated: accept the short form once at
|
| 44 |
+
https://huggingface.co/datasets/{REPO_ID}
|
| 45 |
+
then log in and download it (access is instant):
|
| 46 |
+
pip install -U huggingface_hub
|
| 47 |
+
huggingface-cli login
|
| 48 |
+
hf download {REPO_ID} --repo-type dataset --local-dir cai-bench
|
| 49 |
+
cd cai-bench
|
| 50 |
+
"""
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def require_data():
|
| 54 |
+
"""Exit with a clear download message if the data files are missing (e.g. only the scripts were copied)."""
|
| 55 |
+
data = HERE / "data"
|
| 56 |
+
if not (data / "headline.jsonl").exists():
|
| 57 |
+
raise SystemExit(DOWNLOAD_HELP.format(missing="data/headline.jsonl"))
|
| 58 |
+
|
| 59 |
+
|
| 60 |
+
def share_hint(result_dir):
|
| 61 |
+
"""The last thing a run prints: how to get the result on the leaderboard."""
|
| 62 |
+
d = Path(result_dir)
|
| 63 |
+
try:
|
| 64 |
+
d = d.relative_to(Path.cwd())
|
| 65 |
+
except ValueError:
|
| 66 |
+
pass
|
| 67 |
+
print(f"""
|
| 68 |
+
── Put this result on the CAI-Bench leaderboard ──────────────────────────────
|
| 69 |
+
Every verified submission gets a public row with your name.
|
| 70 |
+
python3 caibench_share.py {d} # builds share/, sends nothing
|
| 71 |
+
python3 caibench_share.py {d} --open-pr # then asks before opening a PR
|
| 72 |
+
Format and review process: results/README.md
|
| 73 |
+
""")
|
| 74 |
+
|
| 75 |
+
|
| 76 |
+
# ---------------------------------------------------------------- packaging
|
| 77 |
+
|
| 78 |
+
def sha256(path):
|
| 79 |
+
h = hashlib.sha256()
|
| 80 |
+
with open(path, "rb") as f:
|
| 81 |
+
for chunk in iter(lambda: f.read(1 << 20), b""):
|
| 82 |
+
h.update(chunk)
|
| 83 |
+
return h.hexdigest()
|
| 84 |
+
|
| 85 |
+
|
| 86 |
+
def release_hashes():
|
| 87 |
+
sums = HERE / "SHA256SUMS"
|
| 88 |
+
out = {}
|
| 89 |
+
if sums.exists():
|
| 90 |
+
for line in sums.read_text().splitlines():
|
| 91 |
+
parts = line.split()
|
| 92 |
+
if len(parts) == 2:
|
| 93 |
+
out[parts[1].lstrip("*").removeprefix("./")] = parts[0]
|
| 94 |
+
return out
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def reply_files(d):
|
| 98 |
+
"""Runner output: <split>.jsonl files that are not scorer output."""
|
| 99 |
+
return sorted(p for p in d.glob("*.jsonl") if not p.stem.endswith("_score"))
|
| 100 |
+
|
| 101 |
+
|
| 102 |
+
def scrub(rec):
|
| 103 |
+
"""Drop a custom endpoint URL from a runner record; keep everything else exactly."""
|
| 104 |
+
if isinstance(rec, dict) and rec.get("base_url"):
|
| 105 |
+
rec = dict(rec, base_url="custom")
|
| 106 |
+
return rec
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def read_meta(files):
|
| 110 |
+
for p in files:
|
| 111 |
+
with open(p) as f:
|
| 112 |
+
for line in f:
|
| 113 |
+
line = line.strip()
|
| 114 |
+
if line:
|
| 115 |
+
try:
|
| 116 |
+
return json.loads(line)
|
| 117 |
+
except json.JSONDecodeError:
|
| 118 |
+
break
|
| 119 |
+
return {}
|
| 120 |
+
|
| 121 |
+
|
| 122 |
+
def slug(s):
|
| 123 |
+
return re.sub(r"[^a-z0-9._-]+", "_", str(s).lower()).strip("_") or "unknown"
|
| 124 |
+
|
| 125 |
+
|
| 126 |
+
def run_scorer(d, splits):
|
| 127 |
+
"""Official scores for the run: score_headline.py when headline was run, else score_all.py."""
|
| 128 |
+
if "headline" in splits and (HERE / "score_headline.py").exists():
|
| 129 |
+
tmp = d / "_share_headline_score.json"
|
| 130 |
+
r = subprocess.run([sys.executable, str(HERE / "score_headline.py"), str(d), "--json", str(tmp)],
|
| 131 |
+
capture_output=True, text=True)
|
| 132 |
+
if r.returncode == 0 and tmp.exists():
|
| 133 |
+
data = json.loads(tmp.read_text())
|
| 134 |
+
tmp.unlink()
|
| 135 |
+
return {"scorer": "score_headline.py", "headline": data}
|
| 136 |
+
scores = {p.stem.removesuffix("_score"): json.loads(p.read_text()) for p in sorted(d.glob("*_score.json"))}
|
| 137 |
+
if not scores and (HERE / "score_all.py").exists():
|
| 138 |
+
subprocess.run([sys.executable, str(HERE / "score_all.py"), str(d)], capture_output=True, text=True)
|
| 139 |
+
scores = {p.stem.removesuffix("_score"): json.loads(p.read_text()) for p in sorted(d.glob("*_score.json"))}
|
| 140 |
+
return {"scorer": "score_all.py", "splits": scores} if scores else {"scorer": None, "note": "no scorer output found"}
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def build(d, a):
|
| 144 |
+
files = reply_files(d)
|
| 145 |
+
if not files:
|
| 146 |
+
raise SystemExit(f"no reply files (*.jsonl) in {d}; run a split first")
|
| 147 |
+
splits = [p.stem for p in files]
|
| 148 |
+
meta = read_meta(files)
|
| 149 |
+
opts = meta.get("options") or {}
|
| 150 |
+
model = a.model_name or meta.get("model") or d.name
|
| 151 |
+
provider = meta.get("provider") or ("ollama" if "num_ctx" in json.dumps(opts) else "unknown")
|
| 152 |
+
|
| 153 |
+
rel = release_hashes()
|
| 154 |
+
data_sha, mismatch = {}, []
|
| 155 |
+
for s in splits:
|
| 156 |
+
p = HERE / "data" / f"{s}.jsonl"
|
| 157 |
+
if p.exists():
|
| 158 |
+
h = sha256(p)
|
| 159 |
+
data_sha[f"data/{s}.jsonl"] = h
|
| 160 |
+
if rel.get(f"data/{s}.jsonl") not in (None, h):
|
| 161 |
+
mismatch.append(f"data/{s}.jsonl")
|
| 162 |
+
|
| 163 |
+
n_replies = n_failed = 0
|
| 164 |
+
out = Path(a.out) / f"{slug(a.org or 'independent')}__{slug(model)}__{slug(a.model_version or 'unversioned')}" \
|
| 165 |
+
/ f"cai-bench-{CAI_BENCH_VERSION}"
|
| 166 |
+
if out.exists():
|
| 167 |
+
shutil.rmtree(out)
|
| 168 |
+
(out / "raw").mkdir(parents=True)
|
| 169 |
+
for p in files:
|
| 170 |
+
lines = []
|
| 171 |
+
with open(p) as f:
|
| 172 |
+
for line in f:
|
| 173 |
+
if not line.strip():
|
| 174 |
+
continue
|
| 175 |
+
rec = scrub(json.loads(line))
|
| 176 |
+
n_replies += 1
|
| 177 |
+
n_failed += "FAILED" in json.dumps(rec.get("samples", ""))[:20000]
|
| 178 |
+
lines.append(json.dumps(rec, ensure_ascii=False))
|
| 179 |
+
text = "\n".join(lines) + "\n"
|
| 180 |
+
if SECRET_PATTERNS.search(text):
|
| 181 |
+
raise SystemExit(f"{p.name} contains something that looks like an API key; not packaging it. "
|
| 182 |
+
"Check the replies and remove it before sharing.")
|
| 183 |
+
(out / "raw" / p.name).write_text(text)
|
| 184 |
+
|
| 185 |
+
scores = run_scorer(d, splits)
|
| 186 |
+
(out / "scores.json").write_text(json.dumps(scores, indent=2, default=str) + "\n")
|
| 187 |
+
|
| 188 |
+
sub = {
|
| 189 |
+
"submitter": {"name": a.name or "", "organization": a.org or ""},
|
| 190 |
+
"model": {"name": model, "version": a.model_version or "", "provider": provider,
|
| 191 |
+
"access": "local" if provider == "ollama" else "api",
|
| 192 |
+
"system_prompt": "none" if not a.system_prompt_sha256 else "withheld",
|
| 193 |
+
**({"system_prompt_sha256": a.system_prompt_sha256} if a.system_prompt_sha256 else {})},
|
| 194 |
+
"sampling": {"temperature": opts.get("temperature"), "max_tokens": opts.get("max_tokens", opts.get("num_predict")),
|
| 195 |
+
"samples_per_prompt": a.samples, "seed": opts.get("seed"), "other_options": {
|
| 196 |
+
k: v for k, v in opts.items() if k not in ("temperature", "max_tokens", "num_predict", "seed")}},
|
| 197 |
+
"benchmark": {"version": CAI_BENCH_VERSION, "splits": splits, "data_sha256": data_sha,
|
| 198 |
+
"hash_mismatch": mismatch,
|
| 199 |
+
"sha256sums_sha256": sha256(HERE / "SHA256SUMS") if (HERE / "SHA256SUMS").exists() else None,
|
| 200 |
+
"private_seed": None},
|
| 201 |
+
"run": {"runner": "run_local.py" if provider == "ollama" else "run_api.py", "harness": "native",
|
| 202 |
+
"date": (meta.get("time") or dt.date.today().isoformat())[:10],
|
| 203 |
+
"replies": n_replies, "failed_calls": n_failed, "packaged_by": "caibench_share.py"},
|
| 204 |
+
}
|
| 205 |
+
(out / "submission.json").write_text(json.dumps(sub, indent=2) + "\n")
|
| 206 |
+
return out, sub, scores
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
def summary(out, sub, scores):
|
| 210 |
+
b, m, s = sub["benchmark"], sub["model"], sub["sampling"]
|
| 211 |
+
lines = [
|
| 212 |
+
f" folder {out}",
|
| 213 |
+
f" submitter {sub['submitter']['name'] or '(not set: --name)'}"
|
| 214 |
+
f"{' / ' + sub['submitter']['organization'] if sub['submitter']['organization'] else ''}",
|
| 215 |
+
f" model {m['name']} {m['version'] or '(version not set: --model-version)'} ({m['provider']}, {m['access']})",
|
| 216 |
+
f" settings temperature {s['temperature']}, max tokens {s['max_tokens']}, {s['samples_per_prompt']} sample(s)",
|
| 217 |
+
f" benchmark CAI-Bench {b['version']}: {', '.join(b['splits'])}"
|
| 218 |
+
f" [{'hashes match release' if not b['hash_mismatch'] else 'MISMATCH: ' + ', '.join(b['hash_mismatch'])}]",
|
| 219 |
+
f" replies {sub['run']['replies']} raw replies ({sub['run']['failed_calls']} failed calls)",
|
| 220 |
+
f" scores {scores.get('scorer') or 'none'}",
|
| 221 |
+
f" system prompt {m['system_prompt']}",
|
| 222 |
+
]
|
| 223 |
+
return "\n".join(lines)
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
def open_pr(out, sub, yes):
|
| 227 |
+
try:
|
| 228 |
+
from huggingface_hub import HfApi
|
| 229 |
+
except ImportError:
|
| 230 |
+
raise SystemExit("--open-pr needs huggingface_hub: pip install -U huggingface_hub, then huggingface-cli login")
|
| 231 |
+
api = HfApi()
|
| 232 |
+
try:
|
| 233 |
+
user = api.whoami()["name"]
|
| 234 |
+
except Exception:
|
| 235 |
+
raise SystemExit("not logged in to Hugging Face: run huggingface-cli login, then rerun with --open-pr")
|
| 236 |
+
rel = out.relative_to(out.parents[1])
|
| 237 |
+
print(f"\nThis opens a PUBLIC pull request on Hugging Face, under your account ({user}), to\n {REPO_ID}\n"
|
| 238 |
+
f"adding results/submissions/{rel}/ exactly as written above.\n"
|
| 239 |
+
"It does not send API keys, file paths, or anything outside that folder.\n"
|
| 240 |
+
"It is published under the dataset's license. You can close the pull request at any time.")
|
| 241 |
+
if not yes and input("Open the pull request? [y/N] ").strip().lower() not in ("y", "yes"):
|
| 242 |
+
print("Nothing sent. The folder stays on disk; you can open the PR by hand (results/README.md).")
|
| 243 |
+
return
|
| 244 |
+
title = f"results: {sub['model']['name']} {sub['model']['version']} (CAI-Bench {CAI_BENCH_VERSION})".strip()
|
| 245 |
+
info = api.upload_folder(folder_path=str(out), path_in_repo=f"results/submissions/{rel}", repo_id=REPO_ID,
|
| 246 |
+
repo_type="dataset", create_pr=True, commit_message=title,
|
| 247 |
+
commit_description="Submitted with caibench_share.py. See submission.json.")
|
| 248 |
+
url = getattr(info, "pr_url", None) or str(info)
|
| 249 |
+
(out / "pr_url.txt").write_text(url + "\n")
|
| 250 |
+
print(f"Pull request opened: {url}")
|
| 251 |
+
|
| 252 |
+
|
| 253 |
+
def main():
|
| 254 |
+
ap = argparse.ArgumentParser(description=__doc__.split("\n")[0],
|
| 255 |
+
formatter_class=argparse.RawDescriptionHelpFormatter, epilog=__doc__)
|
| 256 |
+
ap.add_argument("results_dir", help="the runner's output folder, e.g. results/openai_gpt-4.1-mini")
|
| 257 |
+
ap.add_argument("--name", help="your name, as it should appear on the leaderboard")
|
| 258 |
+
ap.add_argument("--org", help="your organization (optional)")
|
| 259 |
+
ap.add_argument("--model-name", help="override the model name read from the replies")
|
| 260 |
+
ap.add_argument("--model-version", help="checkpoint, API snapshot or date, e.g. 2025-04-14")
|
| 261 |
+
ap.add_argument("--samples", type=int, default=1, help="samples per prompt (default 1)")
|
| 262 |
+
ap.add_argument("--system-prompt-sha256", help="if you used a confidential system prompt, its SHA-256 only")
|
| 263 |
+
ap.add_argument("--out", default="share", help="where to write the submission folder (default share/)")
|
| 264 |
+
ap.add_argument("--open-pr", action="store_true", help="after building, ask, then open the PR on Hugging Face")
|
| 265 |
+
ap.add_argument("--yes", action="store_true", help="with --open-pr: skip the confirmation (CI)")
|
| 266 |
+
a = ap.parse_args()
|
| 267 |
+
|
| 268 |
+
d = Path(a.results_dir)
|
| 269 |
+
if not d.is_dir():
|
| 270 |
+
raise SystemExit(f"{d} is not a folder")
|
| 271 |
+
out, sub, scores = build(d, a)
|
| 272 |
+
print("\nCAI-Bench submission built (nothing has been sent):\n" + summary(out, sub, scores))
|
| 273 |
+
if not a.name or not a.model_version:
|
| 274 |
+
print("\n Add --name and --model-version before submitting; the leaderboard needs both.")
|
| 275 |
+
if a.open_pr:
|
| 276 |
+
if not a.name or not a.model_version:
|
| 277 |
+
raise SystemExit("--open-pr needs --name and --model-version")
|
| 278 |
+
open_pr(out, sub, a.yes)
|
| 279 |
+
else:
|
| 280 |
+
print(f"\n Read the folder, then open the PR with --open-pr, or by hand (results/README.md).")
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
if __name__ == "__main__":
|
| 284 |
+
main()
|
results/README.md
CHANGED
|
@@ -4,6 +4,15 @@ This guide is for CAI-Bench **5.6.0**. It replaces the v2.0/v4 guide. If anythin
|
|
| 4 |
|
| 5 |
Every accepted submission gets a row in the `leaderboard` config. We rescore every submission from its raw replies before listing it, so all you need to send is what you ran and what the model said.
|
| 6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
## 1. Run
|
| 8 |
|
| 9 |
Use the runner for your split, or any harness through the `prompts` config.
|
|
@@ -37,7 +46,8 @@ Add one folder per model and benchmark version:
|
|
| 37 |
```
|
| 38 |
results/submissions/<org>__<model>__<version-or-date>/cai-bench-5.6.0/
|
| 39 |
submission.json # what you ran (required)
|
| 40 |
-
replies.jsonl # raw replies, one record per item_id (required)
|
|
|
|
| 41 |
scores.json # the scorer output, unedited (required)
|
| 42 |
notes.md # anything a reader should know (optional)
|
| 43 |
```
|
|
@@ -65,7 +75,7 @@ Every field below is required unless marked optional.
|
|
| 65 |
|
| 66 |
```json
|
| 67 |
{
|
| 68 |
-
"submitter": {"name": "Ada Example", "organization": "Example Lab"
|
| 69 |
"model": {
|
| 70 |
"name": "gpt-4.1-mini",
|
| 71 |
"version": "2025-04-14",
|
|
@@ -110,7 +120,7 @@ In the Community tab, open a pull request that adds your folder. Title it `resul
|
|
| 110 |
## 4. What happens next
|
| 111 |
|
| 112 |
1. We check the files against the schema and the hashes.
|
| 113 |
-
2. We rescore from `replies.jsonl` with the official scorers.
|
| 114 |
3. If every index matches your `scores.json` to within 0.005, we merge, add your rows to `leaderboard`, and mark them **verified**. If not, we comment on the PR with the difference, and the row waits until it is explained.
|
| 115 |
4. If your run bears on a preregistered prediction, we score the prediction and add the verdict to the `predictions` config, crediting your run.
|
| 116 |
|
|
@@ -118,7 +128,7 @@ We aim to respond within a week.
|
|
| 118 |
|
| 119 |
## License and credit
|
| 120 |
|
| 121 |
-
Merged submissions are published under the dataset's license, and the leaderboard row credits the submitter and organization in `submission.json`.
|
| 122 |
|
| 123 |
## Older results
|
| 124 |
|
|
|
|
| 4 |
|
| 5 |
Every accepted submission gets a row in the `leaderboard` config. We rescore every submission from its raw replies before listing it, so all you need to send is what you ran and what the model said.
|
| 6 |
|
| 7 |
+
**Fastest path.** If you ran `run_api.py` or `run_local.py`, one command builds the whole submission and, only if you ask, opens the pull request under your Hugging Face account:
|
| 8 |
+
|
| 9 |
+
```bash
|
| 10 |
+
python3 caibench_share.py results/openai_gpt-4.1-mini --name "Ada Example" --model-version 2025-04-14 # builds share/, sends nothing
|
| 11 |
+
python3 caibench_share.py results/openai_gpt-4.1-mini --name "Ada Example" --model-version 2025-04-14 --open-pr # shows what it will send, asks, then opens the PR
|
| 12 |
+
```
|
| 13 |
+
|
| 14 |
+
It copies the runner's reply files unchanged (a custom `--base-url` is replaced by `"custom"`), runs the official scorer, hashes the data files against `SHA256SUMS`, and refuses to package anything that looks like an API key. The rest of this guide is for runs from other harnesses, or if you prefer to do it by hand.
|
| 15 |
+
|
| 16 |
## 1. Run
|
| 17 |
|
| 18 |
Use the runner for your split, or any harness through the `prompts` config.
|
|
|
|
| 46 |
```
|
| 47 |
results/submissions/<org>__<model>__<version-or-date>/cai-bench-5.6.0/
|
| 48 |
submission.json # what you ran (required)
|
| 49 |
+
replies.jsonl # raw replies, one record per item_id (required, or raw/ below)
|
| 50 |
+
raw/<split>.jsonl # instead of replies.jsonl: the native runner's output files, unchanged
|
| 51 |
scores.json # the scorer output, unedited (required)
|
| 52 |
notes.md # anything a reader should know (optional)
|
| 53 |
```
|
|
|
|
| 75 |
|
| 76 |
```json
|
| 77 |
{
|
| 78 |
+
"submitter": {"name": "Ada Example", "organization": "Example Lab"},
|
| 79 |
"model": {
|
| 80 |
"name": "gpt-4.1-mini",
|
| 81 |
"version": "2025-04-14",
|
|
|
|
| 120 |
## 4. What happens next
|
| 121 |
|
| 122 |
1. We check the files against the schema and the hashes.
|
| 123 |
+
2. We rescore from `replies.jsonl` (or `raw/`) with the official scorers.
|
| 124 |
3. If every index matches your `scores.json` to within 0.005, we merge, add your rows to `leaderboard`, and mark them **verified**. If not, we comment on the PR with the difference, and the row waits until it is explained.
|
| 125 |
4. If your run bears on a preregistered prediction, we score the prediction and add the verdict to the `predictions` config, crediting your run.
|
| 126 |
|
|
|
|
| 128 |
|
| 129 |
## License and credit
|
| 130 |
|
| 131 |
+
Merged submissions are published under the dataset's license, and the leaderboard row credits the submitter and organization in `submission.json`. Everything in a pull request is public, so do not put an email address or anything private in the files; we reply in the pull request itself. Do not submit replies you are not allowed to publish, such as outputs from a model whose terms forbid it.
|
| 132 |
|
| 133 |
## Older results
|
| 134 |
|
run_api.py
CHANGED
|
@@ -214,6 +214,8 @@ def main():
|
|
| 214 |
ap.add_argument("--max-tokens", type=int, default=512)
|
| 215 |
ap.add_argument("--plan", action="store_true", help="print the number of calls and stop")
|
| 216 |
a = ap.parse_args()
|
|
|
|
|
|
|
| 217 |
provider, _, model = a.model.partition(":")
|
| 218 |
splits = [s for s in a.splits.split(",") if s]
|
| 219 |
calls = {s: count_calls(s) for s in splits}
|
|
@@ -230,6 +232,7 @@ def main():
|
|
| 230 |
print(f" {s}: done" + (f", {failed} failed call(s): rerun the same command to retry them" if failed else ""))
|
| 231 |
print(f"replies in {out_dir(provider, model)}; score with: python3 score_all.py {out_dir(provider, model)}"
|
| 232 |
+ (" or python3 score_headline.py " + str(out_dir(provider, model)) if "headline" in splits else ""))
|
|
|
|
| 233 |
|
| 234 |
|
| 235 |
if __name__ == "__main__":
|
|
|
|
| 214 |
ap.add_argument("--max-tokens", type=int, default=512)
|
| 215 |
ap.add_argument("--plan", action="store_true", help="print the number of calls and stop")
|
| 216 |
a = ap.parse_args()
|
| 217 |
+
from caibench_share import require_data, share_hint
|
| 218 |
+
require_data()
|
| 219 |
provider, _, model = a.model.partition(":")
|
| 220 |
splits = [s for s in a.splits.split(",") if s]
|
| 221 |
calls = {s: count_calls(s) for s in splits}
|
|
|
|
| 232 |
print(f" {s}: done" + (f", {failed} failed call(s): rerun the same command to retry them" if failed else ""))
|
| 233 |
print(f"replies in {out_dir(provider, model)}; score with: python3 score_all.py {out_dir(provider, model)}"
|
| 234 |
+ (" or python3 score_headline.py " + str(out_dir(provider, model)) if "headline" in splits else ""))
|
| 235 |
+
share_hint(out_dir(provider, model))
|
| 236 |
|
| 237 |
|
| 238 |
if __name__ == "__main__":
|
run_local.py
CHANGED
|
@@ -216,6 +216,8 @@ def main():
|
|
| 216 |
ap.add_argument("--models", default=",".join(DEFAULT_MODELS))
|
| 217 |
ap.add_argument("--splits", default=",".join(SPLITS))
|
| 218 |
a = ap.parse_args()
|
|
|
|
|
|
|
| 219 |
have = installed()
|
| 220 |
models = [m for m in a.models.split(",") if m]
|
| 221 |
splits = [s for s in a.splits.split(",") if s]
|
|
@@ -233,6 +235,9 @@ def main():
|
|
| 233 |
progress["all_finished"] = time.strftime("%Y-%m-%dT%H:%M:%S")
|
| 234 |
(HERE / "results" / "progress.json").write_text(json.dumps(progress, indent=1))
|
| 235 |
print("all done")
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
|
| 238 |
if __name__ == "__main__":
|
|
|
|
| 216 |
ap.add_argument("--models", default=",".join(DEFAULT_MODELS))
|
| 217 |
ap.add_argument("--splits", default=",".join(SPLITS))
|
| 218 |
a = ap.parse_args()
|
| 219 |
+
from caibench_share import require_data, share_hint
|
| 220 |
+
require_data()
|
| 221 |
have = installed()
|
| 222 |
models = [m for m in a.models.split(",") if m]
|
| 223 |
splits = [s for s in a.splits.split(",") if s]
|
|
|
|
| 235 |
progress["all_finished"] = time.strftime("%Y-%m-%dT%H:%M:%S")
|
| 236 |
(HERE / "results" / "progress.json").write_text(json.dumps(progress, indent=1))
|
| 237 |
print("all done")
|
| 238 |
+
for m in models:
|
| 239 |
+
if m in have:
|
| 240 |
+
share_hint(HERE / "results" / m.replace(":", "_").replace("/", "_"))
|
| 241 |
|
| 242 |
|
| 243 |
if __name__ == "__main__":
|
score_headline.py
CHANGED
|
@@ -96,6 +96,10 @@ def main():
|
|
| 96 |
print(f" {s:15s} {h}{oc}")
|
| 97 |
if "--json" in sys.argv:
|
| 98 |
Path(sys.argv[sys.argv.index("--json") + 1]).write_text(json.dumps(out, indent=1, default=str))
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
|
| 100 |
|
| 101 |
if __name__ == "__main__":
|
|
|
|
| 96 |
print(f" {s:15s} {h}{oc}")
|
| 97 |
if "--json" in sys.argv:
|
| 98 |
Path(sys.argv[sys.argv.index("--json") + 1]).write_text(json.dumps(out, indent=1, default=str))
|
| 99 |
+
if "--json" not in sys.argv:
|
| 100 |
+
from caibench_share import share_hint
|
| 101 |
+
for d in dirs:
|
| 102 |
+
share_hint(d)
|
| 103 |
|
| 104 |
|
| 105 |
if __name__ == "__main__":
|