Verify if the model's answer matches the ground truth using math-verify. Args: model_response: The full model response text. ground_truth: The ground truth answer (string of an integer for AIME). Returns: True if the answer is correct, False otherwise.
(model_response: str, ground_truth: str)
| 74 | |
| 75 | |
| 76 | def verify_answer(model_response: str, ground_truth: str) -> bool: |
| 77 | """Verify if the model's answer matches the ground truth using math-verify. |
| 78 | |
| 79 | Args: |
| 80 | model_response: The full model response text. |
| 81 | ground_truth: The ground truth answer (string of an integer for AIME). |
| 82 | |
| 83 | Returns: |
| 84 | True if the answer is correct, False otherwise. |
| 85 | """ |
| 86 | gt_normalized = _normalize_ground_truth(ground_truth) |
| 87 | |
| 88 | try: |
| 89 | gold = parse(gt_normalized) |
| 90 | pred = parse(model_response) |
| 91 | if gold and pred: |
| 92 | return verify(gold, pred) |
| 93 | except Exception: |
| 94 | pass |
| 95 | |
| 96 | # Fallback: exact string match on extracted boxed answer |
| 97 | parsed = _extract_boxed(model_response) |
| 98 | if parsed: |
| 99 | # AIME answers are integers; normalize by stripping leading zeros |
| 100 | try: |
| 101 | return int(parsed[-1].strip()) == int(gt_normalized.strip()) |
| 102 | except (ValueError, TypeError): |
| 103 | pass |
| 104 | |
| 105 | return False |
| 106 | |
| 107 | |
| 108 | def evaluate( |
no test coverage detected