Compare · Backends

Vector Database vs Knowledge Graph for AI Memory

Vector databases find agent memories by semantic similarity; knowledge graphs store memories as connected, time-aware facts and relationships — use vectors for “what’s similar,” graphs for “what relates and when it was true.”

Vectors

“What’s semantically similar?”

Graphs

“What relates, and when was it true?”

Vectors

How vector memory works for agents

Text/facts → embed → store vectors → similarity search at retrieval.

Strengths: fast semantic recall, simple schema, scales with embeddings. Weaknesses: weak explicit relationships, temporal validity harder, similar ≠ correct. Examples: Engram, Mem0, pgvector, Pinecone.

Vector databases for AI memory

Graphs

How knowledge-graph memory works for agents

Extract entities/relations → store nodes/edges with timestamps → traverse + query at retrieval.

Strengths: relationships, temporal validity, conflict resolution. Weaknesses: heavier extraction, graph ops, setup cost. Examples: Zep/Graphiti (arXiv:2501.13956), Cognee. Zep LongMemEval +18.5% vs baseline (Rasmussen et al., 2025).

Knowledge graphs for temporal memory

Comparison

Vector vs knowledge graph: comparison table

Vectors for similarity; graphs for structure and time.

DimensionVector-onlyKG-onlyHybrid (Zep-style)
Query typeSemantic similarityRelationship traversalBoth
Temporal factsMetadata versioningNative bi-temporalGraph-native
Relationship queriesWeakStrongStrong
Setup complexityLowHighMedium–high
Best frameworksEngram, Mem0Cognee, GraphitiZep
LOCOMO JMem0 66.9N/A (varies)Zep 66.0

Choose vectors

When to choose vector memory

  • Conversational user preferences
  • Semantic recall sufficient
  • Team knows vector DBs
  • Engram or Mem0 fit
  • Speed to POC matters

Engram explained

Choose graphs

When to choose knowledge-graph memory

  • Facts change over time
  • Entity relationships matter
  • CRM/policy versioning
  • Need “invalidated at T” queries
  • Conflict resolution required

Zep alternatives

Hybrid

Hybrid vector + graph memory

Vectors for recall + graph for structure/temporal metadata — many production systems use both.

Engram uses Weaviate hybrid (vector + BM25) for semantic recall. Zep combines Graphiti graph traversal with vector search for temporal edges. DIY: pgvector + Neo4j sidecar.

Hybrid search for memory retrieval

By type

Vector vs KG by memory type

Memory typeRecommended backend
Episodic chunksVectors (often)
Semantic facts with relationshipsGraphs
User preferencesVectors (Engram, Mem0)
CRM timelinesGraphs (Zep)
Procedural/tool memoryEither

Episodic memory · Semantic memory

FAQ

Frequently asked questions

Is a vector database enough for agent memory?

Yes for many workloads — conversational preferences, semantic recall, fast POC. Engram and Mem0 are vector-first (LOCOMO J 66.9 for Mem0). Graphs add value when relationships and temporal validity matter.

When do you need a knowledge graph for agent memory?

When facts change over time, entity relationships matter, CRM/policy versioning is required or conflict resolution needs bi-temporal invalidation. Zep/Graphiti is the reference.

Is Zep vector or graph memory?

Both — Zep uses Graphiti temporal knowledge graph with hybrid vector search. LOCOMO J 66.0, LongMemEval +18.5% vs baseline (Rasmussen et al., 2025).

Is Engram vector or graph memory?

Vector-native on Weaviate with hybrid search (vector + BM25). Not graph-first. For temporal graphs, compare Zep. See Engram explained.

Can you use both vector and graph memory?

Yes — hybrid is common. Zep combines both natively. DIY: pgvector + Neo4j sidecar.

Graph vs vector for RAG?

RAG typically uses vectors for document chunks. Graphs add value when documents have evolving entity relationships. See memory vs RAG.

Temporal memory without a knowledge graph?

Possible with metadata versioning on vector stores (valid_from/valid_to fields) but weaker than native bi-temporal graphs. See conflicting memories.

pgvector vs Neo4j for agent memory?

pgvector for semantic similarity in Postgres. Neo4j for relationship traversal and temporal graphs. Many teams use both.

Does Mem0 have graph mode?

Mem0 is primarily vector-semantic. For native temporal graphs compare Zep or Cognee. Engram is vector-native on Weaviate.

How do you benchmark vector vs graph memory?

Run LOCOMO and LongMemEval on your domain. Compare recall@k, latency and setup cost. See memory metrics.