Repository navigation
Description
Background
Verifiers are the core of every NeMo Gym environment — they define what counts as a correct agent response and produce the reward signal used for both evaluation and RL training. Despite this central role, there is no single tutorial that walks a user through the full verifier design lifecycle. Related gaps:
- Guidance on verification patterns missing from creating environments documentation #608 notes that verification patterns are only documented in the concepts section and aren't surfaced in the environment creation tutorial.
- docs: multi-reward verification #1661 covers the multi-reward pattern specifically but does not cover the full authoring progression.
- epic: iterative verifier design #1499 (epic) tracks the broader iterative verifier design workflow — re-scoring without re-running the policy, config-driven tuning, and A/B comparison on identical rollout sets. This tutorial should surface the iteration patterns that epic enables.
- [epic] Typed verifiers: standalone primitives outside the resources server #1482
This ticket proposes a standalone tutorial page that takes a user from a minimal verifier to a production-ready one, and shows how to iterate on it efficiently.
Proposed tutorial outline
1. The verifier contract
Explain the three moving parts every verifier must implement, grounded in nemo_gym/base_resources_server.py:
seed_session— populates the session with the ground-truth data the agent will needverify— receives the agent's full trajectory and returns aBaseVerifyResponsewith a scalarrewardaggregate_metrics— inherited fromAggregateMetricsMixin; profiles every numeric field in verify responses across a rollout batch
Minimal skeleton:
from nemo_gym.base_resources_server import (
BaseResourcesServerConfig, BaseVerifyRequest, BaseVerifyResponse, SimpleResourcesServer
)
class MyVerifyRequest(BaseVerifyRequest):
expected_answer: str
class MyServer(SimpleResourcesServer):
async def verify(self, body: MyVerifyRequest) -> BaseVerifyResponse:
correct = body.messages[-1].content.strip() == body.expected_answer
return BaseVerifyResponse(**body.model_dump(), reward=1.0 if correct else 0.0)2. Rule-based verifiers
Walk through resources_servers/equivalence_rule/app.py as the canonical example. Cover:
- Selecting a grading rule via config (
GradingRuleenum) - Exact match vs. fuzzy match (
SequenceMatcher) - When rule-based is appropriate (deterministic outputs, structured answers)
3. Library-based verifiers
Walk through resources_servers/math_with_judge/app.py — using math_verify as a symbolic grader before falling back to an LLM judge. Cover:
- Calling an external grading library
- Handling timeouts and concurrency (
library_verifier_timeout_seconds,library_verifier_max_concurrency) - Chaining a library check with an LLM fallback
4. LLM-as-judge verifiers
Cover the pattern where no deterministic rule exists and a judge model scores the response. Cover:
- Constructing a judge prompt
- Calling the judge via
nemo_gym.openai_utils - Normalizing the judge score to
[0, 1] - Cost and latency trade-offs vs. rule-based
5. Multi-reward verifiers
Walk through resources_servers/example_tool_call_multireward/app.py. Cover:
- Adding
reward_components: Dict[str, float]to the verify response - How
aggregate_metricsautomatically profiles each component (correctness,format,schema_valid) independently - Evaluation use case: reward profiling to diagnose how an agent fails, not just whether it fails
- RL use case: exposing components as
reward1,reward2, ... for GDPO (cross-reference docs: multi-reward verification #1661)
6. Testing your verifier locally
Show how to use ng_test against a resource server before wiring it into a full benchmark run:
ng_test +entrypoint=resources_servers/my_server7. Iterating without re-running the policy
Surfaces the patterns from #1499:
- Tuning reward weights, thresholds, and judge prompts via YAML config overrides without creating a new server implementation
- Re-scoring stored rollouts when only the scoring function changed — avoiding re-invoking the policy model
- A/B comparing two verifier variants on the same rollout set for fair calibration
- When full re-rollout is unavoidable vs. when config overrides or offline re-scoring are sufficient
Acceptance criteria
- Tutorial page published to the docs site under a Build Verifiers section
- Covers all four verifier patterns: rule-based, library-based, LLM-judge, multi-reward
- Each pattern references its canonical in-tree example with a direct link
- Local testing with
ng_testis covered - Iteration workflow (section 7) documented, cross-referencing epic: iterative verifier design #1499
- Row added to the Environment Tutorials table in
README.md - Cross-references Guidance on verification patterns missing from creating environments documentation #608, docs: multi-reward verification #1661, and epic: iterative verifier design #1499
Reference implementations in-tree
| Pattern | Resource server |
|---|---|
| Minimal / rule-based | resources_servers/equivalence_rule/ |
| Library + LLM judge | resources_servers/math_with_judge/ |
| Multi-reward | resources_servers/example_tool_call_multireward/ |
| Simple baseline | resources_servers/example_single_tool_call/ |
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDev Todo
Activity
[-]Tutorial: How to build and design verifiers[/-][+]Tutorial: How to build and design verifiers with a new agent skill in Gym[/+]