#859·InternLM

math_equal()'s default include_percentage=True checks every numeric prediction against reference times 100 and reference divided by 100, so answers off by exactly 100x score as correct

Author: shaurya416Created Sep 24, 2026Updated Oct 1, 2026
LabelsStale

agent/streaming_inference.py:373-401, called from math_equal_process (:454-455) with no override, which is what evaluate()'s ProcessPool.map (:599-604) runs for every graded row:

python
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
    ...


def math_equal_process(param):
    return math_equal(param[-2], param[-1])

include_percentage defaults to True and is never scoped by question type anywhere in the calling code — math_equal_process calls math_equal(param[-2], param[-1]) with no third argument, so every row that evaluate() scores runs with gt_result = [reference/100, reference, reference*100].

What happens (reproduced on the real module)

math_equal() in agent/streaming_inference.py defaults include_percentage=True, and math_equal_process() (the function evaluate()'s ProcessPool.map runs for every graded prediction) calls math_equal(param[-2], param[-1]) with no override, so every numeric row is checked against [reference/100, reference, reference*100]. Any prediction that happens to equal the reference off by exactly ×100 or ÷100 (within rel_tol=1e-4) is scored correct. Since extract_answer() runs both the ground truth (line 543) and the model prediction (line 580) through strip_string(), which strips literal %/\% characters (lines 231-233) before either value reaches math_equal, the percentage branch has no legitimate percentage-formatted case to catch on this call path — it exists purely to produce order-of-magnitude false positives. Suggested fix: default include_percentage=False in math_equal, or thread sample['type'] (already available in evaluate(), used later to compute type_scores) through math_equal_process so the ×100/÷100 branch only fires for question types where it's semantically meaningful. Minor citation correction: the math_equal def itself is at line 372 (not 373), and its full try/except numeric-equal block runs through line 406 (not 401); math_equal_process (:454-455) and evaluate()'s pool.map(...) call (:599-604) are cited exactly correctly.

Happy to open the PR.