Skip to main content

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)
Both types use flexible signatures that automatically receive relevant data from the state.

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 setting weight=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

  1. Always include **kwargs for forward compatibility
  2. Return float (not int, bool, etc.) for rewards
  3. Handle None values gracefully
  4. Keep deterministic when possible (for reproducibility)
  5. Document score range in docstring
  6. Use async only when necessary (adds overhead)
  7. Validate inputs at function start

Type Checking

See Also

  • Rubric - Combining multiple reward functions
  • State - Full state dictionary
  • Parser - Extracting answers from completions