Fix helm_normalizer mis-scoring numbers (homogeneize before remove_punc)#1273
Open
iamsharduld wants to merge 1 commit into
Open
Fix helm_normalizer mis-scoring numbers (homogeneize before remove_punc)#1273iamsharduld wants to merge 1 commit into
iamsharduld wants to merge 1 commit into
Conversation
In helm_normalizer, remove_punc ran before homogeneize_numbers, so it stripped
the decimal point before the float() cast: '1.0' -> '10' -> '10.0'. This made
distinct numbers collide ('10' and '1.0' both -> '10.0'; '3.14' and '314' both
-> '314.0') and broke the function's own documented goal ('1.0' != '1'), causing
false exact-match scores on numeric answers (QuAC/DROP-style quasi_exact_match).
Run homogeneize_numbers before remove_punc so float() sees the original token.
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
In
helm_normalizer(the quasi-exact-match / HELM normalizer),remove_puncruns beforehomogeneize_numbers, so it strips the decimal point before thefloat()cast. The result is wrongon numeric answers:
Root cause:
'1.0'→remove_punc→'10'→float→'10.0', and'3.14'→'314'→'314.0',so different numbers normalize to the same string while
1.0and1normalize differently.Fix
Run
homogeneize_numbersbeforeremove_punc, sofloat()sees the original token. Distinctnumbers then stay distinct and equal-but-differently-formatted numbers match, per the docstring intent.
Non-numeric tokens are unaffected (homogeneize_numbers returns them unchanged either way).
Tests
tests/test_unit_base_metrics.py::test_quasi_exact_match_numbers—1.0 == 1matches;10 != 1.0and
3.14 != 314don't. Fails before, passes after; the existingtest_quasi_exact_match(sentencetext) still passes.