Skip to main content

Overview

The Rubric class is the foundation for evaluating LLM responses in Verifiers environments. It manages reward functions and their weights, supports both individual and group-level scoring, and integrates with parsers to extract answers from completions.

Constructor

list[RewardFunc | GroupRewardFunc] | None
default:"None"
List of reward functions to evaluate. Can be individual-level (RewardFunc) or group-level (GroupRewardFunc) functions.
list[float] | None
default:"None"
Weights for each reward function. Must match the length of funcs. Defaults to 1.0 for each function if not provided.
vf.Parser | None
default:"None"
Parser instance for extracting answers from completions. Defaults to vf.Parser() if not provided.

Reward Function Signatures

Individual-level RewardFunc

Reward functions that score single rollouts can accept any combination of:
  • prompt: list[dict[str, str]] | str - The input prompt
  • completion: list[dict[str, str]] | str - The model’s completion
  • answer: Any - Ground truth or metadata for scoring
  • task: str - Task type identifier
  • state: State - Full state dictionary
  • info: dict - Additional metadata
  • **kwargs - Additional keyword arguments
Returns: float

Group-level GroupRewardFunc

Reward functions that score multiple rollouts together accept plural parameters:
  • prompts: list[...] - List of prompts
  • completions: list[...] - List of completions
  • answers: list[...] - List of answers
  • tasks: list[str] - List of task types
  • states: list[State] - List of states
  • infos: list[dict] - List of metadata
Returns: list[float]

Methods

add_reward_func

Add a reward function that contributes to the total reward.
RewardFunc
The reward function to add.
float
default:"1.0"
Weight for this function in the total reward calculation.

add_metric

Add a metric function that is tracked but doesn’t contribute to reward (weight = 0).
RewardFunc
The metric function to add.
float
default:"0.0"
Weight for this function (typically 0 for metrics).

add_class_object

Register a class object that will be passed to reward functions as a keyword argument.
str
The parameter name that reward functions can use to access this object.
Any
The object to make available to reward functions.

score_rollout

Evaluate all individual-level reward functions for a single rollout. Updates state["reward"] and state["metrics"] in place.
State
The state dictionary to score. Must contain prompt, completion, and other required fields.
This method requires at least one individual-level reward function and no group-level functions.

score_group

Score multiple rollouts together. Executes all reward functions (both individual and group-level) and updates each state’s reward, advantage, and metrics fields.
list[State]
List of state dictionaries to score together.
Group-level functions see all states at once and can implement comparative scoring strategies.

Attributes

list[RewardFunc | GroupRewardFunc]
List of registered reward functions.
list[float]
Weights corresponding to each function.
vf.Parser
Parser instance for extracting answers.
dict[str, Any]
Dictionary of objects available to reward functions, including the parser.

Example Usage

Group Scoring Example

See Also