math_equal() 的默认参数 include_percentage=True 会将每个数值预测与参考值 100 和参考值除以 100 进行比较,因此答案与正确答案的分数相差 100 倍。
作者: shaurya416创建于 2026年9月24日更新于 2026年10月1日
标签Stale
agent/streaming_inference.py:373-401, 从 math_equal_process (:454-455) 调用,没有覆盖,这就是 evaluate() 的 ProcessPool.map (:599-604) 为每个分数行运行的内容:
def math_equal(
prediction: Union[bool, float, str],
reference: Union[float, str],
include_percentage: bool = True,
is_close: bool = True,
tolerance: float = 1e-4,
timeout: bool = False,
) -> bool:
try: # 1. numerical equal
if is_digit(prediction) and is_digit(reference):
prediction = float(str(prediction).replace(',', ''))
reference = float(str(reference).replace(',', ''))
# number questions
if include_percentage:
gt_result = [reference / 100, reference, reference * 100]
else:
gt_result = [reference]
for item in gt_result:
try:
if is_close:
if isclose(item, prediction, rel_tol=tolerance):
return True
else:
if item == prediction:
return True
except Exception:
continue
return False
except Exception:
pass
...内容来源: InternLM/InternLM