fix(llm_judge): use last-match for verdict extraction in single and pairwise judging - #3921
Open
AUTHENSOR wants to merge 1 commit into
Open
fix(llm_judge): use last-match for verdict extraction in single and pairwise judging#3921AUTHENSOR wants to merge 1 commit into
AUTHENSOR wants to merge 1 commit into
Conversation
…ngle/pair run_judge_single used re.search (first-match) for [[rating]] extraction. run_judge_pair used substring 'in' checks (A checked before B before C). Both allow an early verdict token in reasoning text to override the judge's final verdict. Switch to findall + last-match.
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.
Summary
The LLM judge in
fastchat/llm_judge/common.pyextracts verdicts using first-match parsing:run_judge_single(line 176):re.search(one_score_pattern, judgment)returns the first[[N]]match. If the judge reasons about scores before its final verdict, the first match may be from reasoning text, not the verdict.run_judge_pair(line 283):if "[[A]]" in judgmentsubstring checks in A-before-B-before-C order. A response containing[[A]]in reasoning and[[B]]as the verdict selects A (first match).Fix
re.searchwithre.findalland take the last match (matches[-1]).insubstring chain withre.findall(r"\[\[([ABC])\]\]", judgment.upper())[-1].[[rating_a,rating_b]]): Same findall + last-match treatment.This matches the convention used by other eval frameworks (inspect_ai
DEFAULT_GRADE_PATTERNuses a greedy prefix to bind to the last verdict; openai/evalscot_classifyreverses lines).Verification
black --check: clean (no formatting changes needed)