LightRAG: inherit GraphRAG retrieval config via lightRAG()#3
LightRAG: inherit GraphRAG retrieval config via lightRAG()#3ronaldmannak wants to merge 2 commits into
Conversation
An engine created through GraphRAG.lightRAG() now mirrors the owning instance's Config so the LightRAG path stays consistent with GraphRAG.ask/search on the same graph: - topKResults becomes the engine's defaultTopK, used when retrieve/ask are called without an explicit topK (signature is now topK: Int? = nil). - similarityThreshold is applied to semantic hits, and approach == "semantic" drops BM25 (includeKeyword: false), via a new LightRAGSearchOptions threaded into the stores. - approach == "keyword" stays rejected (LightRAG needs embeddings). Constructing LightRAGEngine directly still uses permissive defaults (full hybrid, no threshold, topK 10), so the subsystem remains usable standalone. Tests: topK inheritance (defaultTopK + capped results) and semantic-approach smoke (includeKeyword false, runs without throwing). README documents the inheritance. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VUzx3BzstYuB68txcHvAUh
There was a problem hiding this comment.
Code Review
This pull request updates LightRAGEngine to inherit retrieval settings (such as topKResults, similarityThreshold, and whether to include keywords based on the approach) from the parent GraphRAG instance's configuration, ensuring consistency across retrieval paths. Feedback suggests using Task.detached when building the searchers to offload heavy initialization work to the global concurrent pool, preventing the LightRAGStoreCache actor from being blocked.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Run the store build (community summary generation + on-demand embedding) on the global concurrent pool via Task.detached instead of a task inheriting the cache actor's executor, so the actor stays responsive to concurrent callers. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VUzx3BzstYuB68txcHvAUh
Follow-up to #2. Makes a
LightRAGEnginecreated viaGraphRAG.lightRAG()inherit the owning instance's retrievalConfig, so the LightRAG path stays consistent withGraphRAG.ask/searchon the same configured graph. (In #2, LightRAG deliberately ignored these settings; this threads them through as the more intuitive default for a factory method on a configured instance.)What's inherited
lightRAG())topKResultsdefaultTopK, used whenretrieve/askare called without an explicittopKsimilarityThresholdapproach == "semantic"includeKeyword: false) so results are semantic-onlyapproach == "keyword"How
LightRAGSearchOptions(semanticThreshold,includeKeyword) is threaded intoInMemorySemanticSearcher/LightRAG.chunkSearcher/communitySearcherand applied in theHybridRetriever.searchcall.LightRAGEnginegainssearchOptionsanddefaultTopK;retrieve/asktaketopK: Int? = niland resolve todefaultTopK.GraphRAG.lightRAG()populates both fromself.config.Constructing
LightRAGEnginedirectly still uses permissive defaults (full hybrid, no threshold,topK10), so the subsystem remains usable standalone — the inheritance only applies when derived from a configuredGraphRAG.Tests
lightRAGInheritsConfiguredTopK—withTopK(1)→engine.defaultTopK == 1and capped results.lightRAGSemanticApproachRuns—withApproach("semantic")→includeKeyword == false, engine builds and answers without throwing.README updated to document the inheritance. Offline-only, builds under Swift 6 strict concurrency.
🤖 Generated with Claude Code
https://claude.ai/code/session_01VUzx3BzstYuB68txcHvAUh
Generated by Claude Code