Fix HybridRetriever cutoff and KeyError with small collections#49
Open
tavian-dev wants to merge 1 commit intoAmenRa:mainfrom
Open
Fix HybridRetriever cutoff and KeyError with small collections#49tavian-dev wants to merge 1 commit intoAmenRa:mainfrom
tavian-dev wants to merge 1 commit intoAmenRa:mainfrom
Conversation
Two fixes: 1. Sub-retrievers in search() and msearch() used a hardcoded cutoff of 1000. When the collection has fewer documents, the dense retriever (faiss) returns -1 for missing entries, causing KeyError in map_internal_ids_to_original_ids. Now uses max(cutoff, 1000) so the sub-cutoff respects the user's requested cutoff while still fetching enough candidates for fusion. 2. map_internal_ids_to_original_ids now filters out -1 entries as a safety net, since faiss can return -1 when k exceeds the index size. Fixes AmenRa#29, fixes AmenRa#33
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.
Summary
Fixes two related issues in HybridRetriever:
Issue #29 —
KeyError: -1when collection has fewer than 1000 documents:search()andmsearch()passed a hardcoded cutoff of 1000 to sub-retrieversmap_internal_ids_to_original_idsthen fails withKeyError: -1map_internal_ids_to_original_idsas a safety netIssue #33 — cutoff not passed to sub-retrievers:
cutoffparameter was only applied after fusion, not to the sub-retriever callsmax(cutoff, 1000)so sub-retrievers respect large cutoffs while still fetching enough candidates for fusion qualityChanges
base_retriever.py:map_internal_ids_to_original_idsnow skips -1 entrieshybrid_retriever.py:search()andmsearch()usemax(cutoff, 1000)for sub-retrieversFixes #29, fixes #33