Download tools/bba_merge.py from RightNowAI/duplex-v0: direct link, hf CLI and curl.
- Browser
- Download file 1.99 kB
-
https://huggingface.co/RightNowAI/duplex-v0/resolve/main/tools/bba_merge.py
- Command line
-
hf download hf://RightNowAI/duplex-v0/tools/bba_merge.py
-
curl -L -o bba_merge.py https://huggingface.co/RightNowAI/duplex-v0/resolve/main/tools/bba_merge.py
1.99 kB
| """Summary of a benchmark arm from its per-question files (used when an arm was split over several baseline copies). | |
| python -m tools.bba_merge eval/results/bba2/judge_v1/judge | |
| """ | |
| import json | |
| import sys | |
| from collections import defaultdict | |
| from pathlib import Path | |
| from duplex.spec import write_json | |
| from eval.ws_client import percentiles | |
| d = Path(sys.argv[1]) | |
| rows = [json.loads(p.read_text(encoding="utf-8")) for p in sorted(d.glob("q_*.json"))] | |
| by_cat = defaultdict(list) | |
| for r in rows: | |
| by_cat[r["category"]].append(r["correct"]) | |
| done = [[e for e in r["events"] if e["type"] == "reply.done"] for r in rows] | |
| summary = { | |
| "questions": len(rows), "accuracy": sum(r["correct"] for r in rows) / len(rows), | |
| "accuracy_by_category": {c: sum(v) / len(v) for c, v in sorted(by_cat.items())}, | |
| "replied": sum(r["replied"] for r in rows), "no_answer_found": sum(r["answer"] is None for r in rows), | |
| "errors": sum(bool(r["error"]) for r in rows), | |
| # audible: the caller heard part of a reply that was then cut off because the question went on | |
| "replies_cut_off_after_being_heard": sum(r["replies_cut_off"] for r in rows), | |
| "questions_with_a_reply_cut_off": sum(r["replies_cut_off"] > 0 for r in rows), | |
| "replies_withdrawn_unheard": sum(sum(1 for e in r["events"] if e["type"] == "reply.withdrawn") for r in rows), | |
| "latency_ms": percentiles([r["latency_ms"] for r in rows if r["replied"]]), | |
| "thought_ms": percentiles([x[-1].get("thought_ms") for x in done if x]), | |
| # third run (serving/listen_think.py): reasoning requests made while the caller spoke, and what the last reply began with | |
| "listen_requests": sum(sum(1 for e in r["events"] if e.get("label") == "LISTEN") for r in rows), | |
| "carried_chars": percentiles([x[-1].get("carried_chars") for x in done if x]), | |
| "replies_that_needed_no_reasoning": sum(1 for x in done if x and x[-1].get("thought_ready")), | |
| } | |
| write_json(d.parent / "summary_merged.json", summary) | |
| print(json.dumps(summary)) | |