Skip to content

fix(math_with_judge): verify only the final boxed answer - #5919

Open
ankit373 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
ankit373:fix/math-with-judge-last-boxed
Open

ankit373 wants to merge 1 commit into
NVIDIA-NeMo:mainfrom
ankit373:fix/math-with-judge-last-boxed

Conversation

@ankit373

Copy link
Copy Markdown

What does this PR do?

Fixes #4514. Also tracked in the NVBugs queue #4482 (NVBug 6899737).

_verify_answer already pulls out the last complete \boxed{} for the no-answer guard and the judge, but it still passed the whole response to math-verify. math-verify keeps earlier boxes that sit close to the final one and scores them as a set, so \boxed{5} then \boxed{-3} with gold -3 came back as {-3, 5} with reward 0. Multi-message agents hit this because verify() joins messages with "", and a single message that corrects itself can hit it too.

Now the library gets only \boxed{<last box>}, so math-verify, the guard and the judge all look at the same answer. The unboxed fallback under format_tolerant_answer_extraction is unchanged; it already passes only the selected span.

Other servers that override _verify_answer still send the full text to math-verify and likely have the same issue: physics_judge, math_with_autograder and ugphysics_judge (ugphysics_judge also joins messages with ""). I left them alone to keep this focused, since physics_judge and ugphysics_judge say they mirror the Skills pipeline. Happy to follow up if you want them aligned. polymath calls super().verify() and picks up the fix.

Validation

  • new test_verify_grades_only_final_boxed_answer, run through verify() with the real math-verify (no mocks), gold -3:
    • \boxed{5} then \boxed{-3} in two messages: 1.0 (was 0.0)
    • \boxed{-3} then \boxed{5}: 0.0, extracted 5 (was {-3, 5})
    • one message self-correction First \boxed{5}. Wait, that is wrong: \boxed{-3}: 1.0 (was 0.0)
    • ReWOO-shaped three messages, single box, no box: same as before
  • the three changed cases fail on main and pass with the fix
  • updated the test_verify_answer mock assertion, which now expects the boxed answer instead of the full text
  • pytest resources_servers/math_with_judge/tests: 140 passed
  • pytest resources_servers/polymath/tests: 10 passed
  • pre-commit run --files on the two changed files: passed

Rollouts

N/A. Verifier-only change; the tests run the production math-verify path on fixed inputs, so no model is needed to show the reward change.

Compatibility and benchmark impact

Rewards can change both ways for responses with more than one \boxed{}. A correct final box after a different earlier one now scores 1. A response that puts parts of one answer in separate boxes (for example \boxed{3}, \boxed{4} for gold 3,4) is now graded on the last box only and drops to 0. That matches how the judge path already reads the answer. Single-box and no-box responses are unchanged.

Suggested labels: bug, area:environment.

Checklist

  • I have read the contributing guidelines.
  • The change is focused; unrelated "drive-by" edits are tracked as separate issues/PRs.
  • Tests added or updated and pass locally, or N/A for docs-only / non-code changes (so CI unit/server checks pass when applicable).
  • Documentation added or updated, or N/A with justification. N/A, no documented behavior changes.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass). Ran on the changed files.
  • New source files include the required Apache-2.0 SPDX header. N/A, no new files.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

math-verify scores earlier \boxed{} spans near the final one as a set, so a
correct final box after a different earlier box got reward 0. Pass only the
last complete box to the library, same answer the no-answer guard and the
judge already use.

Fixes NVIDIA-NeMo#4514

Signed-off-by: Ankit Jha <[email protected]>
@copy-pr-bot

copy-pr-bot Bot commented Nov 10, 2026

Copy link
Copy Markdown

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@nemo-automation-bot nemo-automation-bot Bot added the community-request Issue reported or requested by someone from the community label Nov 10, 2026
@github-actions github-actions Bot added the sla:triage-overdue Review assignment is over the one-business-day SLA label Nov 11, 2026
@svcnvidia-nemo-ci svcnvidia-nemo-ci added waiting-on-maintainers Waiting on maintainers to respond bug Something isn't working area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers labels Nov 12, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers bug Something isn't working community-request Issue reported or requested by someone from the community sla:triage-overdue Review assignment is over the one-business-day SLA waiting-on-maintainers Waiting on maintainers to respond

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[NVBug 6899737] Score only the final boxed answer in math_with_judge verify

2 participants