Repository navigation
Fix MCQ letter extraction for chat-style ANSWER lines - #433
Merged
Merged
Conversation
The ANSWER: pattern was case-insensitive, so its [A-Z] matched the first
letter of any word ("ANSWER: the correct choice is C" extracted T). It
also rejected markdown around the label ("**Answer:** B" extracted
nothing). The letter must now stand alone, and emphasis or parentheses
around the label and letter are allowed.
GPQA and LabBench now share this pattern with the native MCQ extractor
instead of carrying their own copies.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
The pattern allowed a leading underscore but rejected a trailing one, since (?!\w) treats underscore as a word character. Also pin that GPQA and LabBench no longer match a letter on the line after ANSWER:. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Chat models often put the letter on its own line ("**Answer:**\n\nC").
GPQA and LabBench matched this on main, and LabBench, which has no
fallback, returned None after the shared pattern went same-line only. The
next-line letter must stand alone or label an option, so a sentence that
starts with "A" or "I" is not read as an answer.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Contributor
|
Three (very flexible) flags:
|
mgmorgan23
approved these changes
Oct 2, 2026
"Answer C" and "**Answer** (B)" now extract the letter. Without a colon,
the letter must be on the same line, uppercase, and stand alone or label
an option, so prose such as "answer a) first" or "answer A good question"
does not match. This matters because the ANSWER pattern outranks
\boxed{}, so an early false match would win over the final answer.
Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Collaborator
Author
|
@mgmorgan23 I took your advice on the colon change. I'll going to leave the other two out of scope for this PR, but I'm not opposed to returning to this and doing more testing to make sure the changes don't unexpectedly regress something else. |
gregorybchris
enabled auto-merge (squash)
October 2, 2026 20:49
Contributor
|
That makes sense to me! |
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 shared
ANSWER: Xregex misread two common chat-model output styles:ANSWER: the correct choice is CT**Answer:** BNoneBAnswer: **(C)**CCAnswer: _B_NoneB**Answer:**\n\nCNoneCAnswer C,**Answer** (B)NoneC,BLet me answer a) first.\n\boxed{C}CCCause: the pattern used
re.IGNORECASE, so[A-Z]also matched the lowercase first letter of the next word. It also did not allow**between the colon and the letter.Fix: a single
ANSWER_LINE_PATTERNinevals/extract/mcq.py. It requires the letter to stand alone ((?!\w)), allows*,_and(around the label and the letter. The letter may also start the next non-blank line (**Answer:**\n\nC), but only when it stands alone there or labels an option (B),(B) Paris). That keepsAnswer:\n\nA good approach…from capturingA. GPQA and LabBench already matched a next-line letter onmain; BBQ, WMDP and MedQA now do too. The guard rejects a following letter or digit, so a trailing_of emphasis is accepted. Lowercase single letters (answer: c) still match, as before.The colon is optional (
Answer C). Without it, the letter must be on the same line, uppercase, and stand alone or label an option. That keeps prose such asanswer a) firstoranswer A good questionfrom matching. The guard matters because the ANSWER pattern outranks\boxed{}, so an early false match would beat the final answer. One known false match remains: prose that names an uppercase option, such asI'd answer (A) at first, but … \boxed{C}, returnsA.Affected tasks
extract_mcq_answerdirectly.ANSWER: the correct choice is Cnow reaches the last-capital-letter fallback and returnsC. LabBench has no fallback, so it returnsNone.Results already stored for these tasks may be affected. They are not re-scored in this PR.
Testing
tests/evals/extract/test_mcq.py,tests/evals/tasks/test_gpqa.pyandtests/evals/tasks/test_lab_bench.py. The positive cases fail onmainand pass with this change. The false-match cases pass on both and guard against new false matches.uv run pytest tests/ --ignore=tests/integration: 2896 passed, 34 skipped.ruff checkandruff format --checkare clean.ty checkreports one warning, an unusedtype: ignoreinharness/sandbox/executor.py. That warning is also onmain.🤖 Generated with Claude Code