Fix DROP exact match: the length check compares gold to gold - #1356
Open
Ag3497120 wants to merge 1 commit into
Open
Fix DROP exact match: the length check compares gold to gold#1356Ag3497120 wants to merge 1 commit into
Ag3497120 wants to merge 1 commit into
Conversation
The second conjunct of the exact-match condition read len(gold_normalized_spans) == len(gold_normalized_spans). It is true for every input, so the check reduced from multiset equality to set equality: a prediction that repeats a correct span scored em 1.0, where lm_eval/tasks/drop/utils.py, which this module mirrors, scores 0.0. Adds the duplicate-span case to tests/unit/metrics/test_cases/drop.json. That file is marked -diff in .gitattributes, so the addition does not render in the GitHub diff view. Co-Authored-By: Claude Opus 5 <noreply@anthropic.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 defect
src/lighteval/metrics/harness_compatibility/drop.py:92— the second conjunct of the exact-match condition comparesgoldtogold:len(x) == len(x)holds for every input, so the condition is set equality. The same condition inlm_eval/tasks/drop/utils.py:87, which this module exists to be compatible with, has the prediction on the left, so it is multiset equality:A prediction that repeats a correct span scores as an exact match. Two lines, no fixtures:
drop.pyentered the repository already in this form, in 9009723 (#1065); there is no earlier revision of the file here.Measured against lm-evaluation-harness
lighteval@932e1f2againstEleutherAI/lm-evaluation-harness@64f3d092(itslm_eval/tasks/drop/utils.pyunmodified), callingget_metricsandDropMetrics._get_metricson the same inputs:The last row is the same bug seen from the other side: because the surviving comparison is
len(gold) == len(gold), a gold that repeats a span also matches a shorter prediction.Sweeping it: every prediction of 1–3 spans and every gold of 1–2 spans drawn from
{"4", "five", "6"}, both passed as lists — 39 predictions × 12 golds = 468 pairs.Over that space the patched metric agrees with the harness everywhere,
maindisagrees on 48 pairs, and every one of those 48 ismainscoring higher.f1never moves. So on those inputs reported DROP EM is inflated, not deflated.The change
The test does not render in the diff
Line 2 of
.gitattributesistests/unit/metrics/test_cases/*.json -filter -diff -merge text, so GitHub shows the fixture change asBin 1714 -> 2332 bytes. It is quoted in full below. It is appended afterDROP - Partial Match, and the three existing cases are byte-identical.{ "name": "DROP - Duplicate Predicted Span", "metric_class": "drop", "metric_params": {}, "doc": { "query": "What is 2 + 2?", "specific": { "golds_no_preprocessing": ["4"] }, "choices": ["4"], "gold_index": 0, "task_name": "math" }, "model_response": { "text": ["4", "4"] }, "expected_output": { "em": 0.0, "f1": 0.5 }, "tolerance": 0.01, "description": "Two predicted spans against one gold span is not an exact match; lm-evaluation-harness scores this 0.0" }git diff --text tests/unit/metrics/test_cases/drop.jsonrenders it: 23 lines inserted, 0 deleted.Red, then green
Base commit
932e1f2f4c5af3e926534f12b2a84a3ae18d6d3f(huggingface/lightevalmain, 2026-08-11), working tree clean at that commit,pip install -e ".[dev]". Python 3.11.15, torch 2.13.0, transformers 5.15.1, datasets 5.0.1, numpy 2.4.6, pytest 9.1.1, ruff 0.16.4, macOS 26.5 arm64.$ pytest tests/unit/metrics/test_automated_metrics_pytest.py -k drop -qUnmodified at
932e1f2:Fixture applied,
drop.pyuntouched:One failure, so the three existing cases still pass without the fix. Fixture plus the one-line change:
Suite
The failing names are the same list before and after, and none of them are DROP:
test_cases/extractiveness.json—ImportErroronDataStatsMetric, wantslighteval[multilingual]test_metric_requests.py::test_pmi_request*—TypeError: Strings must be encoded before hashingtest_vllm_model.py(2),test_reasoning_tags.py(6),test_caching.py(2 tests + 6 subtests) —vllmandtorchvisionare not installed hereThe passed count in
tests/unit/metricsdoes not move, because each test-case JSON file is a single parametrised pytest item regardless of how many cases it holds.ruff format --checkandruff checkpass ondrop.py;make qualityis what the Quality workflow runs.The diff is two files: one line in
drop.py, one appended object indrop.json. Nothing reformatted, no other hunks, no new files.