feat: hybrid search with BM25 + Embedding + RRF fusion - #15
Open
effortprogrammer wants to merge 1 commit into
Open
feat: hybrid search with BM25 + Embedding + RRF fusion#15effortprogrammer wants to merge 1 commit into
effortprogrammer wants to merge 1 commit into
Conversation
- Embedder interface with sync cache for query-time embedding - OnnxEmbedder: optional onnxruntime-node, WordPiece tokenizer, mean pooling - EmbeddingSearchEngine: pre-computed tool vectors, sync cosine similarity - HybridSearchEngine + RRFStrategy: combines BM25 + embedding via RRF (k=60) - Factory: hybrid mode opt-in via RouterCoreOptions.hybrid + embedder - All query() methods remain synchronous (SearchEngine contract preserved)
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
BM25 lexical search can't distinguish 'search local files' from 'search GitHub' — tools like
grep_app:searchGitHubget selected when the user intends local code search.Solution
Hybrid search combining BM25 (lexical) + embedding (semantic) via Reciprocal Rank Fusion.
New files
Embedderinterface withembedSync()for cached sync accessOnnxEmbedderusing optionalonnxruntime-node, WordPiece tokenizer, mean pooling + L2 normalizeEmbeddingSearchEnginepre-computes tool vectors, sync cosine similarity at query timeHybridSearchEngine+RRFStrategy(k=60) combines multiple enginesModified files
RouterCoreOptions.hybrid + embedderDesign decisions
SearchEngine.query()remains synchronous — embeddings pre-computed at catalog build, only cosine similarity at query timeonnxruntime-nodeis optional — dynamic import, graceful fallbackEmbedderinterface — swap bge-small-en-v1.5 for any modelResearch
Based on: ToolRet, Tool-DE, RAG-MCP, ScaleCall papers showing hybrid retrieval significantly outperforms BM25-only for tool selection.
Usage