Download analysis/code/load.py from mverde73/mnemonic-proxy-agentlongbench: direct link, hf CLI and curl.
- Browser
- Download file 2.84 kB
-
https://huggingface.co/datasets/mverde73/mnemonic-proxy-agentlongbench/resolve/main/analysis/code/load.py
- Command line
-
hf download hf://datasets/mverde73/mnemonic-proxy-agentlongbench/analysis/code/load.py
-
curl -L -o load.py https://huggingface.co/datasets/mverde73/mnemonic-proxy-agentlongbench/resolve/main/analysis/code/load.py
2.84 kB
| """Caricamento dei risultati della corsa principale (solo lettura dei file copiati da PC4070TI).""" | |
| import json | |
| from pathlib import Path | |
| ROOT = Path(__file__).resolve().parents[1] # out/main-run-confirm | |
| RUNS = ROOT / "runs" | |
| PREFIX = "main-clar-" # corsa di conferma | |
| MAIN_RUNS = ROOT.parent / "main-run" / "runs" # corsa principale (confronto) | |
| LENGTHS = ["64k", "128k"] | |
| POLS = ["A", "D", "B", "T"] | |
| DEV_QID = "38_i13_j22_a_0031" | |
| DATA = ROOT.parents[1] / "alb-bench-v2" / "alb" / "data" / "benchmark" / "kf-c" | |
| def qtype_short(qt): | |
| return "CF" if qt.startswith("Count Frequency") else ("FD" if qt.startswith("Find Duplicates") else qt) | |
| def load_results(runs=None, prefix=None): | |
| """Una riga per (lunghezza, politica, qid), dai result.json (non da results.jsonl).""" | |
| runs = runs or RUNS | |
| prefix = prefix or PREFIX | |
| rows = [] | |
| for L in LENGTHS: | |
| for pol in POLS: | |
| for d in sorted((runs / (prefix + L) / pol / "kf-c" / L).iterdir()): | |
| r = json.loads((d / "result.json").read_text()) | |
| rows.append({ | |
| "L": L, "pol": pol, "qid": r["qid"], "dir": str(d), | |
| "sample_id": int(r["qid"].split("_")[0]), | |
| "qt": qtype_short(r["question_type"]), | |
| "status": r["status"], | |
| "off": float(r["score_official"] or 0), "norm": float(r["score_format_norm"] or 0), | |
| "full": int(r["fully_correct"] or 0), | |
| "empty": bool(r["answer_empty"]), "trunc": bool(r["answer_truncated"]), | |
| "resid": bool(r["answer_residual_calls"]), "invalid": bool(r["answer_invalid_format"]), | |
| "error": bool(r["answer_error"]), | |
| "wall_s": r["wall_s"], "window": r["window"], "gold": r["gold"], | |
| "pred": r.get("pred_answer"), "raw": r.get("raw_response"), | |
| "finish": r.get("finish_reason"), | |
| "engine": r.get("engine") or {}, "final_call": r.get("final_call") or {}, | |
| "margin_viol": (r.get("engine") or {}).get("margin_violations"), | |
| }) | |
| return rows | |
| def load_engine_calls(d): | |
| return [json.loads(l) for l in open(Path(d) / "engine_calls.jsonl")] | |
| def load_resources(d): | |
| out = [] | |
| for l in open(Path(d) / "resources.jsonl"): | |
| try: | |
| out.append(json.loads(l)) | |
| except ValueError: | |
| pass | |
| return out | |
| def samples(L, qt): | |
| f = DATA / L / "tool_response" / ("count_frequency_tool.jsonl" if qt == "CF" else "find_duplicates_tool.jsonl") | |
| out = {} | |
| for l in open(f): | |
| x = json.loads(l) | |
| out[x["id"]] = x | |
| return out | |
| def load_main(): | |
| """Corsa principale (domanda ambigua), per il confronto affiancato.""" | |
| return load_results(MAIN_RUNS, "main-") | |