Add the build script; card says how to rebuild
Browse files- README.md +2 -1
- build_jevbench.py +54 -0
README.md
CHANGED
|
@@ -32,4 +32,5 @@ loaded as one dataset directly.
|
|
| 32 |
|
| 33 |
Licenses are those of the underlying datasets; see the source dataset's
|
| 34 |
[manifest](https://github.com/uspraveen/Jevify/blob/main/docs/DATASETS.md). Rows are sampled with a fixed
|
| 35 |
-
seed by `
|
|
|
|
|
|
| 32 |
|
| 33 |
Licenses are those of the underlying datasets; see the source dataset's
|
| 34 |
[manifest](https://github.com/uspraveen/Jevify/blob/main/docs/DATASETS.md). Rows are sampled with a fixed
|
| 35 |
+
seed by `build_jevbench.py` in this repo:
|
| 36 |
+
`python build_jevbench.py --out DIR [--push tasksource/jevbench]` rebuilds it exactly.
|
build_jevbench.py
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Recast Praveenrajus/jev-bench into one flat dataset: N rows per data config (model-prediction dumps excluded),
|
| 2 |
+
merged, the config as a `task` column, every field a string (soft_label "" when absent). The per-config files
|
| 3 |
+
disagree on soft_label's type, so the raw configs cannot be loaded as one dataset.
|
| 4 |
+
|
| 5 |
+
python build_jevbench.py --out DIR [--push tasksource/jevbench] (or python -m task_diagnostics.build_jevbench)
|
| 6 |
+
"""
|
| 7 |
+
import argparse, json, random
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
|
| 10 |
+
SRC, REV = "Praveenrajus/jev-bench", "c37b0f6ab1687376ec9ae8dbd9f343163a68252b"
|
| 11 |
+
CONFIGS = ("arc_challenge banking77 boolq chaosnli civil_comments clinc150 fever_evidence go_emotions "
|
| 12 |
+
"helpsteer2_helpfulness helpsteer2_verbosity ledgar massive measuring_hate_speech mmlu mnli paws "
|
| 13 |
+
"sms_spam sst5 strategyqa_closed strategyqa_grounded stsb yelp5").split()
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def build(n, seed, splits):
|
| 17 |
+
from huggingface_hub import hf_hub_download
|
| 18 |
+
out = {}
|
| 19 |
+
for split in splits:
|
| 20 |
+
rows = []
|
| 21 |
+
for c in CONFIGS:
|
| 22 |
+
try:
|
| 23 |
+
p = hf_hub_download(SRC, f"data/{c}/{split}.jsonl", repo_type="dataset", revision=REV)
|
| 24 |
+
except Exception:
|
| 25 |
+
continue # chaosnli has a test split only
|
| 26 |
+
src = sorted((json.loads(l) for l in open(p)), key=lambda r: r["id"])
|
| 27 |
+
random.Random(f"{seed}/{c}/{split}").shuffle(src)
|
| 28 |
+
rows += [{"task": c, **{k: "" if r.get(k) is None else str(r[k]) for k in
|
| 29 |
+
("id", "primitive", "state", "question", "label", "soft_label", "meta")}} for r in src[:n]]
|
| 30 |
+
out[split] = rows
|
| 31 |
+
print(f"[jevbench] {split}: {len(rows)} rows over {len({r['task'] for r in rows})} tasks", flush=True)
|
| 32 |
+
return out
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
def main():
|
| 36 |
+
ap = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
| 37 |
+
ap.add_argument("--out", required=True)
|
| 38 |
+
ap.add_argument("--n", type=int, default=200, help="rows per config and split")
|
| 39 |
+
ap.add_argument("--splits", default="test,validation")
|
| 40 |
+
ap.add_argument("--seed", type=int, default=0)
|
| 41 |
+
ap.add_argument("--push", help="hub repo id to push to")
|
| 42 |
+
a = ap.parse_args()
|
| 43 |
+
data = build(a.n, a.seed, a.splits.split(","))
|
| 44 |
+
Path(a.out).mkdir(parents=True, exist_ok=True)
|
| 45 |
+
for split, rows in data.items():
|
| 46 |
+
(Path(a.out) / f"{split}.jsonl").write_text("".join(json.dumps(r) + "\n" for r in rows))
|
| 47 |
+
if a.push:
|
| 48 |
+
import datasets
|
| 49 |
+
dd = datasets.DatasetDict({s: datasets.Dataset.from_list(r) for s, r in data.items()})
|
| 50 |
+
dd.push_to_hub(a.push, commit_message=f"{a.n}/config sample of {SRC}@{REV[:7]}, seed {a.seed}")
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
if __name__ == "__main__":
|
| 54 |
+
main()
|