Skip to content

Compare the non-additive R1 format gate against r1_style_format_reward - #1917

Open
shaurya416 wants to merge 3 commits into
allenai:mainfrom
shaurya416:fix-r1-format-gate-non-additive
Open

shaurya416 wants to merge 3 commits into
allenai:mainfrom
shaurya416:fix-r1-format-gate-non-additive

Conversation

@shaurya416

Copy link
Copy Markdown

Fixes #1915

RewardConfig.build() scores a response as raw_score if format_scores[i] == 1 else 0 when apply_r1_style_format_reward is on and additive_format_reward is off. format_scores comes from soft_format_reward_func(decoded_responses, self.r1_style_format_reward), so a matching response scores r1_style_format_reward, not 1. With any value other than 1.0 (for example 0.5), every correctly formatted response had its verifiable reward zeroed.

The gate now compares against self.r1_style_format_reward. With the default of 1.0 the behaviour is unchanged.

Tests

Adds TestRewardConfigNonAdditiveFormatGate to open_instruct/test_ground_truth_utils.py: format reward 1.0 (matching and non-matching, unchanged behaviour), 0.5 (matching and non-matching), 2.0 (matching), and a mixed batch.

  • Run against the extracted text of RewardConfig and its helpers with the verifier call stubbed: 3 of the 6 tests fail on current main (0.5 matching, 2.0 matching, mixed batch) and all 6 pass with this change.
  • ruff check and ruff format --check pass on the two changed Python files.
  • I did not run the full uv run pytest suite locally.

CHANGELOG entry is included. No GPU code path is touched.

GPU_TESTS=bypass

RewardConfig.build() zeroed the verifiable reward of every response whose
format score was not exactly 1, but the format score is r1_style_format_reward
on a match. With any value other than 1.0 (for example 0.5), correctly
formatted responses were scored 0 whenever additive_format_reward is False.

Adds regression tests for default, 0.5 and 2.0 format rewards, matching and
non-matching responses, and a mixed batch.

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

1 participant