Reward Functions
Reward functions score model outputs and are the core evaluation mechanism in Verifiers.Overview
Reward functions come in two flavors:- Individual: Score single rollouts (most common)
- Group: Score multiple rollouts together (for comparative evaluation)
Type Definitions
Individual Reward Functions
Functions that score a single rollout at a time.Signature
Available Parameters
Messages | str
The input prompt (from state[“prompt”]).
Messages | str
The model’s final completion (from state[“completion”]).
Any
Ground truth answer from dataset (from state[“answer”]).
str
Task identifier (from state[“task”]).
State
Full state dictionary with trajectory, timing, etc.
dict
Additional metadata from dataset (from state[“info”]).
Catches class objects and extra fields. Always include for forward compatibility.
Examples
Simple Exact Match
Using Parser
State-based
Async Reward
Group Reward Functions
Functions that score multiple rollouts together, enabling comparative evaluation.Signature
Examples
Relative Ranking
Best-of-N
Majority Voting
Metrics vs Rewards
Reward functions can be used as metrics (tracked but not contributing to reward) by settingweight=0:
Async Support
Both individual and group functions can be async:Class Objects
Register objects that reward functions can access:Debugging Rewards
Print intermediate values:Common Patterns
Multi-criteria Scoring
Partial Credit
Error Handling
Best Practices
- Always include
**kwargsfor forward compatibility - Return float (not int, bool, etc.) for rewards
- Handle None values gracefully
- Keep deterministic when possible (for reproducibility)
- Document score range in docstring
- Use async only when necessary (adds overhead)
- Validate inputs at function start