Skip to content

fix(llm_judge): use last-match for verdict extraction in single and pairwise judging - #3921

Open
AUTHENSOR wants to merge 1 commit into
lm-sys:mainfrom
AUTHENSOR:fix/judge-last-match-verdict
Open

fix(llm_judge): use last-match for verdict extraction in single and pairwise judging#3921
AUTHENSOR wants to merge 1 commit into
lm-sys:mainfrom
AUTHENSOR:fix/judge-last-match-verdict

Conversation

@AUTHENSOR

Copy link
Copy Markdown

Summary

The LLM judge in fastchat/llm_judge/common.py extracts verdicts using first-match parsing:

  1. 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.

  2. run_judge_pair (line 283): if "[[A]]" in judgment substring checks in A-before-B-before-C order. A response containing [[A]] in reasoning and [[B]] as the verdict selects A (first match).

Fix

  • Single: Replace re.search with re.findall and take the last match (matches[-1]).
  • Pairwise: Replace the in substring chain with re.findall(r"\[\[([ABC])\]\]", judgment.upper())[-1].
  • Two-score ([[rating_a,rating_b]]): Same findall + last-match treatment.

This matches the convention used by other eval frameworks (inspect_ai DEFAULT_GRADE_PATTERN uses a greedy prefix to bind to the last verdict; openai/evals cot_classify reverses lines).

Verification

  • black --check: clean (no formatting changes needed)
  • Diff touches only the three extraction blocks (16 lines changed)

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant