Skip to content

LightRAG: inherit GraphRAG retrieval config via lightRAG()#3

Open
ronaldmannak wants to merge 2 commits into
mainfrom
claude/graphrag-rs-port-j0im9e
Open

LightRAG: inherit GraphRAG retrieval config via lightRAG()#3
ronaldmannak wants to merge 2 commits into
mainfrom
claude/graphrag-rs-port-j0im9e

Conversation

@ronaldmannak

Copy link
Copy Markdown
Contributor

Follow-up to #2. Makes a LightRAGEngine created via GraphRAG.lightRAG() inherit the owning instance's retrieval Config, so the LightRAG path stays consistent with GraphRAG.ask/search on 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

Config setting Effect on LightRAG (via lightRAG())
topKResults Becomes the engine's defaultTopK, used when retrieve/ask are called without an explicit topK
similarityThreshold Applied to semantic (cosine) hits in both stores
approach == "semantic" Drops BM25 (includeKeyword: false) so results are semantic-only
approach == "keyword" Still rejected — LightRAG's dual-level design requires embeddings

How

  • New LightRAGSearchOptions (semanticThreshold, includeKeyword) is threaded into InMemorySemanticSearcher / LightRAG.chunkSearcher / communitySearcher and applied in the HybridRetriever.search call.
  • LightRAGEngine gains searchOptions and defaultTopK; retrieve/ask take topK: Int? = nil and resolve to defaultTopK.
  • GraphRAG.lightRAG() populates both from self.config.

Constructing LightRAGEngine directly still uses permissive defaults (full hybrid, no threshold, topK 10), so the subsystem remains usable standalone — the inheritance only applies when derived from a configured GraphRAG.

Tests

  • lightRAGInheritsConfiguredTopKwithTopK(1)engine.defaultTopK == 1 and capped results.
  • lightRAGSemanticApproachRunswithApproach("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

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread Sources/GraphRAG/LightRAG/LightRAGEngine.swift Outdated
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants