Download scripts/build_v12_mix.py from Akahsizrr/alea-runs: direct link, hf CLI and curl.
- Browser
- Download file 2.13 kB
-
https://huggingface.co/datasets/Akahsizrr/alea-runs/resolve/main/scripts/build_v12_mix.py
- Command line
-
hf download hf://datasets/Akahsizrr/alea-runs/scripts/build_v12_mix.py
-
curl -L -o build_v12_mix.py https://huggingface.co/datasets/Akahsizrr/alea-runs/resolve/main/scripts/build_v12_mix.py
2.13 kB
| import hashlib, json, random | |
| from collections import Counter | |
| random.seed(12) | |
| D = "/root/alea/data/" | |
| SPECS = [ | |
| ("openjev_train.jsonl", 40000), | |
| ("tev1_train.jsonl", 30000), | |
| ("jevdec_train_v2.jsonl", 18000), | |
| ("tasksource_train.canon.jsonl", 40000), | |
| ("rlcd_train.canon.jsonl", 8000), | |
| ("tot_train.canon.jsonl", 4500), | |
| ("genhard_train.canon.jsonl", 23000), | |
| ("gh2_train.jsonl", 22507), | |
| ("reason_train.jsonl", 16544), | |
| ("sft_v6.jsonl", 12000), | |
| ("sft_v8b.jsonl", 8000), | |
| ("jb7_train.jsonl", 10000), | |
| ("jb6_train.jsonl", 6000), | |
| ] | |
| DEV_SPECS = [ | |
| ("openjev_validation.jsonl", 1000), ("tev1_dev.jsonl", 1000), | |
| ("tev1_transfer.jsonl", 800), | |
| ("tasksource_dev.canon.jsonl", 1200), ("rlcd_dev.canon.jsonl", 800), | |
| ("tot_dev.canon.jsonl", 311), ("genhard_dev.canon.jsonl", 1200), | |
| ("gh2_dev.jsonl", 1200), ("reason_dev.jsonl", 1096), | |
| ("jb7_dev.jsonl", 1500), | |
| ] | |
| def load(fn, cap): | |
| rows = [json.loads(l) for l in open(D + fn)] | |
| random.shuffle(rows) | |
| return rows[:cap] | |
| fps, mix, stats = set(), [], Counter() | |
| for fn, cap in SPECS: | |
| try: | |
| rows = load(fn, cap) | |
| except FileNotFoundError: | |
| print("MISSING", fn); continue | |
| kept = 0 | |
| for r in rows: | |
| st = json.dumps(r["state"], sort_keys=True, ensure_ascii=False) | |
| qs = r.get("questions") or [{"text": r.get("question"), "options": r.get("options")}] | |
| fp = hashlib.sha256((st + json.dumps(qs, sort_keys=True, ensure_ascii=False)).encode()).hexdigest() | |
| if fp in fps: continue | |
| fps.add(fp); mix.append(r); kept += 1 | |
| stats[fn] = kept | |
| random.shuffle(mix) | |
| with open(D + "v12_mix.jsonl", "w") as f: | |
| for r in mix: f.write(json.dumps(r, ensure_ascii=False) + "\n") | |
| dev, dstats = [], Counter() | |
| for fn, cap in DEV_SPECS: | |
| try: rows = load(fn, cap) | |
| except FileNotFoundError: print("DEV MISSING", fn); continue | |
| dev.extend(rows); dstats[fn] = len(rows) | |
| random.shuffle(dev) | |
| with open(D + "v12_dev.jsonl", "w") as f: | |
| for r in dev: f.write(json.dumps(r, ensure_ascii=False) + "\n") | |
| print("mix:", len(mix), dict(stats)) | |
| print("dev:", len(dev), dict(dstats)) | |