Repository navigation
feat(generative_reward_model): add GenRM training resources server - #3635
Merged
Merged
Conversation
HeyyyyyyG
force-pushed
the
jiaqiz/genrm-training-env
branch
from
September 22, 2026 22:38
362da02 to
e47294d
Compare
Adds a resources server for RL-training a Generative Reward Model. The
policy under training acts as the judge: given conversation context and
two candidate responses it emits per-rubric and overall scores plus a
relative ranking, and the server rewards that verdict against human
ground truth.
Reward is the negative L1 penalty against ground truth, so 0.0 is the
best achievable reward:
overall_penalty = score_weight * (|s1_err| + |s2_err|)
+ ranking_weight * |rank_err|
rubric_penalty = rubric_weight * mean_over_rubrics(same form)
reward = -(overall_penalty + rubric_penalty)
Only ground-truth fields that are actually present are penalized, so a
sample carrying just `ranking` contributes only the ranking term.
The parser requires exactly one JSON dict in the model output. Accepting
the first of several would let a degenerate policy repeat its verdict
block for free, which RL then reinforces; this collapsed a training run
at roughly step 600, where entropy fell and generations looped the
verdict JSON until hitting the token cap while reward never moved.
Verify also reports per-sample metrics for logging: format_correct, the
overall and per-rubric L1 errors, and ranking binary accuracy.
task_data.py describes the dataset rows. Required-ness mirrors the wire
contract in app.py rather than what verify() reads: `id` is required,
both ground-truth fields default to None, and the scores and rankings
inside them are optional since verify() reaches them with .get(). The
exception is `rubric_id`, which is indexed directly when matching
predicted rubrics to ground truth.
Example data is five samples spanning the ranking scale in both
directions (overall rankings 1, 2, 3, 5, 6) across one, two, three and
five rubrics; example_metrics.json is generated by `gym dataset collate`
in example_validation mode.
This is the training counterpart to resources_servers/genrm_compare,
which uses an already-trained GenRM to score candidates during RLHF.
Co-Authored-By: Claude Opus 5 <[email protected]>
Signed-off-by: Jiaqi Zeng <[email protected]>
HeyyyyyyG
force-pushed
the
jiaqiz/genrm-training-env
branch
from
September 22, 2026 23:23
e47294d to
00018d7
Compare
… IDs Two defects in the per-rubric reward, both found by review. 1. Perfectly predicted rubrics were dropped from the mean. The penalty list was appended to only `if penalty > 0`, so the divisor counted imperfect rubrics rather than all of them. The rubric term was therefore flat: with five rubrics and one wrong by 4, the reward was -4.00, exactly what five wrong rubrics scored. The policy got no credit for the four it answered correctly. Worse, it was non-monotonic. With penalties [8, 2] the mean was 5.0; fixing the second rubric left [8] and a mean of 8.0, so improving an answer lowered the reward. Appending on whether the rubric carried any ground truth restores the documented mean_over_rubrics in genrm_train.yaml and the README: one wrong of five is now -0.80 and the reward decreases strictly with the number of wrong rubrics. 2. Duplicate rubric IDs bypassed the match check. `pred_by_id` collapses repeats, so comparing its length against the ground-truth count let a verdict answering one rubric twice through, scoring only the last copy. A wrong answer followed by a duplicate correct one scored 0.00 where an honest single wrong answer scored -4.00. The count now comes from the raw parsed list, so repeats are a parse failure, consistent with the parser rejecting a repeated verdict block. Both paths were untested: no case mixed perfect and imperfect rubrics, and none repeated an ID. The four tests added here fail on the previous implementation and pass on this one. Note for anyone mid-training: this changes the reward on multi-rubric samples, which is roughly half of a typical blend. Single-rubric samples are unaffected, and a perfect verdict still scores exactly 0.0. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]>
The repo's data validation (nemo_gym/cli/env.py, run per changed server in CI with +should_validate_data=true) requires data/example_rollouts.jsonl with exactly one rollout per example row. 131 of the other 132 resources servers ship one; this server was the gap, so the changed-server step failed even with unit tests green. Each row is the full verify() response for its example: the judge verdict the policy would emit, then the reward, format_correct, the overall and per-rubric L1 errors and ranking binary accuracy. Only the verdict text is authored -- every reward and metric in the file is computed by running the row through the server's own verify(), so the numbers stay correct by construction rather than being transcribed by hand. Re-verifying each committed row reproduces its stored reward exactly. The five verdicts are deliberately not all perfect, so the fixture covers the reward surface rather than just its zero point: row 0 is flawless (reward 0.0), rows 1-3 miss the overall or a rubric ranking, and row 4 mixes one perfect rubric with one wrong to cover the mean-over-all-rubrics path. id/dataset/agent_ref are written back onto each row because the verify response model does not declare them and pydantic drops them, which would otherwise leave the rollouts untraceable to their source rows. data/.gitignore needed the file un-ignored: its `*.jsonl` rule re-admitted only example.jsonl, so the rollouts would have been silently skipped by git add while still being demanded by CI. train.jsonl stays ignored. Co-Authored-By: Claude Opus 5 <[email protected]> Signed-off-by: Jiaqi Zeng <[email protected]>
cmunley1
approved these changes
Sep 23, 2026
Contributor
|
🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/35893540551 |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds a resources server for RL-training a Generative Reward Model. The policy under training acts as the judge: given conversation context and two candidate responses it emits per-rubric and overall scores plus a relative ranking, and the server rewards that verdict against human ground truth.
Reward is the negative L1 penalty against ground truth, so 0.0 is the best achievable reward:
overall_penalty = score_weight * (|s1_err| + |s2_err|)
+ ranking_weight * |rank_err|
rubric_penalty = rubric_weight * mean_over_rubrics(same form)
reward = -(overall_penalty + rubric_penalty)
Only ground-truth fields that are actually present are penalized, so a sample carrying just
rankingcontributes only the ranking term.The parser requires exactly one JSON dict in the model output. Accepting the first of several would let a degenerate policy repeat its verdict block for free, which RL then reinforces; this collapsed a training run at roughly step 600, where entropy fell and generations looped the verdict JSON until hitting the token cap while reward never moved.
Verify also reports per-sample metrics for logging: format_correct, the overall and per-rubric L1 errors, and ranking binary accuracy.
This is the training counterpart to resources_servers/genrm_compare, which uses an already-trained GenRM to score candidates during RLHF.
What does this PR do?
Validation
Rollouts
Compatibility and benchmark impact
Checklist
pre-commit run --all-files) (so CI lint/format checks pass).git commit -s) (so the DCO check passes).