fix: ROUGE-1 eval returns 0 for non-English languages (ASCII-only tokenizer) - #6136
fix: ROUGE-1 eval returns 0 for non-English languages (ASCII-only tokenizer)#6136tcconnally wants to merge 1 commit into
Conversation
e275a87 to
6dff0a2
Compare
|
Hi @tcconnally , Thank you for your contribution! We appreciate you taking the time to submit this pull request. Please fix formatting errors. |
9beec74 to
98396a4
Compare
|
Fixed the pre-commit formatting issue (pyink). Rebased on main. |
|
Pushed a follow-up commit that hardens the tokenizer — I found two issues in the previous version while validating it against the
The updated Verified against the library:
Ready for another look, @wyf7107 — thanks for your patience. |
The default RougeScorer tokenizer uses r'\\w+' regex which only matches ASCII [a-zA-Z0-9_]. For non-Latin scripts (Thai, Chinese, Japanese, etc.), this returns zero tokens, causing ROUGE scores of 0.0 even when the response matches the expected output exactly. Added _unicode_tokenize function that uses re.UNICODE flag and falls back to character-level tokenization for non-ASCII scripts. Closes #3111
0168674 to
a574d0b
Compare
|
Withdrawing this — the fix doesn't actually run. It passes a plain function as The underlying bug is real (the default tokenizer strips non-Latin script → ROUGE 0.0 for Thai/CJK), but the fix needs to be a proper |
Problem
When evaluating text in non-Latin scripts (Thai, Chinese, Japanese, Arabic, etc.), the v1 ROUGE-1 evaluator returns scores of 0.0 even when the response matches the expected output exactly.
Root cause: The
rouge_scorelibrary's default tokenizer usesre.findall(r'\\w+', text)which only matches ASCII[a-zA-Z0-9_]. Non-Latin characters produce zero tokens → ROUGE-1 score of 0.0 regardless of correctness.Reproduction (from #3111)
Fix
Added
_unicode_tokenizefunction that:re.UNICODEflag for ASCII-majority text (preserves existing behavior)Closes #3111