fix(metrics): escape decimal point in final_number_exact_match regex#4317
Open
devteamaegis wants to merge 1 commit into
Open
fix(metrics): escape decimal point in final_number_exact_match regex#4317devteamaegis wants to merge 1 commit into
devteamaegis wants to merge 1 commit into
Conversation
The number-extraction regex used an unescaped '.', which matches any character. As a result a non-digit, non-dot character between digits (e.g. '7:30', '2x3') was captured as a single number instead of extracting the trailing number, producing wrong metric values.
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's broken
final_number_exact_matchmis-extracts the final number when a prediction contains a non-digit, non-dot character between digits. For examplefinal_number_exact_match("30", "the meeting is at 7:30")returns 0, andfinal_number_exact_match("3", "the grid is 2x3")returns 0 — both should be 1. This silently lowers scores on any benchmark using this metric when models emit times, ratios, or dimensions before the answer.Why it happens
The extraction regex is
r"-?[\d,]+(?:.\d+)?". The.in the optional group is unescaped, so it matches any character;7:30and2x3get captured as a single token instead of extracting the trailing number.Fix
Escape the decimal point:
(?:\.\d+)?. Decimal handling is unchanged (\.still matches a literal.); only the spurious cross-character merges stop.Test
Added two assertions to
test_final_number_exact_matchcovering7:30and2x3. They fail before and pass after; existing decimal/comma/negative cases still pass.