File size: 1,985 Bytes
f730521
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""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))