Step 06 of 22
Knowledge graphs & memory
Store entities and relationships, and an agent's memory over time. Vectors find similar text; graphs answer "how is A connected to B" and "what changed since". Useful, but often overkill.
How to choose
- Questions about relationships across many documents: GraphRAG-style indexing.
- Agents that must remember users and facts over time: a temporal graph or memory layer.
- Plain Q&A over documents: skip the graph until vector search provably falls short.
What to look for
The questions that separate the options, in order of how much they matter.
01
Prove you need a graph first
Graphs help with questions that follow relationships (who supplies whom, which contracts cite which clause) or span a whole corpus (what are the main themes). Build an evaluation set from real questions and run it against hybrid vector search first. If few questions fail for relationship reasons, a graph adds cost and moving parts without much gain: in the GraphRAG-Bench study, LightRAG sent about 100,000 prompt tokens per question to the answering model against under 1,000 for vector RAG.
02
Indexing cost and how updates work
Every graph RAG tool sends your documents through a language model to extract entities and relationships, so indexing costs far more than embedding. Microsoft GraphRAG also writes community summaries and largely rebuilds when documents change; LightRAG skips the summaries and adds documents incrementally; Graphiti ingests episode by episode. Estimate tokens for your whole corpus with your extraction model, then ask what happens when a tenth of it changes next month.
03
Time: facts that change
Agent memory has a problem document RAG rarely does: facts go stale. A user moves house, a policy is replaced. Graphiti records when each fact became true and when it was invalidated, so an agent can answer what is true now and what was true then. Mem0 and most graph RAG pipelines simply add new facts beside old ones, and Cognee's time-awareness is newer. If your agent runs for months, test contradiction handling explicitly.
04
Storage backend and what you must operate
Pipelines and memory layers sit on top of a store. Graphiti needs Neo4j, FalkorDB or Amazon Neptune; LightRAG's in-memory defaults are for testing only and it recommends Postgres for production; GraphRAG writes files and a LanceDB index by default; Cognee defaults to embedded stores but can move to Postgres or Neo4j. Choose a tool whose production backend you already run or are willing to run.
05
Extraction model quality and structured output
Graph quality depends on the model doing extraction. Small local models miss relationships and duplicate entities, and Graphiti's README warns that models without reliable structured output can break ingestion. LightRAG suggests a 30B-class model as a practical local minimum. Budget for a capable model at indexing time and check entity deduplication on a sample before indexing everything.
06
Read memory benchmarks with care
Agent-memory products cite LoCoMo, LongMemEval, Deep Memory Retrieval and BEAM. Almost every published figure comes from the vendor, often for its hosted service rather than the open-source SDK, with different models and settings per run. Use them to shortlist, then score each candidate on a replay of your own conversations, measuring accuracy on changed facts and retrieval latency.
07
Licence and open-core splits
GraphRAG and LightRAG are MIT; Graphiti, Mem0 and Cognee are Apache 2.0; Neo4j Community Edition is GPLv3 and single-server, with clustering and role-based security only in paid editions. Several projects keep key features for their hosted product: Mem0's graph memory is platform-only, and Cognee's production extractor and Postgres graph store sit in a licensed product. Check that the feature you need is in the open edition.
How the options differ
Three different kinds of tool share this shelf. A graph database (Neo4j) is storage: nodes, relationships and a query language (Cypher), now with vector indexes too. It does nothing to your documents on its own; you, or a pipeline, decide what goes in. A GraphRAG indexing pipeline (Microsoft GraphRAG, LightRAG, and the knowledge-graph option in RAGFlow) reads a document collection with a language model, extracts entities and relationships into a graph, and answers questions over it; GraphRAG adds community summaries for whole-corpus questions, LightRAG trades those for cheaper incremental updates.
An agent memory layer (Graphiti, Mem0, Cognee) is built for conversations rather than document collections: it extracts facts as an agent talks and works, stores them across sessions and retrieves the relevant ones later. Graphiti keeps a temporal graph that tracks when facts changed, Mem0 is the simplest per-user memory API, and Cognee builds one shared graph from many sources for several agents. Pipelines and memory layers usually run on top of a store such as Neo4j or Postgres, so the choice is often one of each.
7 tools, compared
Ranked by our rating. Open any review for sources, prices and the full verdict.
| Tool | Rating | Our verdict | Best for | Price |
|---|---|---|---|---|
| Graphitirepo | 4.3/5 | For agents whose facts change over time, Graphiti is the open-source memory layer to beat, provided you will run a graph database and pay for LLM extraction on every write. | Teams building long-running agents that must remember changing facts about users, accounts or the world. | Free and open source under Apache 2.0. You supply the graph database and pay for LLM and embedding calls during ingestion. |
| Neo4jrepo | 4.1/5 | The default graph store when your RAG or agent memory genuinely needs relationships, but the free edition stops at one server and most RAG does not need a graph at all. | Teams whose RAG or agent-memory questions depend on relationships between entities, and who need a proven graph store. | Community Edition free under GPLv3. Enterprise by quote. AuraDB: Free tier; Professional $0.09/GB/hour (1 GB minimum); Business Critical $0.20/GB/hour (2 GB minimum). |
| Mem0repo | 4.0/5 | Mem0 is still the quickest way to give an agent a memory, but the open-source SDK is increasingly the trial version of a platform that keeps graph memory and the best benchmark scores for itself. | Developers adding cross-session user memory to chatbots and agents. | Open-source SDK free under Apache 2.0. Platform: Hobby free (10k adds, 1k retrievals/month); Starter $19/month; Pro $249/month (500k adds, 50k retrievals, graph memory); Enterprise custom. |
| RAGFlowrepo | 4.0/5 | A finished document-to-answer product you can run on one server, whose security record says it belongs behind a VPN rather than on the open internet. | Teams that want a self-hosted document Q&A and knowledge assistant without building a pipeline. | Free and open source under the Apache 2.0 licence. You pay for the server and the model calls. |
| LightRAGrepo | 3.9/5 | The sensible way to try graph RAG, cheaper to maintain than Microsoft GraphRAG, but most teams should prove they need a graph before adding one. | Teams whose evaluations show multi-hop questions failing with hybrid search and who want a graph on Postgres. | Free and open source under the MIT license. Indexing and queries use your own LLM and embedding credits. |
| Cogneerepo | 3.8/5 | Cognee builds a shared knowledge graph from almost any source, but its defaults need an owner before they meet production. | Teams building several agents that need a shared knowledge graph assembled from many sources. | Open source under Apache 2.0. Cognee Cloud: free up to 1M tokens and one workspace, then $1 per 1M tokens plus $5 per extra workspace a month; Enterprise is a quoted BYOC engagement. |
| GraphRAGrepo | 3.5/5 | Still the reference design for whole-corpus questions, but Microsoft has stopped developing it and the indexing bill is as large as ever. | Teams with a fixed, high-value document set where cross-document questions justify a costly one-off index. | Free and open source under the MIT licence. Indexing runs on your own OpenAI or Azure OpenAI credits, which the README warns can be expensive. |
Side by side
The specifications that matter for this step. Checked 2026-10-23; confirm on the vendor’s site before you commit.
| Tool | What it is | Storage backend | Temporal awareness | Query interface | Licence |
|---|---|---|---|---|---|
| Graphiti | Temporal agent memory layer | Neo4j, FalkorDB or Amazon Neptune | Yes, valid/invalid times per fact | Python API: vector + BM25 + graph | Apache 2.0 |
| Neo4j | Graph database | Native graph store + vector index | No built-in fact versioning | Cypher | GPLv3 Community; commercial |
| Mem0 | Agent memory layer | Qdrant default; 20+ vector stores | No proper handling of changes | Python/TS SDK: add and search | Apache 2.0 (graph is paid) |
| RAGFlow | RAG engine with graph option | Elasticsearch (default) or Infinity | No | Web UI, REST, Python SDK | Apache 2.0 |
| LightRAG | GraphRAG indexing pipeline | Postgres recommended; Neo4j etc. | No; incremental updates | Python, REST: five query modes | MIT |
| Cognee | Agent memory layer (shared graph) | Ladybug + LanceDB + SQLite default | Partial; newer than Graphiti's | Python, CLI, REST, MCP: recall | Apache 2.0 |
| GraphRAG | GraphRAG indexing pipeline | Files + LanceDB (default); Azure | No; rebuild on change | Python/CLI: global, local search | MIT |
Connect it to your agent
MCP servers that let assistants like Claude, ChatGPT and Cursor use these tools directly.
Where this stage fits
- Research & knowledge graph: we would start with GraphRAG, Neo4j.
- Assistant with long-term memory: we would start with Graphiti, Mem0.
Sources for this guide
- Microsoft GraphRAG configuration
- Graphiti on GitHub
- Zep: temporal knowledge graph architecture (arXiv)
- LightRAG README (storage)
- Neo4j: vector search with filters
- Mem0 docs: vector databases
- Cognee on GitHub
- RAGFlow docs: construct knowledge graph
- Atlan: best AI agent memory frameworks 2026
- When to use Graphs in RAG (GraphRAG-Bench, arXiv)