Repository navigation
fix(searchqa): don't let an empty answer count as a sub_em match - #375
Merged
Yifan Yang (Yif-Yang) merged 1 commit intoNov 7, 2026
Merged
Conversation
sub_em checked `norm_gold in norm_pred or norm_pred in norm_gold`. An empty string is a substring of every string, so a prediction that normalizes to empty (an empty <answer></answer>, or an answer such as "The." that is only an article and punctuation) scored sub_em = 1.0 against any gold answer. A gold answer that normalizes to empty matched every prediction the same way. An empty normalized string now only matches another empty string, which is how exact_match and f1_score already treat it. Non-empty substring matches in either direction are unchanged.
Contributor
|
Merged, thank you. |
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.
Summary
Fixes #374.
SearchQA's
sub_emgave full credit to an empty answer. A prediction that normalizes to empty (an empty<answer></answer>, or an answer such asThe.) scoredsub_em = 1.0against any gold answer, and a gold answer that normalizes to empty matched every prediction. An empty normalized string now only matches another empty string.User impact: without this fix, SearchQA results report empty or article-only answers as substring matches, which inflates the reported
sub_emrate.Proof: the regression tests fail on upstream
eb959c3and pass with this change.Root cause
sub_em()inskillopt/envs/searchqa/evaluator.pyreturns 1.0 whennorm_gold in norm_pred or norm_pred in norm_gold. Afternormalize_answer()strips punctuation and articles, either side can be"", and"" in sis true for everys.exact_match()andf1_score()do not have this problem: an empty prediction only matches an empty gold there.Changes
sub_em()skips the substring test when either normalized side is empty, and returns 1.0 for that pair only when both are empty. This matchesexact_match()andf1_score().tests/test_searchqa_evaluator.py, testing throughevaluate(), which is what the SearchQA rollout calls.Reproduction
Before:
1.0,1.0,1.0,1.0After:
0.0,0.0,0.0,1.0Testing
python -m pytest tests/test_searchqa_evaluator.py -q: on upstreameb959c3, 4 failed (assert 1.0 == 0.0) and 2 passed; with the fix, 6 passed.python -m pytest tests/test_searchqa_evaluator.py tests/test_searchqa_rollout_failfast.py tests/test_materialize_searchqa.py tests/test_qwen_backend.py -q: 40 passed.python -m pytest -q: 2039 passed, 12 skipped, 4 xfailed.python -m ruff checkon the changed files: all checks passed.python -m mkdocs build --strict: passed.Risk and compatibility
sub_emis recorded in each SearchQA rollout result but does not feedhardorsoft(those come from EM and F1), so training and the validation gate are unchanged. The only visible change is that reportedsub_emno longer counts empty answers as matches. No backend, config key, file format or CLI change.