(predict: str, answer: str)
| 137 | |
| 138 | @staticmethod |
| 139 | def eval_math(predict: str, answer: str): |
| 140 | pattern = r"\\boxed\{(.*?)\}" |
| 141 | |
| 142 | def _parse(content): |
| 143 | items = re.findall(pattern, content) |
| 144 | return items[-1] if len(items) else content |
| 145 | |
| 146 | if '\\boxed' in predict: |
| 147 | predict = _parse(predict) |
| 148 | if '\\boxed' in answer: |
| 149 | answer = _parse(answer) |
| 150 | |
| 151 | return (predict == answer) * 100 |
| 152 | |
| 153 | @staticmethod |
| 154 | def eval_f1(predict: str, answer: Union[str, List]): |