Datasets:
Download source/tools/select_tasks.py from dnakhla/terminal-desk: direct link, hf CLI and curl.
- Browser
- Download file 2.74 kB
-
https://huggingface.co/datasets/dnakhla/terminal-desk/resolve/main/source/tools/select_tasks.py
- Command line
-
hf download hf://datasets/dnakhla/terminal-desk/source/tools/select_tasks.py
-
curl -L -o select_tasks.py https://huggingface.co/datasets/dnakhla/terminal-desk/resolve/main/source/tools/select_tasks.py
2.74 kB
| """Pick the submission's task ids from a calibration screen. | |
| Rule (v3): keep ids the untrained model solved between --min and --max times out of its episodes, drop ids it | |
| never solved or always solved, and require that industrial + office make up at least --floor of the list. | |
| Errors (episodes that raised instead of finishing) are not counted as attempts. | |
| Usage: | |
| python tools/select_tasks.py runs/screen_v3.jsonl --min 1 --max 3 --out runs/selected3.txt | |
| """ | |
| import argparse | |
| import collections | |
| import json | |
| import sys | |
| DOMAIN = {"ind": "industrial", "off": "office", "sw": "software", "fin": "finance", | |
| "sci": "science", "math": "math", "sec": "security", "med": "media"} | |
| def domain_of(task_id: str) -> str: | |
| prefix = task_id.split("_", 1)[0].rstrip("0123456789") | |
| return DOMAIN[prefix] | |
| def main() -> None: | |
| p = argparse.ArgumentParser() | |
| p.add_argument("screen") | |
| p.add_argument("--min", type=int, default=1) | |
| p.add_argument("--max", type=int, default=3) | |
| p.add_argument("--floor", type=float, default=1 / 3, help="industrial + office share of the list") | |
| p.add_argument("--only", default="", help="comma-separated prefixes to consider, e.g. ind3,off3") | |
| p.add_argument("--out", default="") | |
| a = p.parse_args() | |
| solves, attempts, endings = collections.Counter(), collections.Counter(), collections.defaultdict(collections.Counter) | |
| for line in open(a.screen): | |
| r = json.loads(line) | |
| if "error" in r: | |
| continue | |
| t = r["task_id"] | |
| if a.only and not any(t.startswith(x) for x in a.only.split(",")): | |
| continue | |
| attempts[t] += 1 | |
| solves[t] += int(r["reward"] >= 1.0) | |
| endings[t][r["ended"]] += 1 | |
| keep, dropped = [], [] | |
| for t in sorted(attempts): | |
| n, s = attempts[t], solves[t] | |
| row = f"{t:24s} {s}/{n} " + " ".join(f"{k}={v}" for k, v in sorted(endings[t].items())) | |
| (keep if a.min <= s <= a.max else dropped).append(row) | |
| print("kept:"); print("\n".join(keep)); print("dropped:"); print("\n".join(dropped)) | |
| ids = [r.split()[0] for r in keep] | |
| by_domain = collections.Counter(domain_of(t) for t in ids) | |
| core = by_domain["industrial"] + by_domain["office"] | |
| print(f"\n{len(ids)} ids; per domain {dict(by_domain)}; industrial+office share {core / max(1, len(ids)):.2f}") | |
| if ids and core / len(ids) < a.floor: | |
| print(f"industrial + office below the {a.floor:.2f} floor: fix the screen or widen their bands", file=sys.stderr) | |
| sys.exit(1) | |
| if a.out: | |
| with open(a.out, "w") as fh: | |
| fh.write(f"# {a.screen}: ids solved {a.min}-{a.max} times\n" + "\n".join(ids) + "\n") | |
| print("wrote", a.out) | |
| if __name__ == "__main__": | |
| main() | |