Skip to content

feat(generative_reward_model): add GenRM training resources server - #3635

Merged
cmunley1 merged 3 commits into
mainfrom
jiaqiz/genrm-training-env
Sep 23, 2026
Merged

cmunley1 merged 3 commits into
mainfrom
jiaqiz/genrm-training-env

Conversation

@HeyyyyyyG

Copy link
Copy Markdown
Contributor

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.

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

  • 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.
  • Pre-commit checks pass locally (pre-commit run --all-files) (so CI lint/format checks pass).
  • New source files include the required Apache-2.0 SPDX header.
  • All commits have DCO sign-off (git commit -s) (so the DCO check passes).

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
HeyyyyyyG force-pushed the jiaqiz/genrm-training-env branch from e47294d to 00018d7 Compare September 22, 2026 23:23
@yaoyu-33 yaoyu-33 added area:environment Individual environments, benchmarks, verifiers, and environment-specific resources servers complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer labels Sep 22, 2026
HeyyyyyyG and others added 2 commits September 23, 2026 05:52
… 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
cmunley1 added this pull request to the merge queue Sep 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔄 Merge queue validation started! You can track the progress here: https://github.com/NVIDIA-NeMo/Gym/actions/runs/35893540551

Merged via the queue into main with commit 4101fa5 Sep 23, 2026
34 checks passed
@cmunley1
cmunley1 deleted the jiaqiz/genrm-training-env branch September 23, 2026 17:17

This branch was previously deployed

1 inactive deployment
public — 70fd81cd Deployed Sep 23, 2026 by copy-pr-bot[bot] via release / finalize / notify #3545
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 complexity:medium Single-domain change with interacting parts or a moderate review surface feature New capabilities, enhancements, or enablement work needs-review PR is ready for code review and waiting on a reviewer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants