Skip to content

fix(rm_hub): accept numeric zero ground truth in grade_answer_verl - #2486

Open
Domin-Focus wants to merge 1 commit into
THUDM:mainfrom
Domin-Focus:fix/math-zero-label
Open

Domin-Focus wants to merge 1 commit into
THUDM:mainfrom
Domin-Focus:fix/math-zero-label

Conversation

@Domin-Focus

@Domin-Focus Domin-Focus commented Oct 20, 2026 •

Copy link
Copy Markdown

Problem

grade_answer_verl (slime/rollout/rm_hub/math_utils.py:485) starts with:

if not ground_truth:
    return False
ground_truth = str(ground_truth)

Labels are passed through from the dataset as-is (slime/utils/data.py:272), so a zero answer arrives as 0 or 0.0. Both are falsy, so the guard treats them as a missing label, and every correct \boxed{0} response scores 0 under rm_type=math. Under GRPO, a group where every sample gets 0 gives no learning signal for that prompt.

#336 added str(ground_truth) so this function would accept non-string labels, but the falsy guard runs before that conversion.

Reproduction:

from slime.rollout.rm_hub.math_utils import grade_answer_verl
grade_answer_verl(r"\boxed{0}", 0)    # False (expected True)
grade_answer_verl(r"\boxed{0}", 0.0)  # False (expected True)
grade_answer_verl(r"\boxed{0}", "0")  # True

deepscaler (label == "") and gpqa already handle numeric zero correctly. Only math is affected.

Fix

Only reject a missing label:

if ground_truth is None or ground_truth == "":
    return False

Behavior is unchanged for every other input, including "", None and whitespace-only labels.

Tests

tests/test_rm_math.py:

  • test_grade_answer_verl_accepts_numeric_zero_ground_truth[0, 0.0]: fails before this change, passes after.
  • test_grade_answer_verl_rejects_wrong_answer_for_zero_ground_truth: \boxed{1} vs 0 is still rejected.
  • test_grade_answer_verl_returns_false_on_missing_ground_truth["", None]: the existing empty-label test, extended to None.

python tests/test_rm_math.py: 36 passed. pre-commit run: passed.

Note: #2150 edits a line two below this one in grade_answer_verl (\fbox support). The two changes don't conflict logically. I'll rebase if that one lands first.

Labels are passed through from the dataset as-is, so a zero answer
arrives as 0 / 0.0. The `if not ground_truth` guard treated these as a
missing label, so every correct \boxed{0} response scored 0 under
rm_type=math. THUDM#336 added str(ground_truth) to support non-string labels,
but the falsy guard runs before that conversion.

Only reject None and "", and add tests for numeric zero labels.

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant