feat: optional BM25+vector hybrid entity seeding with RRF fusion#3377
Open
BigStartByXuyb wants to merge 1 commit into
Open
feat: optional BM25+vector hybrid entity seeding with RRF fusion#3377BigStartByXuyb wants to merge 1 commit into
BigStartByXuyb wants to merge 1 commit into
Conversation
Add an optional BM25 keyword index over entity names as a parallel seed path beside vector search in LightRAG's local retrieval, fused via Reciprocal Rank Fusion. Targets jargon/acronym queries where dense embeddings fail to seed the graph. Key changes: - New storage role KEYWORD_STORAGE with BaseKeywordStorage interface - Bm25KeywordStorage impl backed by optional bm25s library + TiktokenTokenizer - RRF fusion helper (fuse_seed_rankings) merges vector + BM25 ranked lists - Query integration: QueryParam.enable_bm25_seeding flag (off by default) - Rebuild hook on insert and entity delete - Server config: LIGHTRAG_KEYWORD_STORAGE + ENABLE_BM25_SEEDING env vars - 25 tests, zero behavior change when disabled Refs: HKUDS#3198
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.
Sorry, my English isn't very good. The following introduction was translated with the help of Claude. The commits were merged into one.
Summary
Adds an optional BM25 keyword index over entity names as a parallel seed path beside vector search in
_get_node_data. Targets the exact failure mode in #3198: jargon/acronym queries where dense embeddings fail to seed the knowledge graph.enable_bm25_seeding=Truebm25sis an optional dependency (lazy import, graceful degradation)What's Changed
BaseKeywordStorageBm25KeywordStoragefuse_seed_rankingsQueryParam.enable_bm25_seedingflag, threaded through query chainLIGHTRAG_KEYWORD_STORAGE+ENABLE_BM25_SEEDINGenv varsDesign Decisions
Test Plan
ruff check .cleanQueryParam().enable_bm25_seeding == FalseconfirmedCloses #3198