Skip to content

reward: RLPR WebInstruct math grader ignores \boxed{...} answers, scoring correct answers 0 #170

Description

@philluiz2323

Bug

_check_rlpr_webinstruct in src/trinity/orchestration/reward.py scores WebInstruct-verified RLPR items. For a math answer it feeds the raw candidate text straight into math_equal / normalize_math_answer (lines 484–487) without first extracting the answer — unlike _check_math, which calls extract_boxed / extract_last_number before comparing.

Since normalize_math_answer does not strip \boxed{...} (or pull an answer out of prose), a correct boxed answer never matches the bare gold value → scored 0.

Reproduce (offline)

from trinity.orchestration import reward as R
ref = {"ground_truth": "15", "source": "WebInstruct-verified-val_Avg2"}
R.score_text("rlpr", r"The area is \boxed{15}.", ref)   # -> 0.0  (should be 1.0)
R.score_text("rlpr", "The answer is 15", ref)           # -> 1.0  (plain number works)
R.score_text("math500", r"The area is \boxed{15}.", "15")  # -> 1.0 (math path extracts the box)

The worker is even instructed by format_hint("rlpr") to "use a boxed final answer for math items", so this is the expected output format — and it's graded wrong.

Impact

Every WebInstruct-verified RLPR math item answered with the requested \boxed{...} format is a false negative, understating accuracy on that benchmark and corrupting the reward signal for those items.

Distinct from

#116 / #122 (RLPR MMLU-Pro choice grading, letters E–J). This is the WebInstruct math path — a different branch and a different fix.

Fix

Extract the answer from the candidate (and gold) before the math compare, mirroring _check_math:

cand_math = extract_boxed(cand) or extract_last_number(cand) or cand
gold_math = extract_boxed(gold) or gold
if math_equal(cand_math, gold_math):
    return True
return normalize_math_answer(cand_math) == normalize_math_answer(gold_math)

Location

src/trinity/orchestration/reward.py, _check_rlpr_webinstruct (~lines 484–487).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions