llm-serving-bench / build_dataset.py
Francesco's picture
ingine bench v3
9bd0d59 verified
Raw History Blame Contribute Delete
1.61 kB
# [Agent] Builds the three prompt files of Francesco/ingine-bench from the pinned public sources in data/.
import json
from pathlib import Path
import pyarrow.parquet as pq
D, OUT = Path("data"), Path("ds")
by_cat = {}
for line in open(D / "spec_bench_question.jsonl"):
q = json.loads(line)
# [Agent] Spec-Bench has 6 tasks; its 8 MT-Bench categories (ids 81-160) are one task, so "the first 10" of it are the writing questions.
task = "mt_bench" if q["question_id"] <= 160 else q["category"]
by_cat.setdefault(task, [])
if len(by_cat[task]) < 10:
by_cat[task].append(q)
with open(OUT / "short.jsonl", "w") as f:
for cat, qs in by_cat.items():
for q in qs:
f.write(json.dumps({"id": f"spec-bench/{q['question_id']}", "category": cat, "prompt": q["turns"][0], "max_tokens": 256}) + "\n")
with open(OUT / "code.jsonl", "w") as f:
for h in pq.read_table(D / "humaneval.parquet").to_pylist()[:20]:
f.write(json.dumps({"id": h["task_id"], "category": "code (HumanEval)", "max_tokens": 384,
"prompt": f"Complete this Python function. Reply with code only.\n\n```python\n{h['prompt']}```"}) + "\n")
s = next(x for x in json.load(open(D / "longbench_v2.json")) if x["_id"].startswith("66fa208bbb02"))
with open(OUT / "long.jsonl", "w") as f:
f.write(json.dumps({"id": "longbench-v2/" + s["_id"], "domain": s["domain"], "question": s["question"],
"choices": {k: s["choice_" + k] for k in "ABCD"}, "answer": s["answer"], "context": s["context"],
"max_tokens": 256}) + "\n")