Datasets:
File size: 652 Bytes
fa8b928 | 1 2 3 4 5 6 7 8 9 10 11 12 13 | #!/usr/bin/env python3
"""raw client rows -> predictions.jsonl {id: kbench id with '/', text}. Usage: export_preds.py MANIFEST_JSON... -- RAW_JSONL... -- OUT"""
import json, sys
a = sys.argv[1:]; i = a.index("--"); j = a.index("--", i + 1)
kid = {p["id"]: p["kid"] for m in a[:i] for p in json.load(open(m))["pages"]}
rows = {}
for raw in a[i + 1:j]:
for l in open(raw):
r = json.loads(l); rows[r["id"]] = r
with open(a[j + 1], "w") as f:
for k, r in rows.items(): f.write(json.dumps({"id": kid[k], "text": r["text"], "finish": r["finish"], "error": r["error"]}, ensure_ascii=False) + "\n")
print("exported", len(rows), "of", len(kid))
|