feat(retrieval): BM25 hybrid retrieval with reciprocal rank fusion#11
Open
AyushAnand413 wants to merge 2 commits into
Open
feat(retrieval): BM25 hybrid retrieval with reciprocal rank fusion#11AyushAnand413 wants to merge 2 commits into
AyushAnand413 wants to merge 2 commits into
Conversation
Replace single-pass FAISS dense retrieval with a hybrid pipeline: - FAISS (dense) + BM25Okapi (sparse) each fetch `initial_top_k` candidates - Results are merged via Reciprocal Rank Fusion (k=60) - Final ranked list preserves the same output schema consumed by Reranker - rank_bm25==0.2.2 added to requirements.txt Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Covers _tokenize, _reciprocal_rank_fusion edge cases, and BM25 scoring without requiring faiss or sentence_transformers in the test environment. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
BM25Okapi(sparse) retrieval alongside existing FAISS (dense) inretrieval/retriever.pyinitial_top_kcandidates; results merged with Reciprocal Rank Fusion (k=60) — parameter-free, robust to score-scale differences between sparse and dense signalsinitial_top_kand passed toRerankerunchanged — zero breaking changes downstreamrank_bm25==0.2.2added torequirements.txtHow it works
Tests
10 new unit tests in
tests/test_hybrid_retrieval.pycovering:_tokenizeedge cases_reciprocal_rank_fusion(single list, agreement boost, exclusive chunks, empty input, custom k)All 10 pass without requiring
faissorsentence_transformersin the test environment.Test plan
pip install rank_bm25==0.2.2pytest tests/test_hybrid_retrieval.py→ 10 passed🤖 Generated with Claude Code