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.
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).
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).
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.
- Iterates through each child rubric
- Calls
score_rollouton each rubric - Aggregates rewards (summed across rubrics)
- Aggregates metrics (summed across rubrics)
- Updates the state with total reward and combined metrics
state["reward"]: Set to the sum of all rubric rewardsstate["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.
- Iterates through each child rubric
- Calls
score_groupon each rubric - Aggregates rewards across all rubrics for each state
- Aggregates metrics across all rubrics for each state
- 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
UseRubricGroup 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
- Combining a
MathRubricwith custom format validation - Aggregating task-specific rubrics with general quality metrics
- Creating modular evaluation pipelines
- Reusing rubrics across different environments
Important Notes
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
- Rubric - Base rubric class
- MathRubric - Domain-specific math evaluation
- Environment - How rubrics are used in environments
- Reward Functions - Writing custom reward functions