Skip to main content

Overview

Metrics aggregate verification rewards across multiple trials to provide summary statistics and insights. They transform individual trial rewards into meaningful performance indicators. Harbor includes built-in metrics (mean, sum, min, max) and supports custom metric scripts for specialized evaluation.

BaseMetric Interface

All metrics implement the BaseMetric abstract class:

Input

  • rewards: List of reward dictionaries from verifiers, or None for failed trials

Output

  • Dictionary mapping metric names to numeric values

Built-in Metrics

Harbor provides several standard metrics:

Mean

Computes the average reward across trials:
Example:

Sum

Sums all rewards:

Min

Finds the minimum reward:

Max

Finds the maximum reward:

Custom Metrics

Create custom metrics using Python scripts executed with uv.

UvScript Metric

Creating a Custom Metric Script

Using Custom Metrics

In task.toml or dataset configuration:
Or via CLI:

Metric Configuration

Metrics are configured using the MetricConfig model:

MetricType Enum

MetricFactory

Create metrics dynamically:
Usage:

Job-Level Metrics

Jobs aggregate metrics across trials:

Metric Computation in Jobs

Metrics are computed as trials complete:

EvalStats

Metric results are stored in EvalStats:
Example job result:

Multi-Metric Evaluation

Combine multiple metrics for comprehensive evaluation:
Output:

Dataset-Specific Metrics

Benchmark datasets can define their own metrics:
These metrics are automatically applied to all trials from that dataset.

Handling Failed Trials

Metrics must handle None values for failed trials:

Best Practices

  • Use Mean for general performance comparison
  • Use Max when evaluating best-case performance
  • Use Min to identify worst-case scenarios
  • Use custom metrics for domain-specific evaluation
  • Combine multiple metrics for comprehensive analysis
  • Document metric semantics clearly
  • Handle None values (failed trials) gracefully
  • Validate input data format
  • Return meaningful metric names
  • Test metrics with edge cases
  • Keep metric computation fast
  • Avoid expensive operations in metrics
  • Cache computed values when appropriate
  • Use efficient data structures
  • Consider memory usage for large datasets
  • Pin dependency versions in metric scripts
  • Document metric algorithms
  • Use deterministic computations
  • Version metric implementations
  • Test metrics for consistency

Example Custom Metrics

Pass Rate

Statistical Summary

Percentile Metrics

Verifiers

Producing rewards for metrics

Trials and Jobs

Trial execution and result aggregation

Tasks

Task configuration and evaluation

Agents

Agent performance measurement