1"""Public long-document QA (LongBench v1 subsets). Raw jsonl obtained from the HF dataset repo THUDM/LongBench (data.zip)."""2from __future__ import annotations3import json, hashlib4from pathlib import Path5from ..util import ROOT, sha256_text67RAW = ROOT / "data" / "raw" / "longbench" / "data"8SUBSETS = {"qasper": "F1", "2wikimqa": "F1", "hotpotqa": "F1", "musique": "F1", "multifieldqa_en": "F1"}910def load_subset(name: str) -> list[dict]:11 rows = [json.loads(l) for l in open(RAW / f"{name}.jsonl", encoding="utf-8")]12 out = []13 for r in rows:14 out.append({"document_id": f"lb_{name}_{r['_id']}", "subset": name, "text": r["context"], "char_len": len(r["context"]),15 "document_hash": sha256_text(r["context"]),16 "questions": [{"question_id": "q00", "qtype": name, "question": r["input"], "answer": r["answers"][0], "aliases": r["answers"][1:],17 "answer_type": "qa_f1", "tolerance": 0.0, "supporting_fact_ids": [], "answer_position_frac": -1.0}],18 "facts": [], "length_words": r["length"]})19 return out20