Skip to content
Judgment Labs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Evaluation

Score a batch of examples using hosted scorers or Code judges.

Create an Evaluation via client.evaluation.create(), then call .run() to execute scorers against your examples.

Two modes are supported:

  • Hosted scorers – pass scorer names as strings (e.g. "faithfulness", "answer_relevancy"). Evaluation runs server-side on the Judgment platform.
  • Code judges – pass Judge subclass instances for in-process evaluation with your own scoring logic.

Using hosted scorers:

evaluation = client.evaluation.create()
results = evaluation.run(
    examples=examples,
    scorers=["faithfulness", "answer_relevancy"],
    eval_run_name="nightly-eval",
)
for result in results:
    print(result.scorers_data)

Using a Code judge:

evaluation = client.evaluation.create()
results = evaluation.run(
    examples=examples,
    scorers=[ToxicityJudge()],
    eval_run_name="toxicity-check",
)

__init__()

def __init__(client, project_id, project_name):

Parameters

PropType
clientJudgmentSyncClient
TypeJudgmentSyncClient
project_idOptional[str]
TypeOptional[str]
project_namestr
Typestr

run()

Run scorers against your examples and return results.

Pass either hosted scorer names (strings) or Code judge (Judge) instances. Mixing both in one call is not supported.

results = evaluation.run(
    examples=[
        Example.create(
            input="What is Python?",
            actual_output="A programming language.",
            expected_output="A high-level programming language.",
        ),
    ],
    scorers=["answer_relevancy"],
    eval_run_name="quick-test",
)
print(results[0].scorers_data)
def run(examples, scorers, eval_run_name, assert_test=False, timeout_seconds=300) -> typing.List:

Parameters

PropType
examplesList[Example]

The Example objects to evaluate.

TypeList[Example]
scorersUnion[List[str], List[Judge]]

Hosted scorer names (e.g. ["faithfulness"]) or Judge instances (e.g. [ToxicityJudge()]).

TypeUnion[List[str], List[Judge]]
eval_run_namestr

A name for this run, visible in the dashboard.

Typestr
assert_test?bool

Deprecated and ignored by the current evaluation result payload.

Typebool
DefaultFalse
timeout_seconds?int

Maximum seconds to wait for hosted scorer results before timing out.

Typeint
Default300

Returns

typing.List - A list of ScoringResult objects, one per example.

Was this page helpful?