fix: DocumentRecallEvaluator single_hit reports false 1.0 recall on missing comparison values#11951
Open
Otis0408 wants to merge 1 commit into
Open
Conversation
|
@Otis0408 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
Coverage reportClick to see where and how coverage changed
This report was generated by python-coverage-comment-action |
||||||||||||||||||||||||
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.
Anyone using
DocumentRecallEvaluatorinsingle_hitmode with adocument_comparison_fieldthat is not present on the documents (for examplemeta.file_idwhen that key was never set) gets a silently wrong evaluation._get_comparison_valuereturnsNonefor every such document, so both the ground-truth set and the retrieved set collapse to{None}. The set intersection is non-empty (NonematchesNone), and the evaluator reports a perfect recall of 1.0 even when the ground-truth and retrieved documents are completely unrelated. The same happens when all documents have empty-string comparison values.multi_hitmode already guards against this: it returns 0.0 with a warning when the ground-truth or retrieved comparison values are empty or a subset of{"", None}, and the MAP/MRR/NDCG evaluators all filter outNonevalues too. Only thesingle_hitpath was missing the guard, so it treated a missing/empty value as a legitimate match — most likely overlooked when the guard was added tomulti_hit.The fix adds the same guard to
_recall_single_hit: before matching, if the unique ground-truth values (or the unique retrieved values) are empty or a subset of{"", None}, the method logs a warning and returns 0.0. Valid comparisons are unaffected.Before/after with the public API:
A regression test (
test_missing_comparison_field_on_both_sides) plus the empty / empty-string cases already covered formulti_hitare added to thesingle_hittest class. The new test fails on the current code and passes with the fix.A release note is included at releasenotes/notes/document-recall-single-hit-missing-values-c3d4e5f607182930.yaml.