Repository navigation
fix(eval): find the choice letter when CJK text touches it - #4774
Merged
jundot merged 1 commit intoOct 23, 2026
Merged
Conversation
_extract_mc_answer finds the fallback letter with \b, and in a str pattern Han, kana and Hangul are word characters. A letter written straight against them has no boundary, so "答案是B", "正解はBです" and "정답은 B입니다" extract nothing and CMMLU, JMMLU and KMMLU score the answer as wrong. When steps 1-3 find nothing, look again with re.ASCII so only ASCII letters, digits and _ count as word characters. Every response that extracts a letter today keeps the same letter. Co-Authored-By: Claude Opus 5.5 <[email protected]>
jundot
approved these changes
Oct 23, 2026
jundot
left a comment
Owner
There was a problem hiding this comment.
Unicode \b treats Han, kana and Hangul as word characters, so replies like "答案是B" or "정답은 B입니다." came back empty on main and were scored wrong. The new step only runs after the existing ones miss, so answers that already extract stay the same and these now return B.
LGTM, merging.
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
CMMLU, JMMLU and KMMLU score a correct answer as wrong when the model states it as a sentence in the benchmark's language and nothing separates the letter from the surrounding text.
BaseBenchmark._extract_mc_answerreturns an empty string, so the question counts as wrong (an external-API run reports it asparse_error).These are ordinary ways to give an answer. Chinese and Japanese put no spaces between words, and Korean particles and the copula attach straight to the letter. The CMMLU authors' own scorer has patterns for exactly these shapes, such as
答案(选项)?(是|为):? ?([ABCD])and故?选择?:? ?([ABCD])(extract_choicein mp_utils.py).Root cause
omlx/eval/base.py:137-143. The fallback that takes the last valid letter relies on\b:In a
strpattern\wcovers every Unicode letter, so Han characters, kana and Hangul are word characters. There is no word boundary inside "是B" or "B입", and the letter is never matched. Step 1 needs the English "answer is" cue and step 3 only looks at the first character, so all three steps come back empty.Fix
A new last step runs only when steps 1 to 3 find nothing. It repeats the step 2 search with
re.ASCII, which limits word characters to ASCII letters, digits and_. A letter next to CJK text now counts, and a letter inside an ASCII word or number still does not ("维生素B12", vitamin B12, still extracts nothing).The step goes after the existing ones on purpose: every response that extracts a letter today extracts the same letter afterwards. A letter found by the existing steps still beats a later one that touches CJK text. "答案:B。A选项错误" ("Answer: B. Option A is wrong") stays
B, and "B是正确的,A是错误的" ("B is correct, A is wrong") staysBthrough the first-character rule. Switching step 2 to ASCII boundaries outright would turn both intoA.All twelve benchmarks that call this helper get the change. Only responses that extract nothing today are affected, and those are always scored wrong today, so no score can go down.
Validation
Apple Silicon (arm64), macOS 26.7.1, Python 3.11.17. No model is needed; the change is in a pure text function.
tests/test_eval.pygainsTestCJKMultipleChoice: seven responses whose letter touches Chinese, Japanese or Korean text, and three that pin the existing precedence. Onmain(d762927) with only the tests added:With the change:
10 passed.Adjacent suites:
tests/test_eval.pygives 101 passed, andtests/test_eval_worker_pool.pywithtests/test_mbpp_extract_code.pygives 46 passed.TestLocalStopReasonandTestBenchmarkRegistryintests/test_eval.pyimport modules that load MLX and could not run in my environment; neither passes CJK text to the extractor.I also ran the old and new extractor side by side on 300,000 random strings mixing CJK, ASCII letters, digits and punctuation, and on 647,753 question and choice texts from all twelve bundled multiple-choice datasets. No input that extracted a letter before extracts a different one after.
ruff checkandblack --checkreport the same findings on both touched files before and after the change, so it adds none.Checklist
🤖 Generated with Claude Code