Repository navigation
Restore TriviaQA prediction normalization - #1446
Open
mottopanikeiku wants to merge 1 commit into
Open
mottopanikeiku wants to merge 1 commit into
mottopanikeiku wants to merge 1 commit into
Conversation
I noticed that the TriviaQA task lowercases and strips punctuation from the gold aliases but no longer normalizes the model's answer, so a correct answer such as "John Nash" scores 0. I restored the harness_triviaqa_normalizer prediction normalizer that the task used before the tasks were moved to individual files in huggingface#1016, and added a regression test. Assisted-by: Claude Assisted-by: GPT-6 Astra Signed-off-by: mottopanikeiku <176798723+mottopanikeiku@users.noreply.github.com>
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 built-in
triviaqatask lowercases the gold aliases and strips their punctuation intriviaqa_prompt. Its metric is plainMetrics.exact_match, which only strips whitespace from the prediction. So a correct answer scores 0 whenever it has a capital letter or punctuation. For example,John Nashdoes not match the aliasjohn nash.The prediction normalizer was lost when the tasks were moved to individual files in #1016. Before that, the task used
Metrics.exact_match(sample_params={"strip_strings": True, "normalize_pred": harness_triviaqa_normalizer}). This PR restores that line. lm-eval-harness also scores TriviaQA withignore_caseandignore_punctuation.Reproducer:
John Nash(validation question bb_5713)1599-1660(validation question wh_4325)lighteval accelerate "model_name=HuggingFaceTB/SmolLM2-135M,device=cpu" "triviaqa|0" --max-samples 1000The model outputs were the same in both runs. Scoring those 1000 outputs with the lm-eval-harness rule gives 0.042. The remaining 3 differences come from
_remove_prefixesin the prompt function, which this PR does not change.Like other tasks that pass a normalizer function in
sample_params, the metric key is nowem:strip_strings=True&normalize_pred=<function harness_triviaqa_normalizer ...>, as it was before #1016.I added
tests/unit/tasks/test_triviaqa.py. Two of its three cases fail on main, and all three pass with this change.I found this by reading and testing the code.
I made this PR and directed its development, with AI assistance from Claude and GPT-6 Astra.