Skip to content

Include missing retrieval queries in evaluation averages - #1633

Open
Afloat16 wants to merge 1 commit into
FlagOpen:masterfrom
Afloat16:fix/missing-query-evaluation-20261112
Open

Afloat16 wants to merge 1 commit into
FlagOpen:masterfrom
Afloat16:fix/missing-query-evaluation-20261112

Conversation

@Afloat16

Copy link
Copy Markdown

Problem

evaluate_metrics averages the scores returned by pytrec_eval over the number of queries present in that output. A judged query omitted from a retrieval run disappears from the denominator, so an incomplete run can report perfect NDCG, MAP, recall and precision. Representing the same missing query with an explicit empty result instead gives a different score. A completely empty run also divides by zero even when the judgment set is nonempty.

Changes

Average these four metrics over the full set of queries in qrels, matching the evaluation population already used by this module's MRR and capped recall. Missing query results contribute zero without changing per-query pytrec_eval calculations or complete-run scores.

Validation

  • Eleven native pytrec_eval cases cover omitted/empty/nonrelevant result equivalence, multiple cutoffs, entirely empty runs, hand-calculated rank-two hits, unjudged query exclusion, and complete-run controls.
  • Exact baseline: 5 failed, 6 passed. With the patch: 11 passed.
  • New cases plus existing Trainer/import checks: 19 passed, 1 skipped; the skipped check requires Transformers 5.x.
  • Tested with pytrec-eval-terrier 0.5.11 and FAISS CPU 1.16.0 installed. The tests use normal package imports and skip when these optional evaluation dependencies are unavailable.
  • The judgment set remains nonempty in this regression scope; this change does not redefine empty-qrels behavior or other metric functions.
  • Ruff and git diff --check pass.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant