fix: support non-English languages in response_match_score eval metric - #6494
Closed
guptaishaan wants to merge 1 commit into
Closed
fix: support non-English languages in response_match_score eval metric#6494guptaishaan wants to merge 1 commit into
guptaishaan wants to merge 1 commit into
Conversation
The `response_match_score` metric uses the `rouge_score` library to compute Signed-off-by: Ishaan <ishaangupta0408@gmail.com>
Collaborator
|
Closing this PR and consolidating review and follow ups in #6292 |
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.
The
response_match_scoremetric uses therouge_scorelibrary to computeROUGE-1 F1 between the actual and expected responses. The library's default
tokenizer strips every character that is not
[a-z0-9], which discards allnon-ASCII text (Thai, Chinese, Japanese, Arabic, etc.) and produces an empty
token list. As a result, even perfectly-matching non-English strings receive a
score of 0.0.
The fix introduces a
_UnicodeTokenizerthat preserves ASCII words as-is andfalls back to character-level tokenization for tokens containing non-ASCII
characters. This ensures that identical non-English strings are scored 1.0
while the existing scoring behaviour for English text is unchanged (validated
by the existing unit tests). A new regression test covering identical Thai
text is also added.
Fixes #3111.