fix(evaluation): resolve threshold via criterion in LlmAsJudge, not the deprecated EvalMetric.threshold - #6678
Open
gaurav-gandhi-2411 wants to merge 1 commit into
Conversation
…he deprecated EvalMetric.threshold LlmAsJudge.evaluate_invocations read self._eval_metric.threshold directly, the deprecated field (defaults to None). Configuring the metric only via criterion -- the documented, non-deprecated path -- left this field None and crashed with TypeError: '>=' not supported between instances of 'float' and 'NoneType'. _get_metric_threshold() is the established pattern for this exact resolution, already used by 8 other evaluators since 2510141. This call site was missed. Routes LlmAsJudge through the same helper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔴 Required Information
Describe the Bug:
LlmAsJudge.evaluate_invocationsreadsself._eval_metric.thresholddirectly, which is the deprecated field (EvalMetric.threshold, defaults toNone, docstring: "This field will be deprecated soon. Please usecriterioninstead."). Configuring the metric only viacriterion— the documented, non-deprecated path — leaves this fieldNoneand crashes.Steps to Reproduce:
EvalMetricwithcriterion=LlmAsAJudgeCriterion(threshold=0.5, ...)and no top-levelthreshold.LlmAsJudgesubclass'sevaluate_invocations.Expected Behavior: Evaluation completes using the criterion's threshold.
Observed Behavior:
raised from
llm_as_judge_utils.get_eval_status, called withthreshold=None.Minimal Reproduction Code:
Why this fix
_get_metric_threshold()(added in 2510141) is the established pattern for resolving this exact deprecated-field-vs-criterion ambiguity, already used by 8 other evaluators (trajectory_evaluator.py,response_evaluator.py,safety_evaluator.py,final_response_match_v1.py, and themulti_turn_*evaluators). This call site was missed when that pattern was introduced. This PR routesLlmAsJudgethrough the same helper.Testing Plan
Added
test_evaluate_invocations_with_criterion_only_threshold, which constructs the metric viacriteriononly and assertsevaluate_invocationscompletes without raising. Confirmed this test fails onmainwith the exactTypeErrorabove, and passes after the fix.