The EvaluatorRunner is an abstract base class used to execute evaluations. To use it, you must create a concrete implementation that defines how to build the evaluation payload and how to submit the evaluation (either to a hosted server or via a local in-process execution).
There are two primary modes of operation determined by the generic type S:
- Hosted Scorers: Use
S = str when scorers are identified by strings (typically for server-side execution). - Local Scorers: Use
S = Judge when using local Judge instances (typically for in-process execution).
To implement a runner, you must override:
_build_payload: Constructs the ExampleEvaluationRun object._submit: Handles the actual submission of the evaluation and returns the number of unique examples expected.
The base class provides the run method, which orchestrates the lifecycle: building the payload, submitting, polling for results, and displaying them.
from typing import List, TypeVar
from judgeval.evaluation.evaluation_base import EvaluatorRunner
from judgeval.judges import Judge
from judgeval.data.example import Example
from judgeval.internal.api import JudgmentSyncClient
# For local Judge execution
S = Judge
class MyLocalRunner(EvaluatorRunner[S]):
def _build_payload(self, eval_id, project_id, eval_run_name, created_at, examples, scorers):
# Implementation for building payload
pass
def _submit(self, console, project_id, eval_id, examples, scorers, payload, progress):
# Implementation for local execution
return len(examples)
# Usage
runner = MyLocalRunner(client=client, project_id="proj_123", project_name="My Project")
results = runner.run(
examples=my_examples,
scorers=[my_judge_instance],
eval_run_name="test-run",
timeout_seconds=300
)