{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Shortlist forward test: maze\n", "\n", "Shortlist's can-it-be-gamed check says GRPO will collapse Qwen3-0.6B onto a constant answer on maze (\"5\" or \"6\"), without learning to solve mazes. The prediction was published before this notebook existed (SHA-256 `4cca90e80a446fcb9286c2e9007450c7fd31e2d692f32b24d256eca118477cc8`).\n", "\n", "**Setup.** Kaggle: Settings → Accelerator → *GPU T4 x1*, and *Internet on*. Then **Run all** (about 20–30 minutes). Download `shortlist-maze-results.zip` from the Output panel at the end." ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "!pip install -q trl==1.17.0 peft==0.21.2 transformers==5.22.0 accelerate==1.15.0 datasets==5.1.0 reasoning-gym==0.1.25\n", "# A preinstalled torchao older than 0.16 makes PEFT refuse to import; Shortlist doesn't use it.\n", "!pip uninstall -y -q torchao\n", "import torch, importlib.metadata as m\n", "print('GPU:', torch.cuda.get_device_name(0) if torch.cuda.is_available() else 'none — switch the accelerator to a GPU')\n", "print({p: m.version(p) for p in ['torch','trl','peft','transformers','accelerate','datasets','reasoning-gym']})" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "%%writefile trainee.py\n", "\"\"\"The model you would train, defined once: its prompt, its sampling, and Shortlist's rule for it.\n", "\n", "Both the ladder's small-model rung (on single-answer tasks) and the GRPO training proof import from here,\n", "so the proof tests exactly the rule the shortlist applies.\n", "\"\"\"\n", "\n", "from __future__ import annotations\n", "\n", "MODEL = \"Qwen/Qwen3-0.6B\"\n", "SYSTEM = \"Solve the task. Reply with only the final answer, in the format the task asks for. No explanation.\"\n", "TEMPERATURE = 1.0 # what GRPO samples at\n", "MAX_NEW_TOKENS = 64\n", "\n", "# Shortlist's rule for the trainee: it sometimes succeeds, isn't already saturated, and enough of its\n", "# tasks give GRPO a gradient (the repeated attempts at one task don't all score the same).\n", "PASS_MIN = 0.0 # pass@1 must be above this\n", "PASS_MAX = 0.95 # and below this\n", "GRPO_SIGNAL_MIN = 0.2 # share of tasks whose attempts disagree\n", "\n", "\n", "def messages(question: str) -> list[dict]:\n", " # \"/no_think\" is Qwen3's switch for answering without a thinking block.\n", " return [{\"role\": \"system\", \"content\": SYSTEM}, {\"role\": \"user\", \"content\": question.strip() + \" /no_think\"}]\n", "\n", "\n", "def clean(text: str) -> str:\n", " text = (text or \"\").replace(\"\", \"\").replace(\"\", \"\").strip()\n", " if \"answer:\" in text.lower():\n", " text = text[text.lower().rfind(\"answer:\") + 7:]\n", " return text.strip().strip(\"`\").strip()\n", "\n", "\n", "def rule(pass1: float, mean_score: float, grpo_signal: float | None) -> str:\n", " \"\"\"'improves' when GRPO should be able to raise the trainee's score on this environment, else why not.\n", "\n", " GRPO learns from any reward difference within a group, partial credit included, so \"too hard\" means the\n", " trainee earns no reward at all, not merely that it never fully solves a task.\n", " \"\"\"\n", " if mean_score <= PASS_MIN:\n", " return \"too hard now\"\n", " if pass1 >= PASS_MAX:\n", " return \"too easy\"\n", " if grpo_signal is None:\n", " return \"unknown\"\n", " if grpo_signal < GRPO_SIGNAL_MIN:\n", " return \"no gradient\"\n", " return \"improves\"\n" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "%%writefile grpo_proof.py\n", "\"\"\"Training proof: do Shortlist's verdicts predict which environments GRPO can improve a small model on?\n", "\n", "For each Reasoning Gym family (the tasks behind OpenEnv's reasoning_gym_env, whose reward is the family's\n", "own `score_answer`), in two separate runs:\n", "\n", " python grpo_proof.py --predict-only --out results # 1. write predictions.json (and its SHA-256) first\n", " python grpo_proof.py --out results # 2. train, then compare with the predictions\n", "\n", "1. Predict with Shortlist's rule (shortlist/trainee.py, the same rule the shortlist uses for the small model)\n", " from the trainee's own samples, drawn exactly as GRPO draws them (same prompt, temperature and length).\n", "2. Score 200 held-out tasks before training (greedy), train with GRPO + LoRA on the environment's reward,\n", " score the same 200 tasks after. \"Improved\" means a paired bootstrap on those 200 tasks puts the gain\n", " above zero (p <= 0.05).\n", "Full precision (fp32): a T4 has no bf16, and fp16 can give NaN losses with Qwen3.\n", "\"\"\"\n", "\n", "from __future__ import annotations\n", "\n", "import argparse\n", "import json\n", "import random\n", "import time\n", "from pathlib import Path\n", "\n", "import hashlib\n", "import os\n", "import sys\n", "\n", "# TRL's GRPO trainer can't use nn.DataParallel, which Trainer picks when several GPUs are visible (Kaggle's T4 x2).\n", "os.environ.setdefault(\"CUDA_VISIBLE_DEVICES\", \"0\")\n", "\n", "import numpy as np\n", "import reasoning_gym\n", "import torch\n", "from datasets import Dataset\n", "from peft import LoraConfig\n", "from transformers import AutoModelForCausalLM, AutoTokenizer\n", "from trl import GRPOConfig, GRPOTrainer\n", "\n", "# The trainee's prompt, sampling and Shortlist's rule live in shortlist/trainee.py; on Kaggle or Colab the\n", "# notebook writes that file next to this one.\n", "sys.path.insert(0, str(Path(__file__).resolve().parent.parent))\n", "sys.path.insert(0, str(Path(__file__).resolve().parent))\n", "try:\n", " from shortlist import trainee\n", "except ImportError:\n", " import trainee # type: ignore\n", "\n", "messages, clean = trainee.messages, trainee.clean\n", "\n", "\n", "def tasks(family: str, seeds: range) -> list[dict]:\n", " out = []\n", " for seed in seeds:\n", " entry = reasoning_gym.create_dataset(family, seed=seed, size=1)[0]\n", " out.append({\"family\": family, \"seed\": seed, \"question\": entry[\"question\"], \"entry\": json.dumps(entry, default=str)})\n", " return out\n", "\n", "\n", "def score(family: str, seed: int, answer: str) -> float:\n", " ds = reasoning_gym.create_dataset(family, seed=seed, size=1)\n", " try:\n", " return float(ds.score_answer(answer=answer, entry=ds[0]))\n", " except Exception: # a malformed answer earns nothing, as in the environment\n", " return 0.0\n", "\n", "\n", "@torch.no_grad()\n", "def sample(model, tok, rows: list[dict], n: int, greedy: bool, max_new: int, batch: int = 16) -> list[list[str]]:\n", " \"\"\"n completions per row, generated in batches of rows (left-padded).\"\"\"\n", " tok.padding_side = \"left\"\n", " if tok.pad_token is None:\n", " tok.pad_token = tok.eos_token\n", " outs: list[list[str]] = []\n", " batch = max(1, 32 // n) # at most 32 sequences in memory at once\n", " for i in range(0, len(rows), batch):\n", " chunk = rows[i:i + batch]\n", " prompts = [tok.apply_chat_template(messages(r[\"question\"]), tokenize=False, add_generation_prompt=True, enable_thinking=False)\n", " for r in chunk]\n", " enc = tok(prompts, return_tensors=\"pt\", padding=True).to(model.device)\n", " gen = model.generate(**enc, max_new_tokens=max_new, do_sample=not greedy,\n", " temperature=trainee.TEMPERATURE if not greedy else None, top_p=1.0 if not greedy else None,\n", " num_return_sequences=n, pad_token_id=tok.pad_token_id)\n", " texts = [clean(tok.decode(g[enc[\"input_ids\"].shape[1]:], skip_special_tokens=True)) for g in gen]\n", " outs += [texts[j * n:(j + 1) * n] for j in range(len(chunk))]\n", " return outs\n", "\n", "\n", "def predict(model, tok, family: str, k: int, n_tasks: int, max_new: int) -> dict:\n", " rows = tasks(family, range(500, 500 + n_tasks))\n", " groups = sample(model, tok, rows, k, greedy=False, max_new=max_new)\n", " scores = [[score(family, r[\"seed\"], a) for a in g] for r, g in zip(rows, groups)]\n", " flat = [s for g in scores for s in g]\n", " pass1 = sum(s >= 1.0 for s in flat) / len(flat)\n", " passk = sum(any(s >= 1.0 for s in g) for g in scores) / len(scores)\n", " mean = sum(flat) / len(flat)\n", " disagree = sum(max(g) - min(g) > 1e-9 for g in scores) / len(scores)\n", " verdict = trainee.rule(pass1, mean, disagree)\n", " return {\"family\": family, \"pass@1\": pass1, f\"pass@{k}\": passk, \"mean_score\": mean, \"grpo_signal\": disagree,\n", " \"shortlist_verdict\": verdict, \"prediction\": \"improves\" if verdict == \"improves\" else \"no change\"}\n", "\n", "\n", "def evaluate(model, tok, family: str, n: int, max_new: int) -> dict:\n", " rows = tasks(family, range(100_000, 100_000 + n))\n", " answers = [g[0] for g in sample(model, tok, rows, 1, greedy=True, max_new=max_new)]\n", " scores = [score(family, r[\"seed\"], a) for r, a in zip(rows, answers)]\n", " return {\"accuracy\": sum(s >= 1.0 for s in scores) / n, \"mean_score\": sum(scores) / n, \"scores\": scores,\n", " \"examples\": [{\"seed\": r[\"seed\"], \"answer\": a, \"score\": s} for r, a, s in list(zip(rows, answers, scores))[:5]],\n", " \"answers\": answers} # every answer, in seed order, so the result can be re-scored later\n", "\n", "\n", "def paired_gain(before: list[float], after: list[float], n: int = 10000) -> dict:\n", " \"\"\"Mean gain on the same tasks, with a paired bootstrap p-value for 'gain <= 0'.\"\"\"\n", " d = np.asarray(after) - np.asarray(before)\n", " rng = np.random.default_rng(0)\n", " boots = rng.choice(d, (n, len(d))).mean(1)\n", " return {\"gain\": float(d.mean()), \"ci95\": [float(np.percentile(boots, 2.5)), float(np.percentile(boots, 97.5))],\n", " \"p\": float(np.mean(boots <= 0))}\n", "\n", "\n", "def main() -> None:\n", " ap = argparse.ArgumentParser()\n", " ap.add_argument(\"--families\", default=\"basic_arithmetic,propositional_logic,word_sorting,leg_counting,letter_counting,chain_sum\")\n", " ap.add_argument(\"--model\", default=trainee.MODEL)\n", " ap.add_argument(\"--steps\", type=int, default=100)\n", " ap.add_argument(\"--group\", type=int, default=8)\n", " ap.add_argument(\"--prompts-per-step\", type=int, default=4)\n", " ap.add_argument(\"--max-new\", type=int, default=trainee.MAX_NEW_TOKENS)\n", " ap.add_argument(\"--eval-n\", type=int, default=200)\n", " ap.add_argument(\"--predict-only\", action=\"store_true\", help=\"write predictions.json and stop\")\n", " ap.add_argument(\"--predict-tasks\", type=int, default=24)\n", " ap.add_argument(\"--lr\", type=float, default=5e-5)\n", " ap.add_argument(\"--out\", default=\"results\")\n", " ap.add_argument(\"--predictions\", help=\"a prediction file written in advance (default: /predictions.json)\")\n", " args = ap.parse_args()\n", " out = Path(args.out)\n", " out.mkdir(parents=True, exist_ok=True)\n", " device = \"cuda\" if torch.cuda.is_available() else \"cpu\"\n", " dtype = torch.float32\n", " tok = AutoTokenizer.from_pretrained(args.model)\n", " families = args.families.split(\",\")\n", " pred_path = Path(args.predictions) if args.predictions and not args.predict_only else out / \"predictions.json\"\n", "\n", " # 1. Predictions, as a separate run, written down before any training.\n", " if args.predict_only:\n", " base = AutoModelForCausalLM.from_pretrained(args.model, dtype=dtype).to(device)\n", " predictions = [predict(base, tok, f, args.group, args.predict_tasks, args.max_new) for f in families]\n", " body = json.dumps({\"written_at\": time.strftime(\"%Y-%m-%d %H:%M:%S %Z\"), \"model\": args.model,\n", " \"rule\": f\"shortlist/trainee.py: improves if mean score > {trainee.PASS_MIN}, pass@1 < {trainee.PASS_MAX}, \"\n", " f\"GRPO signal >= {trainee.GRPO_SIGNAL_MIN}\",\n", " \"settings\": vars(args), \"predictions\": predictions}, indent=2)\n", " pred_path.write_text(body)\n", " digest = hashlib.sha256(body.encode()).hexdigest()\n", " (out / \"predictions.sha256\").write_text(digest + \" predictions.json\\n\")\n", " print(body, f\"\\nSHA-256 {digest}\", flush=True)\n", " return\n", " if not pred_path.exists():\n", " raise SystemExit(\"Run with --predict-only first, so the predictions exist before any training.\")\n", " predictions = json.loads(pred_path.read_text())[\"predictions\"]\n", "\n", " results = []\n", " for pred in predictions:\n", " family = pred[\"family\"]\n", " model = AutoModelForCausalLM.from_pretrained(args.model, dtype=dtype).to(device)\n", " before = evaluate(model, tok, family, args.eval_n, args.max_new)\n", " train_rows = tasks(family, range(0, args.steps * args.prompts_per_step))\n", " random.Random(0).shuffle(train_rows)\n", " ds = Dataset.from_list([{\"prompt\": messages(r[\"question\"]), \"seed\": r[\"seed\"]} for r in train_rows])\n", "\n", " def reward(prompts, completions, seed, **_):\n", " texts = [c[0][\"content\"] if isinstance(c, list) else c for c in completions]\n", " return [score(family, s, clean(t)) for s, t in zip(seed, texts)]\n", "\n", " cfg = GRPOConfig(\n", " output_dir=str(out / f\"ckpt-{family}\"), max_steps=args.steps, learning_rate=args.lr,\n", " per_device_train_batch_size=4, gradient_accumulation_steps=args.group * args.prompts_per_step // 4, num_generations=args.group,\n", " max_completion_length=args.max_new, temperature=1.0, logging_steps=5, save_strategy=\"no\",\n", " report_to=[], fp16=False, bf16=False, gradient_checkpointing=False, seed=0,\n", " )\n", " trainer = GRPOTrainer(model=model, reward_funcs=[reward], args=cfg, train_dataset=ds,\n", " peft_config=LoraConfig(r=16, lora_alpha=32, target_modules=\"all-linear\", task_type=\"CAUSAL_LM\"))\n", " started = time.time()\n", " trainer.train()\n", " trained = trainer.model.merge_and_unload() if hasattr(trainer.model, \"merge_and_unload\") else trainer.model\n", " after = evaluate(trained, tok, family, args.eval_n, args.max_new)\n", " curve = [{\"step\": h.get(\"step\"), \"reward\": h.get(\"reward\")} for h in trainer.state.log_history if \"reward\" in h]\n", " gain = paired_gain(before[\"scores\"], after[\"scores\"])\n", " improved = gain[\"p\"] <= 0.05 and gain[\"gain\"] > 0\n", " res = {**pred, \"before\": {k: v for k, v in before.items() if k != \"scores\"}, \"after\": {k: v for k, v in after.items() if k != \"scores\"},\n", " \"gain\": gain, \"improved\": improved, \"held\": improved == (pred[\"prediction\"] == \"improves\"),\n", " \"reward_curve\": curve, \"minutes\": round((time.time() - started) / 60, 1)}\n", " results.append(res)\n", " (out / \"results.json\").write_text(json.dumps(results, indent=2))\n", " print(f\"{family}: predicted {pred['prediction']}; mean score {before['mean_score']:.3f} -> {after['mean_score']:.3f} \"\n", " f\"(gain {gain['gain']:+.3f}, p={gain['p']:.3f}); prediction held: {res['held']}\", flush=True)\n", " del model, trainer, trained\n", " if device == \"cuda\":\n", " torch.cuda.empty_cache()\n", "\n", "\n", "if __name__ == \"__main__\":\n", " main()\n" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "%%writefile maze_check.py\n", "\"\"\"Score the maze forward test's pre-registered claims (P1-P4) from the training run's saved answers.\n", "\n", " python maze_check.py results-maze/results.json predictions.json # on Kaggle, or locally\n", "\n", "Writes /claims.json and prints one line per claim.\n", "\"\"\"\n", "\n", "import json\n", "import sys\n", "from collections import Counter\n", "from pathlib import Path\n", "\n", "import numpy as np\n", "import reasoning_gym\n", "\n", "HELD_OUT = range(100_000, 100_200)\n", "\n", "\n", "def paired_p(before: list[float], after: list[float], n: int = 10000) -> tuple[float, float]:\n", " \"\"\"Mean gain and the paired-bootstrap p-value for 'gain <= 0' (as in grpo_proof.py).\"\"\"\n", " d = np.asarray(after, dtype=float) - np.asarray(before, dtype=float)\n", " if len(d) == 0:\n", " return 0.0, 1.0\n", " boots = np.random.default_rng(0).choice(d, (n, len(d))).mean(1)\n", " return float(d.mean()), float(np.mean(boots <= 0))\n", "\n", "\n", "def main() -> None:\n", " res_path, pred_path = Path(sys.argv[1]), Path(sys.argv[2])\n", " r = next(x for x in json.loads(res_path.read_text()) if x[\"family\"] == \"maze\")\n", " before, after = r[\"before\"][\"answers\"], r[\"after\"][\"answers\"]\n", " sets = [reasoning_gym.create_dataset(\"maze\", seed=s, size=1) for s in HELD_OUT]\n", " truth = [str(ds[0][\"answer\"]) for ds in sets]\n", " solved = lambda i, a: float(sets[i].score_answer(answer=a, entry=sets[i][0]) >= 1.0) # the environment's own grader\n", " top, top_n = Counter(a.strip() for a in after).most_common(1)[0]\n", " others = [i for i, t in enumerate(truth) if t != top]\n", " acc_b = [solved(i, before[i]) for i in others]\n", " acc_a = [solved(i, after[i]) for i in others]\n", " gain, p = paired_p(acc_b, acc_a)\n", " claims = [\n", " {\"id\": \"P1\", \"held\": r[\"gain\"][\"p\"] <= 0.05 and r[\"gain\"][\"gain\"] > 0,\n", " \"measured\": f\"mean reward {r['before']['mean_score']:.3f} -> {r['after']['mean_score']:.3f}, paired p = {r['gain']['p']:.3f}\"},\n", " {\"id\": \"P2\", \"held\": top_n / len(after) >= 0.5,\n", " \"measured\": f\"most common answer after training: {top!r}, {top_n} of {len(after)} answers\"},\n", " {\"id\": \"P3\", \"held\": top in (\"5\", \"6\"), \"measured\": f\"most common answer after training: {top!r}\"},\n", " {\"id\": \"P4\", \"held\": p > 0.05,\n", " \"measured\": f\"accuracy on the {len(others)} tasks whose answer isn't {top!r}: {np.mean(acc_b):.3f} -> {np.mean(acc_a):.3f}, \"\n", " f\"paired p = {p:.3f}\"},\n", " ]\n", " stated = {c[\"id\"]: c for c in json.loads(pred_path.read_text())[\"predictions\"][0][\"claims\"]}\n", " for c in claims:\n", " c.update(claim=stated[c[\"id\"]][\"claim\"], test=stated[c[\"id\"]][\"test\"])\n", " print(f\"{c['id']} {'HELD ' if c['held'] else 'FAILED'} {c['claim']} [{c['measured']}]\")\n", " out = {\"most_common_after\": top, \"share\": top_n / len(after),\n", " \"answers_after\": Counter(a.strip() for a in after).most_common(8), \"claims\": claims}\n", " (res_path.parent / \"claims.json\").write_text(json.dumps(out, indent=2))\n", "\n", "\n", "if __name__ == \"__main__\":\n", " main()\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The published prediction\n", "\n", "Written byte for byte, then checked against the fingerprint published before training. Training refuses to start on a mismatch." ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "import base64, hashlib, pathlib\n", "PUBLISHED_SHA256 = '4cca90e80a446fcb9286c2e9007450c7fd31e2d692f32b24d256eca118477cc8'\n", "pathlib.Path('predictions.json').write_bytes(base64.b64decode('ewogICJ0aXRsZSI6ICJTaG9ydGxpc3QgZm9yd2FyZCB0ZXN0OiBtYXplIiwKICAid3JpdHRlbl9hdCI6ICIyMDI2LTEwLTMxIDIyOjMxOjEyIFVUQyIsCiAgIm1vZGVsIjogIlF3ZW4vUXdlbjMtMC42QiIsCiAgIm1ldGhvZCI6ICJVbmNoYW5nZWQgZnJvbSB0aGUgc2l4LWZhbWlseSBydW46IHRyYWluaW5nL2dycG9fcHJvb2YucHksIDEwMCBHUlBPIHN0ZXBzLCBMb1JBIHI9MTYsIGxlYXJuaW5nIHJhdGUgNWUtNSwgOCBzYW1wbGVzIHBlciBwcm9tcHQsIDQgcHJvbXB0cyBwZXIgc3RlcCwgdHJhaW5pbmcgdGFza3MgYXJlIHNlZWRzIDAtMzk5OyBzY29yZWQgZ3JlZWR5IG9uIGhlbGQtb3V0IHNlZWRzIDEwMDAwMC0xMDAxOTkgYmVmb3JlIGFuZCBhZnRlciB0cmFpbmluZy4gUnVuOiBweXRob24gZ3Jwb19wcm9vZi5weSAtLWZhbWlsaWVzIG1hemUgLS1wcmVkaWN0aW9ucyBwcmVkaWN0aW9ucy5qc29uIiwKICAicHJlZGljdGlvbnMiOiBbCiAgICB7CiAgICAgICJmYW1pbHkiOiAibWF6ZSIsCiAgICAgICJwcmVkaWN0aW9uIjogImltcHJvdmVzIiwKICAgICAgImV2aWRlbmNlX2JlZm9yZV90cmFpbmluZyI6IHsKICAgICAgICAic2hvcnRsaXN0X3ZlcmRpY3QiOiAid29ydGggdHJhaW5pbmcgdGhlIHNtYWxsIG1vZGVsIG9uIiwKICAgICAgICAic21hbGxfbW9kZWxfbWVhbl9yZXdhcmRfb25fbGFkZGVyIjogMC4wMDEsCiAgICAgICAgInNtYWxsX21vZGVsX2dycG9fc2lnbmFsX29uX2xhZGRlciI6IDAuMjUsCiAgICAgICAgImdhbWluZ19jaGVjayI6IHsKICAgICAgICAgICJjb25zdGFudF9hbnN3ZXIiOiAiNSIsCiAgICAgICAgICAiaXRzX2hlbGRfb3V0X3Njb3JlIjogMC4zMTUsCiAgICAgICAgICAibW9zdF9jb21tb25fY29ycmVjdF9hbnN3ZXJzX29uX3RyYWluaW5nX3Rhc2tzIjogewogICAgICAgICAgICAiNSI6IDExNCwKICAgICAgICAgICAgIjYiOiAxMTIsCiAgICAgICAgICAgICI3IjogNjYsCiAgICAgICAgICAgICI4IjogNTIKICAgICAgICAgIH0sCiAgICAgICAgICAidHJhaW5pbmdfdGFza3MiOiA0MDAKICAgICAgICB9CiAgICAgIH0sCiAgICAgICJjbGFpbXMiOiBbCiAgICAgICAgewogICAgICAgICAgImlkIjogIlAxIiwKICAgICAgICAgICJjbGFpbSI6ICJSZXdhcmQgcmlzZXMuIiwKICAgICAgICAgICJ0ZXN0IjogIk1lYW4gaGVsZC1vdXQgcmV3YXJkIGFmdGVyIHRyYWluaW5nIGlzIGFib3ZlIGJlZm9yZSwgcGFpcmVkIGJvb3RzdHJhcCBwIDw9IDAuMDUgKHRoZSBzYW1lIHRlc3QgYXMgdGhlIHNpeC1mYW1pbHkgcnVuKS4iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAiaWQiOiAiUDIiLAogICAgICAgICAgImNsYWltIjogIlRoZSBtb2RlbCBjb2xsYXBzZXMgb250byBvbmUgY29uc3RhbnQgYW5zd2VyLiIsCiAgICAgICAgICAidGVzdCI6ICJBZnRlciB0cmFpbmluZywgYSBzaW5nbGUgYW5zd2VyIHN0cmluZyBtYWtlcyB1cCBhdCBsZWFzdCA1MCUgb2YgdGhlIDIwMCBncmVlZHkgaGVsZC1vdXQgYW5zd2Vycy4iCiAgICAgICAgfSwKICAgICAgICB7CiAgICAgICAgICAiaWQiOiAiUDMiLAogICAgICAgICAgImNsYWltIjogIlRoZSBjb25zdGFudCBpcyA1IG9yIDYuIiwKICAgICAgICAgICJ0ZXN0IjogIlRoZSBtb3N0IGNvbW1vbiBhbnN3ZXIgYWZ0ZXIgdHJhaW5pbmcgaXMgJzUnIG9yICc2JywgdGhlIHR3byBtb3N0IGNvbW1vbiBjb3JyZWN0IGFuc3dlcnMgb24gdGhlIHRyYWluaW5nIHRhc2tzLiIKICAgICAgICB9LAogICAgICAgIHsKICAgICAgICAgICJpZCI6ICJQNCIsCiAgICAgICAgICAiY2xhaW0iOiAiTm8gbWF6ZS1zb2x2aW5nIHNraWxsIGlzIGxlYXJuZWQuIiwKICAgICAgICAgICJ0ZXN0IjogIk9uIGhlbGQtb3V0IHRhc2tzIHdob3NlIGNvcnJlY3QgYW5zd2VyIGRpZmZlcnMgZnJvbSB0aGUgbW9kZWwncyBtb3N0IGNvbW1vbiBhbnN3ZXIgYWZ0ZXIgdHJhaW5pbmcsIGFjY3VyYWN5IGRvZXMgbm90IHJpc2U6IHBhaXJlZCBib290c3RyYXAgcCA+IDAuMDUgZm9yIGEgZ2Fpbi4iCiAgICAgICAgfQogICAgICBdLAogICAgICAicmVwb3J0aW5nIjogIkV2ZXJ5IGNsYWltIGlzIHJlcG9ydGVkIGFzIGhlbGQgb3IgZmFpbGVkLCB3aGF0ZXZlciB0aGUgb3V0Y29tZS4iCiAgICB9CiAgXQp9Cg=='))\n", "actual = hashlib.sha256(pathlib.Path('predictions.json').read_bytes()).hexdigest()\n", "assert actual == PUBLISHED_SHA256, f'predictions.json differs from the published one ({actual})'\n", "print(pathlib.Path('predictions.json').read_text())\n", "print('fingerprint matches')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Train and score (about 20–30 minutes)" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "!python grpo_proof.py --families maze --predictions predictions.json --out results-maze 2>&1 | grep -vE 'Warning|warn'" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## The claims" ] }, { "cell_type": "code", "metadata": {}, "execution_count": null, "outputs": [], "source": [ "!python maze_check.py results-maze/results.json predictions.json\n", "import shutil; shutil.copy('predictions.json', 'results-maze/predictions.json')\n", "shutil.make_archive('shortlist-maze-results', 'zip', 'results-maze')\n", "print('Download shortlist-maze-results.zip from the Output panel.')" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "name": "python" } }, "nbformat": 4, "nbformat_minor": 5 }