Datasets:
Download scripts/check_rates.py from AutomatedScientist/og2_small: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/datasets/AutomatedScientist/og2_small/resolve/main/scripts/check_rates.py
- Command line
-
hf download hf://datasets/AutomatedScientist/og2_small/scripts/check_rates.py
-
curl -L -o check_rates.py https://huggingface.co/datasets/AutomatedScientist/og2_small/resolve/main/scripts/check_rates.py
1.37 kB
| """Check uniformity: realized inclusion rate (kept bases / characters streamed) per subset and split, vs the target. | |
| python check_rates.py [--root .] [--split train] | |
| A per-base uniform sample keeps rate * (sequence characters) per subset; characters streamed also count tag and | |
| separator characters, so a subset with many tags or separators shows a slightly lower realized rate. | |
| """ | |
| from __future__ import annotations | |
| import argparse | |
| import json | |
| from collections import defaultdict | |
| from pathlib import Path | |
| def main() -> None: | |
| ap = argparse.ArgumentParser() | |
| ap.add_argument("--root", type=Path, default=Path(".")) | |
| ap.add_argument("--split", default="train") | |
| a = ap.parse_args() | |
| agg = defaultdict(lambda: [0, 0, 0, 0.0]) | |
| for done in sorted((a.root / a.split).glob("*/*.done")): | |
| st = json.loads(done.read_text()) | |
| g = agg[done.parent.name] | |
| g[0] += st["kept_bases"] | |
| g[1] += st["chars_seen"] | |
| g[2] += st["records"] | |
| g[3] = st["rate"] | |
| print(f"{'subset':<28} {'records':>12} {'chars/record':>13} {'kept/chars':>11} {'ratio to rate':>14}") | |
| for k, (kept, chars, recs, rate) in sorted(agg.items(), key=lambda kv: -kv[1][1]): | |
| r = kept / max(chars, 1) | |
| print(f"{k:<28} {recs:12d} {chars / max(recs, 1):13.0f} {r:11.3e} {r / rate:14.3f}") | |
| if __name__ == "__main__": | |
| main() | |