Skip to content

Persistence: round-trip the graph with embeddings and the retrieval index #7

Description

@ronaldmannak

Motivation

GraphRAG.save(toJSON:) persists the knowledge graph, but a built index (chunk/entity embeddings + the hybrid retriever state) is thrown away between runs, so every process start re-embeds the whole corpus — expensive with a remote embedder. Persisting and reloading a built index makes startup cheap and offline-repeatable.

Scope

  • Extend save/load to round-trip chunk embeddings (and entity embeddings if present) so a reloaded graph doesn't need re-embedding.
  • Add a GraphRAG load path that reconstructs a built instance from a saved graph (rebuild the HybridRetriever index from persisted embeddings without calling the embedder).
  • Guard against embedder-dimension mismatch on load (re-embed or error clearly) — consistent with the LightRAG dimension guard already in Searchers.swift.
  • Document the save/load lifecycle.

Files (mostly isolated)

Sources/GraphRAG/Graph/KnowledgeGraph.swift (persistence), Sources/GraphRAG/GraphRAG/Engine.swift (load/rebuild), tests. Low overlap with retrieval/community work.

Acceptance criteria

  • Save then load reproduces query results without re-invoking the embedder (verifiable with a throwing/failing embedder on the load path).
  • Dimension mismatch on load is handled explicitly.
  • CI green.

Context: follow-up to PRs #2 / #3.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions