fix(rerank): filter empty docs before rerank API; concurrent read_batch#2619
Open
njuboy11 wants to merge 1 commit into
Open
fix(rerank): filter empty docs before rerank API; concurrent read_batch#2619njuboy11 wants to merge 1 commit into
njuboy11 wants to merge 1 commit into
Conversation
…d_batch 1. openai_rerank.py: Filter out empty/blank documents before sending to rerank API (SiliconFlow drops empty docs, causing result count mismatch). Map results back to original indices with 0.0 score for empty docs. 2. viking_fs.py: Make read_batch truly concurrent with asyncio.gather instead of sequential file reads. Added Tuple to typing imports. These two issues combined could add 3-5s to search latency with 24 candidates (empty doc causes rerank fallback + serial file reads).
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨No code suggestions found for the PR. |
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.
Problem
Two issues causing slow search (up to 8.3s worst-case):
1. Reranker fails when documents contain empty strings
SiliconFlow API silently drops empty documents from results. When one of N documents has an empty string, the API returns N-1 results. The client detects the count mismatch and falls back to vector scores, wasting the API call entirely (approximately 180ms per call, plus worse result quality).
Log evidence:
2. read_batch reads files sequentially
VikingFS.read_batch() loops through URIs sequentially with await self.abstract() for each file. For 24 candidates each with up to 5 relations, that is up to 120 serial file reads.
Fix
openai_rerank.py
viking_fs.py
Test Results
Before:
After:
Reranker now works correctly - no more "Invalid rerank result" warnings.