Skip to main content

Overview

RubricGroup is a class for combining multiple Rubric instances into a single rubric. It aggregates reward functions and metrics from all child rubrics, allowing you to compose complex evaluation strategies from simpler components.

Class Signature

Parameters

list[Rubric]
required
List of rubric instances to aggregate. Must contain at least one rubric, otherwise a ValueError is raised.
Any
Additional keyword arguments passed to the parent Rubric class.

Attributes

list[Rubric]
The list of child rubrics being aggregated.

Methods

add_reward_func

Adds a reward function to the first rubric in the group.
RewardFunc
required
The reward function to add. Should accept parameters like completion, answer, prompt, etc.
float
default:"1.0"
The weight to apply to this reward function when calculating the total reward.
This method adds the reward function to the first rubric only, not all rubrics. A warning is logged when this method is called.

add_metric

Adds a metric (zero-weight reward function) to the first rubric in the group.
RewardFunc
required
The metric function to add. Should accept parameters like completion, answer, prompt, etc.
float
default:"0.0"
The weight for this metric (typically 0.0 for tracking purposes only).
This method adds the metric to the first rubric only. A warning is logged when this method is called.

add_class_object

Adds a class object (like a parser) to the first rubric in the group.
str
required
The name to use when referencing this object in reward functions.
Any
required
The object to add (e.g., a parser, validator, or other helper class).
This method adds the object to the first rubric only. A warning is logged when this method is called.

score_rollout

Evaluates all reward functions for a single rollout.
State
required
The rollout state to score. This is modified in-place with aggregated rewards and metrics.
Behavior:
  1. Iterates through each child rubric
  2. Calls score_rollout on each rubric
  3. Aggregates rewards (summed across rubrics)
  4. Aggregates metrics (summed across rubrics)
  5. Updates the state with total reward and combined metrics
State Modifications:
  • state["reward"]: Set to the sum of all rubric rewards
  • state["metrics"]: Set to the combined metrics from all rubrics

score_group

Evaluates all reward functions for a group of rollouts.
list[State]
required
List of rollout states to score. Each state is modified in-place with aggregated rewards and metrics.
Behavior:
  1. Iterates through each child rubric
  2. Calls score_group on each rubric
  3. Aggregates rewards across all rubrics for each state
  4. Aggregates metrics across all rubrics for each state
  5. Updates each state with total reward and combined metrics

Internal Methods

These methods aggregate information from child rubrics:
  • _get_reward_func_names(): Returns all reward function names from all rubrics
  • _get_reward_funcs(): Returns all reward functions from all rubrics
  • _get_reward_weights(): Returns all reward weights from all rubrics

Usage Examples

Basic Usage

Combining Domain-Specific Rubrics

Scoring a Single Rollout

Scoring Multiple Rollouts

Adding Reward Functions

Reward and Metric Aggregation

How Rewards are Aggregated

Rewards from all rubrics are summed together:

How Metrics are Aggregated

Metrics with the same name are summed across rubrics:

Example

When to Use RubricGroup

Use RubricGroup when:
  • You want to combine multiple evaluation criteria from different rubrics
  • You have domain-specific rubrics that should be evaluated together
  • You need to compose complex evaluation strategies from simpler components
  • You want to weight different aspects of evaluation differently
Common scenarios:
  • Combining a MathRubric with custom format validation
  • Aggregating task-specific rubrics with general quality metrics
  • Creating modular evaluation pipelines
  • Reusing rubrics across different environments

Important Notes

Empty rubrics list: A ValueError is raised if you try to create a RubricGroup with an empty list of rubrics.
Methods that modify rubrics: add_reward_func, add_metric, and add_class_object only affect the first rubric in the group. If you need to add functions to specific rubrics, access them directly via rubric_group.rubrics[index].
Inheritance: RubricGroup inherits from Rubric, so it can be used anywhere a Rubric is expected (e.g., in environments).

See Also