Skip to content

Respect run score order in TREC evaluation - #905

Open
snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:fix/trec-respect-run-scores
Open

snygginghani wants to merge 1 commit into
huggingface:mainfrom
snygginghani:fix/trec-respect-run-scores

Conversation

@snygginghani

Copy link
Copy Markdown

The wrapper assigns an input DataFrame directly to TrecRun. TrecTools' NDCG expects its rows to already be ranked, so changing only row order changes the result. Evaluate also stored run scores as float32 and could turn distinct nearby scores into ties.

Sort by query, descending score and descending document ID, matching the tie-break used by TrecTools MAP. Store incoming Python scores as float64.

On the public TrecTools Robust03 InexpC2 example (100,000 run rows and 128,796 qrel rows), a pandas shuffle with random_state=42 changed NDCG@5 from 0.410148 to 0.028842 and NDCG@10 from 0.380676 to 0.031109 on main. Both input orders now produce 0.410148 / 0.380676, with equal values for all reported fields. Scores 0.50000001 versus 0.5 now give MAP and reciprocal rank of 1.0 in the regression. The exact-tie result remains 0.5.

Both focused tests fail on main and pass with the patch on TrecTools 0.0.50 and pandas 3.0.2. Black, isort, flake8 and git diff --check passed.

Prepared with AI assistance.

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