"""Join panel question IDs to the public benchmark datasets. The package itself contains no question text. uv run --no-project --with pandas --with pyarrow --with datasets python code/load_questions.py \ panels/main256.parquet questions_main256.jsonl --math-dir path/to/MATH [--jmmlu-dir path/to/JMMLU] Sources and keys (column source_key of every panel file): MMLU-Pro TIGER-Lab/MMLU-Pro, split test, field question_id (ID mmlu_pro__test_) SuperGPQA m-a-p/SuperGPQA, split train, field uuid (ID supergpqa__) MathArena MathArena/, split train, field problem_idx (ID __) MATH the original release of Hendrycks et al. (2021), file test//.json (ID math__test__); pass the unpacked folder with --math-dir JMMLU nlp-waseda/JMMLU at revision 762cbf192c9e4588b574d718f95afd64c96fcbf4, JMMLU/.csv, zero-based CSV row (ID .); pass a clone at that revision with --jmmlu-dir Each dataset keeps its own licence; check it before use. JMMLU's licence does not allow redistributing modified copies, which is one reason the package ships IDs only. The output file is for local use and is not part of the package. Rows that cannot be resolved are reported, not guessed. """ from __future__ import annotations import argparse import csv import json from pathlib import Path import pandas as pd def mmlu_pro(): from datasets import load_dataset # noqa: PLC0415 return {int(r["question_id"]): r for r in load_dataset("TIGER-Lab/MMLU-Pro", split="test")} def supergpqa(): from datasets import load_dataset # noqa: PLC0415 return {r["uuid"]: r for r in load_dataset("m-a-p/SuperGPQA", split="train")} def matharena(contest): from datasets import load_dataset # noqa: PLC0415 rows = load_dataset(f"MathArena/{contest}", split="train") key = "problem_idx" if "problem_idx" in rows.column_names else None if key is None: raise KeyError(f"MathArena/{contest} has no problem_idx column: {rows.column_names}") return {int(r[key]): r for r in rows} def main(): ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) ap.add_argument("panel", type=Path) ap.add_argument("output", type=Path) ap.add_argument("--math-dir", type=Path) ap.add_argument("--jmmlu-dir", type=Path) a = ap.parse_args() panel = pd.read_parquet(a.panel) cache, out, missing = {}, [], [] def get(name, loader): if name not in cache: cache[name] = loader() return cache[name] for row in panel.itertuples(): qid, src = row.question_id, row.source_dataset try: if src == "MMLU-Pro": r = get("mmlu_pro", mmlu_pro)[int(row.source_key)] text = {"question": r["question"], "options": list(r["options"]), "answer": r["answer"]} elif src == "SuperGPQA": r = get("supergpqa", supergpqa)[row.source_key] text = {"question": r["question"], "options": list(r["options"]), "answer": r.get("answer_letter", r.get("answer"))} elif src == "MathArena": contest = row.hf_dataset.split("/", 1)[1] r = get(contest, lambda: matharena(contest))[int(row.source_key)] text = {"question": r["problem"], "answer": r.get("answer")} elif src == "MATH": if a.math_dir is None: raise FileNotFoundError("--math-dir not given") r = json.loads((a.math_dir / row.source_key).read_text()) text = {"question": r["problem"], "solution": r["solution"], "level": r.get("level")} elif src == "JMMLU": if a.jmmlu_dir is None: raise FileNotFoundError("--jmmlu-dir not given") subject, line = row.question_id.rsplit(".", 1) def read_csv(subject=subject): with (a.jmmlu_dir / "JMMLU" / f"{subject}.csv").open(encoding="utf-8-sig", newline="") as f: return list(csv.reader(f)) stem, *options, label = get("jmmlu/" + subject, read_csv)[int(line)] text = {"question": stem, "options": options, "answer": label.strip()} else: raise KeyError(src) except (KeyError, FileNotFoundError, IndexError) as e: missing.append((qid, repr(e))) continue out.append({"question_id": qid, "source_dataset": src, **text}) with a.output.open("w", encoding="utf-8") as f: for r in out: f.write(json.dumps(r, ensure_ascii=False) + "\n") print(f"resolved {len(out)} of {len(panel)}; wrote {a.output}") for qid, why in missing: print("unresolved", qid, why) if __name__ == "__main__": main()