Skip to content

fix: handle non-ASCII languages in ROUGE-1 eval tokenizer#6483

Open
guptaishaan wants to merge 1 commit into
google:mainfrom
guptaishaan:fix/issue-3111-6599
Open

fix: handle non-ASCII languages in ROUGE-1 eval tokenizer#6483
guptaishaan wants to merge 1 commit into
google:mainfrom
guptaishaan:fix/issue-3111-6599

Conversation

@guptaishaan

Copy link
Copy Markdown

The _calculate_rouge_1_scores function in final_response_match_v1.py uses
rouge_scorer.RougeScorer with its default tokenizer, which strips every
character that does not match [a-z0-9]. For languages such as Thai, Chinese,
or Arabic—where words contain no ASCII characters—every token is removed and
the scorer always returns an F-measure of 0.0, causing eval to report a
mismatch even for identical strings.

The fix introduces a _UnicodeTokenizer that is used automatically whenever
either the candidate or reference text contains non-ASCII characters. It splits
on whitespace and, for each non-ASCII word, emits individual Unicode characters
as tokens so that ROUGE-1 overlap is computed at the character level—a
well-established fallback for scripts that lack whitespace word delimiters.
ASCII text continues to use the existing stem-based tokenizer unchanged.

Two regression tests are added to test_final_response_match_v1.py: one
asserting that identical Thai text scores 1.0, and one asserting that entirely
different Thai text scores 0.0.

Fixes #3111.

The `_calculate_rouge_1_scores` function in `final_response_match_v1.py` uses

Signed-off-by: Ishaan <ishaangupta0408@gmail.com>
@adk-bot adk-bot added the eval [Component] This issue is related to evaluation label Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

eval [Component] This issue is related to evaluation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Eval fails for non-English languages

3 participants