fix: MixEval judge extractors use last-match (verdict-injection defense)#1295
Open
AUTHENSOR wants to merge 1 commit into
Open
fix: MixEval judge extractors use last-match (verdict-injection defense)#1295AUTHENSOR wants to merge 1 commit into
AUTHENSOR wants to merge 1 commit into
Conversation
The three process_judge_response functions used re.search (first-match) to extract the judge's verdict. The model-under-test's output is interpolated verbatim into the judge prompt (judge_prompts.py), so an injected <score> or [[N]] tag echoed early in the judge's response would win over the judge's actual final verdict. Switch all three to re.findall + take the last match, so the judge's final verdict (which appears last per the rubric instructions) is the one extracted.
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 three
process_judge_response*functions in MixEval usedre.search(first-match) to extract the judge's verdict from its response. The model-under-test's output is interpolated verbatim into the judge prompt (judge_prompts.py:92—<output>{answer}</output>), so an injected verdict tag (e.g.<score> 9 </score>or[[1]]) echoed early in the judge's response would win over the judge's actual final verdict.This is the "verdict-injection" class — the same pattern fixed across the eval ecosystem (deepeval, ragas, guardrails-ai, promptfoo, instructor, CrewAI, LlamaIndex).
The three extractors
process_judge_response<score>\s(\d)\s</score>process_judge_response_multichoice_gpt\[\[([01])\]\]process_judge_response_freeform_gpt\[\[(\d.\d)\]\]All used
re.search→ first match wins. A judge response like:would extract
9(injected) instead of0(real).Fix
Switch all three to
re.findall+ take the last match. The judge's rubric instructs it to end with the verdict, so the last match is the authoritative one. Earlier matches (echoed from the submission or appearing in reasoning) are ignored.Verified
Single-match outputs are unaffected (last == first when there's one match).
Checklist
ruff check+ruff formatpass