| """Validate the two metrics against known-correct answers before spending GPU time. |
| |
| A scorer that silently returns 0 for a correct answer would make every claim |
| look refuted. Feed each metric its own gold answer and require ~100%. |
| """ |
| import sys, os |
| sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) |
| import json |
| from run_eval import load_trip, load_humaneval, score_trip, score_humaneval |
|
|
| ok = True |
|
|
| |
| items, _ = load_trip(limit=40, num_cities=None) |
| gold_responses = [i["golden_plan"] for i in items] |
| score, per = score_trip(items, gold_responses) |
| print(f"Trip gold-plan score: {score:.1f}% ({int(sum(per))}/{len(per)})") |
| if score < 95: |
| print(" FAIL: trip metric does not score its own gold plans"); ok = False |
|
|
| |
| |
| |
| docs = load_humaneval(limit=20) |
| resps = [d["canonical_solution"] + "```" for d in docs] |
| score, per = score_humaneval(docs, resps) |
| print(f"HumanEval canonical score: {score:.1f}% ({int(sum(per))}/{len(per)})") |
| if score < 95: |
| print(" FAIL: humaneval metric does not score its own canonical solutions") |
| for d, p in zip(docs, per): |
| if p == 0: |
| print(" first failing task:", d["task_id"]); break |
| ok = False |
|
|
| |
| bad = [" return None\n```" for d in docs] |
| score_bad, _ = score_humaneval(docs, bad) |
| print(f"HumanEval wrong-answer score: {score_bad:.1f}% (expect ~0)") |
| if score_bad > 5: |
| print(" FAIL: humaneval metric passes wrong answers"); ok = False |
|
|
| print("\nSCORER TEST:", "PASS" if ok else "FAIL") |
| sys.exit(0 if ok else 1) |
|
|