fix(reward): grade the final MC letter, not the first (#29)#94
Open
shin-core wants to merge 2 commits into
Open
fix(reward): grade the final MC letter, not the first (#29)#94shin-core wants to merge 2 commits into
shin-core wants to merge 2 commits into
Conversation
5be4976 to
deea867
Compare
extract_choice_letter used pat.search() -- the FIRST occurrence -- so a
self-correcting answer ("The answer is A. Actually, the answer is C.")
was graded against A instead of C, corrupting the MMLU/GPQA reward signal.
Use the LAST occurrence of the highest-priority matching pattern, matching
the "final answer comes last" convention already used by extract_boxed /
extract_last_number / extract_code and this function's own fallback.
Fixes mini-router#29
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
deea867 to
8ca605e
Compare
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.
What changed
extract_choice_letterusedpat.search()(first occurrence). When a model self-corrects, the first stated letter was graded instead of the final one. Now it takes the last occurrence of the highest-priority matching pattern.Repro
This matches the "final answer comes last" convention already used by
extract_boxed,extract_last_number,extract_code, and this function's own fallback. Pattern priority is preserved — a higher-priority earlier match still beats a lower-priority later one.Tests
New
tests/test_reward_choice.py(10 cases): self-correction, all supported phrasings, priority ordering, prose-"A" exclusion, empty input. Fails on old source, passes with fix; full reward suite (26 tests) green.Fixes #29
🤖 Generated with Claude Code
Notes
A corresponding lab-notebook entry was added to
docs/JOURNAL.mdper repository protocol (AGENTS.md §6).