ruler_qa_squad: string_match_part is a mis-port of RULER's partial match and scores identically to string_match_all

Author: johnny-glitch12Created Sep 30, 2026Updated Sep 30, 2026

lm_eval/tasks/ruler/common_utils.py ports RULER's two string-match reductions from NVIDIA/RULER scripts/eval/synthetic/constants.py. The part variant places max outside and keeps all's inner term:

python
def string_match_part(preds, refs):          # harness, d6de8164
    score = max(
        sum(1.0 if r.lower() in pred.lower() else 0.0 for r in ref) / len(ref)
        for pred, ref in zip(preds, refs, strict=False)
    ) / len(preds)

Upstream has max inside, per prediction over the references, with sum as the outer reducer:

python
def string_match_part(preds, refs):          # NVIDIA/RULER
    score = sum([max([1.0 if r.lower() in pred.lower() else 0.0 for r in ref])
                 for pred, ref in zip(preds, refs)]) / len(preds) * 100

The two differences cancel exactly when len(preds) == 1, which is the only way the harness calls it — process_results_part passes a single generation. So string_match_part currently returns the same value as string_match_all: I enumerated 1,764 single-prediction inputs over a small vocabulary and found 0 differing cases.

Why it matters for ruler_qa_squad

qa_squad.yaml wires process_results: !function common_utils.process_results_part, matching upstream's TASKS = {..., 'qa': string_match_part}. But for SQuAD, qa_utils.read_squad builds "outputs": [a["text"] for a in qas["answers"]] — every annotator's answer for one question, i.e. alternative spellings, not several strings the model must all produce. Scoring them with the all reduction asks the model to emit every annotator variant at once.

With a real SQuAD answer list ['Denver Broncos', 'Denver Broncos', 'Broncos']:

prediction harness part upstream part
'Broncos' 0.3333 1.0000
'Denver Broncos' 1.0000 1.0000
'Santa Clara' 0.0000 0.0000

Measured on the dev set the task actually downloads (dev-v2.0.json, the URL in read_squad): 5,928 answerable questions, of which 3,166 (53.4%) have more than one distinct gold variant. A perfect model emitting gold answer #1 verbatim scores 0.8531 under the harness and 1.0000 upstream — so ruler_qa_squad numbers are not comparable with the RULER paper or with NVIDIA's own harness.

As a sanity check on the outer reducer: two fully-correct predictions currently score 0.5, because a max is divided by len(preds).

Suggested fix

One statement; string_match_all untouched:

python
 def string_match_part(preds: list[str], refs: list[list[str]]) -> float:
-    score = max(
-        sum(1.0 if r.lower() in pred.lower() else 0.0 for r in ref) / len(ref)
+    score = sum(
+        max(1.0 if r.lower() in pred.lower() else 0.0 for r in ref)
         for pred, ref in zip(preds, refs, strict=False)
     ) / len(preds)

There is currently no test coverage of either function — outside its definition, string_match_part's only reference in the repo is qa_squad.yaml.

Two things I'd want a maintainer's call on before opening a PR:

  1. This changes published ruler_qa_squad / ruler_qa_hotpot numbers (upward, and by a lot on SQuAD). If you'd rather freeze the current behaviour for comparability — as lm_eval/tasks/leaderboard/math/utils.py does with an explicit note — that's a legitimate choice, but it should be written down, because today it reads as a porting slip rather than a decision.
  2. Whether it warrants a task-version bump.

Happy to send the fix plus regression tests for both functions once you've decided which way you want it.

Found while auditing the RULER port; analysis done with an AI coding agent, and I verified every number above myself by running it — including fetching NVIDIA's constants.py and the SQuAD dev set directly.

Source: EleutherAI/lm-evaluation-harness