Repository navigation
Closed
Labels
enhancementNew feature or requestresearchResearch, methodology, ablationsretrievalRetrieval and RAGv2.0.1Planned for v2.0.1 release
Milestone
Description
Summary
Go beyond vector search: build a live, continuously-updated causal/temporal graph of entities, events, and relationships extracted from user data. Queries traverse the graph and retrieve embeddings. Think "Palantir-lite for LLM apps," deeply integrated with SynapseKit RAG.
Motivation
Vector search retrieves similar chunks. It cannot answer:
- "What caused X?"
- "Show all events involving Alice between March and May"
- "Which entities depend on the deprecated API?"
A live world model captures structure — entities, relations, time, causation. Combined with embeddings, it enables hybrid graph + semantic retrieval. This is the foundation for true "agentic memory."
Design Sketch
from synapsekit import WorldModelRAG, ExtractionPolicy
wm = WorldModelRAG(
extraction=ExtractionPolicy(
entities=[\"person\", \"org\", \"product\", \"event\", \"location\"],
relations=\"open_schema\", # or fixed list
temporal=True,
causal=True,
),
graph_backend=\"neo4j://...\", # or \"memgraph\", \"kuzu\", \"in_memory\"
vector_store=ChromaStore(...),
)
# Ingest — extracts entities, relations, timestamps continuously
await wm.ingest(docs)
# Hybrid query
result = await wm.query(
\"What did Alice work on that led to the v1.5 release?\",
strategy=\"graph_first\", # or \"vector_first\", \"hybrid\"
)
# result.subgraph -> traversed nodes/edges
# result.embeddings -> top-k chunks
# result.answer -> LLM synthesis grounded in bothPipeline
- Extract — LLM-driven entity + relation + event extraction on every ingest
- Normalize — entity resolution (Alice == Alice Chen == @alice)
- Temporal index — bitemporal model (valid time + transaction time)
- Causal links — LLM proposes causation, scored by
NeuroSymbolicAgentfor plausibility - Query — hybrid retrieval: Cypher/graph traversal + vector top-k, fused via reciprocal rank
- Incremental — schema and entity merges update without full reindex
Components
-
WorldModelRAGfacade -
EntityExtractor,RelationExtractor,EventExtractor(LLM-driven, schema-tunable) -
EntityResolver— embedding + heuristic matching -
GraphBackendinterface — Neo4j, Memgraph, Kuzu, in-memory -
HybridRetriever— graph traversal + vector merge -
TemporalIndex— bitemporal queries -
CausalLinker— proposes + scores causal edges - Visualization:
wm.subgraph_to_mermaid(query)
Use Cases
- Codebase intelligence: "who introduced this bug + which PRs touch it + what tests cover it"
- Customer 360: unified entity view across CRM + emails + tickets
- Legal/compliance discovery: timeline reconstruction with causal links
- Personal knowledge management: Obsidian-style but auto-built
Risks
- Extraction noise — bad entities pollute the graph. Mitigate with confidence thresholds + human review queue.
- Entity resolution drift — false merges are catastrophic. Conservative defaults + provenance tracking.
- Cost — extraction LLM calls are expensive. Use small fast model + batch + cache.
Acceptance Criteria
- End-to-end demo on a 10k-document corpus
- Hybrid retrieval beats pure vector search by ≥20% on a question set requiring multi-hop reasoning
- Backends: Neo4j + Kuzu + in-memory all green
- Time-travel queries work:
wm.query(..., as_of=\"2026-03-01\")
Related
- Builds on existing
RAGfacade + vector stores - Pairs with
NeuroSymbolicAgentfor causal verification
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestresearchResearch, methodology, ablationsretrievalRetrieval and RAGv2.0.1Planned for v2.0.1 release
Activity
AmitoVrito commentedon Jul 18, 2026
Status update (2026-07-18) — retargeted to v2.0.1
Checked in on this — the core is actually built, not unstarted. Progress against the acceptance criteria:
Done
WorldModelRAGfacade,ExtractionPolicy, entity/relation/event extraction (HeuristicWorldModelExtractor+LLMWorldModelExtractor)EntityResolver(embedding + heuristic matching)HybridWorldModelRetrieverfuses graph traversal + vector top-k via reciprocal rank fusionas_ofparam works end-to-end (wm.query(..., as_of=...))CausalLinkerfor causal edge scoringin_memoryandkuzu— both implemented and covered by testswm.subgraph_to_mermaid)tests/retrieval/test_world_model.pyRemaining
ExternalWorldGraphBackendis currently a stub; every method raisesRuntimeError("... not available in the core package yet"). Needs a realneo4jdriver-backed implementation to satisfy "Backends: Neo4j + Kuzu + in-memory all green."examples/world_model_rag.pyexists but is a toy example (~4 short sentences, fake embeddings/LLM). Need a real demo at the stated 10k-doc scale.Net: this is a finishing PR (Neo4j adapter + benchmark + scaled demo), not a from-scratch build. Reprioritizing accordingly.
AmitoVrito commentedon Jul 18, 2026
@Abhay-Mmmm assigning this to you — sent you a collaborator invite (check your GitHub notifications/email), and I'll set you as assignee once you accept it. See the status update above for what's remaining (Neo4j backend, 10k-doc demo, hybrid-vs-vector benchmark).
Abhay-Mmmm commentedon Jul 18, 2026
Okay great! I'll start working on this.
Abhay-Mmmm commentedon Jul 18, 2026
@AmitoVrito Design question from a code review of PR #823 (Neo4j backend + 10k-doc demo + hybrid benchmark) that I'd like your call on before I sink more time into it:
Neo4jWorldGraphBackend(and the existingKuzuWorldGraphBackend) write-through to the external store, but every read (query_subgraph,to_mermaid) is served from an in-memory dict built up during the current process'singest()calls — not native Cypher/Kuzu queries against the store itself.Consequence: no durability across process restarts, and no state sharing across processes. A second process pointed at an already-populated Neo4j instance sees an empty graph until it re-ingests everything itself.
This matches the existing Kuzu backend's convention, so it's not a new pattern — and it's called out in
docs/world-model-rag.md. But it does mean "Neo4j backend" doesn't currently deliver what a caller would typically expect from choosing a graph database (durability, multi-process access).Is the write-through-mirror behavior acceptable for closing out this issue's Neo4j acceptance criterion, or should
query_subgraphrun real Cypher traversal (bounded-hopMATCH) directly against Neo4j/Kuzu instead of the in-memory mirror? Happy to take it either way, just want to confirm before changing the read path.AmitoVrito commentedon Jul 18, 2026
Hey Abhay, good catch on this :agree it's worth fixing before we close it out.
Going with option 2: let's have query_subgraph do real bounded-hop Cypher against Neo4j instead of leaning on the in-memory mirror. Reasoning is basically that if someone picks Neo4j specifically, they're picking it for durability and multi-process reads, and the mirror-only approach quietly doesn't give them either. Since this backend hasn't shipped yet there's no compat cost to doing it right now instead of patching it later.
You don't have to build this from scratch btw: Neo4jPropertyGraphBackend.traverse() in property_graph.py already does the variable-length MATCH pattern with confidence/type filtering, so it should mostly be a port. Keep the write-through for upsert_entity/upsert_relation, just swap the read path (query_subgraph + to_mermaid) to pull from a live query instead of self.nodes/self.edges.
Leaving Kuzu alone for this PR: it's already out there with the mirror behavior documented, so changing it now feels like a separate piece of work. I'll open a follow-up issue for that one so it doesn'tet lost.
Ping me if the Cypher gets gnarly, happy to pair on it.
fix(retrieval): make Neo4j world-graph reads live Cypher, not the in-…
Abhay-Mmmm commentedon Jul 19, 2026
Added the change and pushed @AmitoVrito
feat(retrieval): finish WorldModelRAG — Neo4j backend, 10k-doc demo, …