compressionawareintelligence's picture
CAI-Bench 5.4.0: one-question card, leaderboard and prediction-ledger configs, future split and results (what memory keeps for later decisions), claims split (agent actions), coupling split and results, currency split and results, every 5.2 prediction scored, CAI Headline leaderboard, prompts config for any harness, lm-eval tasks, import_replies, report cards, datasheet
8e26cf8 verified
Raw History Blame
2.17 kB
"""lm-evaluation-harness hooks for CAI-Bench (dataset config `prompts`).
`answer_match` is a quick per-prompt check of the final answer line. It is NOT the CAI-Bench score: the official
indexes pair each prompt with its opposite and condition on the base case. For official numbers run with
`--log_samples` and score the samples file:
python3 import_replies.py --model <name> --lm-eval <output_dir>/<model>/samples_cai_bench_*.jsonl
python3 score_all.py results/<name> && python3 score_headline.py results/<name>
"""
import re
SPLITS = ("authority", "temporal", "release", "real", "relay", "floor", "live", "relational", "experience",
"capability", "observer", "reasons", "coherence", "hysteresis", "recoverability", "obligations", "currency", "coupling",
"dynamics")
def _plain(d):
return not d["messages_json"] and not d["multi_turn"]
def _make(split):
def f(dataset):
return dataset.filter(lambda d: d["split"] == split and _plain(d))
f.__name__ = f"docs_{split}"
return f
for _s in SPLITS:
globals()[f"docs_{_s}"] = _make(_s)
def docs_headline(dataset):
return dataset.filter(lambda d: d["in_headline"] and _plain(d))
def parse_answer(reply, line, fmt):
t = re.sub(r"[*`#]", "", reply or "")
if fmt == "owed":
m = re.findall(r"OWED\s*[:\-]\s*([A-Z ,]+|NONE)", t, re.I)
if not m:
return None
v = m[-1].upper()
return "NONE" if "NONE" in v else "".join(sorted(set(re.findall(r"[A-E]", v))))
if fmt == "choice":
m = re.findall(r"CHOICE\s*[:\-]\s*\(?([A-F])\b", t, re.I)
return m[-1].upper() if m else None
m = re.findall(rf"{line}\s*[:\-]\s*([A-Za-z_ ]+?)\s*(?:$|\n|\.)", t, re.I | re.M)
if not m:
return None
v = m[-1].strip().upper().replace(" ", "_")
return "NEED_INFO" if v.startswith("NEED") else v
def process_results(doc, results):
p = parse_answer(results[0], doc["answer_line"], doc["answer_format"])
gold = doc["gold"].upper()
if doc["answer_format"] == "owed":
gold = "NONE" if gold in ("", "NONE") else "".join(sorted(gold))
return {"answer_match": int(p == gold)}