Judgeval Python-v1 SDKPrimitives

CustomScorerResult

The result object returned by custom scorers

A Pydantic model representing the result of a custom scorer evaluation. This is the required return type for all custom scorer score methods.

Parameters

scorerequired

:float

The numerical score assigned by the scorer. Typically between 0 and 1, where 1 indicates the best score.

Example: 1.0

reasonrequired

:str

A human-readable explanation for why the score was assigned.

Example: "The response correctly answered the question."

choice

:Optional[str]

An optional field to store additional choice information or metadata related to the scoring decision.

Example: "option_a"

Usage

from judgeval.v1.scorers import CustomScorerResult

# Creating a passing result
passing_result = CustomScorerResult(
    score=1.0,
    reason="The output matches the expected format."
)

# Creating a failing result
failing_result = CustomScorerResult(
    score=0.0,
    reason="The output is missing required fields."
)

# Creating a partial score result
partial_result = CustomScorerResult(
    score=0.5,
    reason="The output is partially correct."
)

# Creating a result with choice information
result_with_choice = CustomScorerResult(
    score=1.0,
    reason="Selected the best option based on criteria.",
    choice="option_a"
)

On this page