File size: 1,455 Bytes
698308b | 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 | """Score a run on browsecomp-plus-mini with normalized exact match (no LLM judge).
predictions.jsonl: one {"query_id": ..., "answer": ...} per line (answer = the agent's final answer text;
if it contains an "Exact Answer:" line, that line is used).
gold.jsonl: the decrypted Tevatron/browsecomp-plus file you produced locally (query_id, query, answer).
usage: python score.py predictions.jsonl gold.jsonl [data/tasks.jsonl] [data/metrics.json]
"""
import sys, json
from grader import grade, extract_answer
pred_path, gold_path = sys.argv[1], sys.argv[2]
tasks = sys.argv[3] if len(sys.argv) > 3 else "data/tasks.jsonl"
metrics = sys.argv[4] if len(sys.argv) > 4 else "data/metrics.json"
ids = [json.loads(l)["query_id"] for l in open(tasks)]
gold = {}
for l in open(gold_path):
r = json.loads(l)
if str(r["query_id"]) in ids:
gold[str(r["query_id"])] = r["answer"]
preds = {str(json.loads(l)["query_id"]): json.loads(l).get("answer") for l in open(pred_path)}
ok = 0
for q in ids:
p = preds.get(q)
a = extract_answer(p) if p else None
c, _ = grade(a, gold[q])
ok += int(c)
print(f"{q}\t{'correct' if c else 'wrong'}") # query ids only; never print question/answer text
m = json.load(open(metrics))["linear_fit_full_from_mini"]
s = ok / len(ids)
print(f"\nmini score: {ok}/{len(ids)} = {100*s:.1f}%")
print(f"estimated full-830 score (normalized match, linear fit): {100*(m['slope']*s + m['intercept']):.1f}%")
|