Download code/scripts/report.py from JagritGumber/shortlist: direct link, hf CLI and curl.
- Browser
- Download file 2.22 kB
-
https://huggingface.co/datasets/JagritGumber/shortlist/resolve/main/code/scripts/report.py
- Command line
-
hf download hf://datasets/JagritGumber/shortlist/code/scripts/report.py
-
curl -L -o report.py https://huggingface.co/datasets/JagritGumber/shortlist/resolve/main/code/scripts/report.py
2.22 kB
| """Print and save the learnability verdicts for one or more runs. | |
| python scripts/report.py runs/day1 [runs/day1-high ...] | |
| Episodes from all given runs are pooled per suite (so a later Beam-high run adds a rung to day1's ladder). | |
| Writes <first run>/report.json and report.md. | |
| """ | |
| import json | |
| import sys | |
| from collections import defaultdict | |
| from pathlib import Path | |
| sys.path.insert(0, str(Path(__file__).resolve().parent.parent)) | |
| from shortlist.checks import check_suite # noqa: E402 | |
| def fmt(x, nd=2): | |
| return "–" if x is None else (f"{x:.{nd}f}" if isinstance(x, float) else str(x)) | |
| def main() -> None: | |
| runs = [Path(p) for p in sys.argv[1:]] | |
| pooled: dict[str, list[dict]] = defaultdict(list) | |
| for run in runs: | |
| for path in sorted(run.glob("*.jsonl")): | |
| pooled[path.stem] += [json.loads(l) for l in path.read_text().splitlines() if l.strip()] | |
| results = [check_suite(s, rows) for s, rows in sorted(pooled.items())] | |
| (runs[0] / "report.json").write_text(json.dumps(results, indent=2)) | |
| lines = ["| Environment | Verdict | Floor (do-nothing/random) | Beam by effort | GRPO signal | Beam output tokens |", "|---|---|---|---|---|---|"] | |
| for r in results: | |
| t = r["tiers"] | |
| def rung(name): | |
| s = t.get(name) | |
| if not s: | |
| return None | |
| return f"{s['mean']:.2f}" + (f" ({s['pass@1']:.0%} solved)" if "pass@1" in s else "") | |
| floor = " / ".join(x for x in (rung("null"), rung("random")) if x) or "–" | |
| beams = ", ".join(f"{k[5:]}: {rung(k)}" for k in t if k.startswith("beam-")) or "–" | |
| tokens = sum(v["out_tokens"] for k, v in t.items() if k.startswith("beam-")) | |
| grpo = ", ".join(f"{k[5:]}: {v['grpo_signal']:.0%}" for k, v in t.items() if k.startswith("beam-") and v.get("grpo_signal") is not None) or "–" | |
| lines.append(f"| {r['suite']} | {r['verdict']} | {floor} | {beams} | {grpo} | {tokens:,} |") | |
| md = "\n".join(lines) | |
| (runs[0] / "report.md").write_text(md + "\n") | |
| print(md) | |
| for r in results: | |
| if r.get("error_examples"): | |
| print(f"\n{r['suite']} errors ({r['errors']}): {r['error_examples']}") | |
| if __name__ == "__main__": | |
| main() | |