feat!: add document_comparison_field to DocumentNDCGEvaluator#11636
Open
Kunal-Somani wants to merge 5 commits into
Open
feat!: add document_comparison_field to DocumentNDCGEvaluator#11636Kunal-Somani wants to merge 5 commits into
Kunal-Somani wants to merge 5 commits into
Conversation
|
@Kunal-Somani 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 |
||||||||||||||||||||||||
bogdankostic
requested changes
Jun 19, 2026
bogdankostic
left a comment
Contributor
There was a problem hiding this comment.
Thanks for your PR @Kunal-Somani! I left a few in-line comments that should be addressed before merging.
…tting, add upgrade note
Contributor
Author
|
Hey @bogdankostic |
Co-authored-by: bogdankostic <bogdankostic@web.de>
Contributor
Author
|
Thanks @bogdankostic Pulled in your formatting fixes and everything's merged and all 28 tests still pass. Let me know if anything else is needed. |
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.
Related Issues
Proposed Changes
DocumentNDCGEvaluatorwas the only document evaluator in Haystack that hardcoded document matching byid. This caused a known limitation where ground truth and retrieved documents had to share the same auto-generated hash-based ID to be matched correctly, which is rarely the case in practice.DocumentMAPEvaluator,DocumentMRREvaluator, andDocumentRecallEvaluatorall already support adocument_comparison_fieldparameter that lets users control how documents are matched. This PR bringsDocumentNDCGEvaluatorto the same level of consistency.Changes:
document_comparison_field: str = "content"init parameter toDocumentNDCGEvaluator, defaulting to"content"for consistency with sibling evaluators_get_comparison_value()method following the exact same pattern asDocumentMAPEvaluatorandDocumentMRREvaluatorto_dict()for serialization supportcalculate_dcg()to use the configurable comparison field instead of hardcodeddoc.idlookupid,meta.<key>, nested meta, missing keys, unsupported fields, and serialization round-tripsHow did you test it?
PYTHONPATH="" hatch run test:unit test/components/evaluators/test_document_ndcg.py& 27 passed, 0 failures (17 existing + 10 new)hatch run test:types— no issues in 365 source fileshatch run fmt— all checks passedNotes for the reviewer
The default value is
"content"(not"id") to match the behaviour ofDocumentMAPEvaluator,DocumentMRREvaluator, andDocumentRecallEvaluator. This is a behaviour change from the previous hardcodedidmatching, but the previous behaviour was incorrect for the common case where ground truth and retrieved documents are created independently and do not share IDs.Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.