You’ll use this when…
- Conversation history mixes multiple actors and objects that vectors alone blur together
- Compliance or auditing demands a graph of who said what and when
- Agent teams need shared context without duplicating every memory in each run
How Graph Memory Maps Context
Mem0 extracts entities and relationships from every memory write, stores embeddings in your vector database, and mirrors relationships in a graph backend. On retrieval, vector search narrows candidates, then the graph supplies context and re-ranks results.Graph Memory complements your vector store. Keep both healthy to avoid blind spots.
How It Works
1
Extract people, places, and facts
Mem0’s extraction LLM identifies entities, relationships, and timestamps from the conversation payload you send to
memory.add.2
Store vectors and edges together
Embeddings land in your configured vector database while nodes and edges flow into a Bolt-compatible graph backend (Neo4j, Memgraph, Neptune, or Kuzu).
3
Blend graph context at search time
memory.search first performs vector similarity, then follows connected nodes to boost (or filter) answers before optionally handing results to a reranker.Quickstart (Neo4j Aura)
Time to implement: ~10 minutes · Prerequisites: Python 3.10+, Node.js 18+, Neo4j Aura DB (free tier)
- Python
- TypeScript
1
Install Mem0 with graph extras
2
Export Neo4j credentials
3
Add and recall a relationship
Expect to see Alice met Bob at GraphConf 2025 in the output. In Neo4j Browser run
MATCH (p:Person)-[r]->(q:Person) RETURN p,r,q LIMIT 5; to confirm the edge exists.Operate Graph Memory Day-to-Day
Refine extraction prompts
Refine extraction prompts
Guide which relationships become nodes and edges.
Raise the confidence threshold
Raise the confidence threshold
Keep noisy edges out of the graph by demanding higher extraction confidence.
Toggle graph writes per request
Toggle graph writes per request
Disable graph writes or reads when you only want vector behaviour.
Organize multi-agent graphs
Organize multi-agent graphs
Separate or share context across agents and sessions with
user_id, agent_id, and run_id.Monitor graph growth, especially on free tiers, by periodically cleaning dormant nodes:
MATCH (n) WHERE n.lastSeen < date() - duration('P90D') DETACH DELETE n.Troubleshooting
Neo4j connection refused
Neo4j connection refused
Confirm Bolt connectivity is enabled, credentials match Aura, and your IP is allow-listed. Retry after confirming the URI format is
neo4j+s://....Neptune Analytics rejects requests
Neptune Analytics rejects requests
Ensure the graph identifier matches the vector dimension used by your embedder and that the IAM role allows
neptune-graph:*DataViaQuery actions.Graph store outage fallback
Graph store outage fallback
Catch the provider error and retry with
enable_graph=False so vector-only search keeps serving responses while the graph backend recovers.Decision Points
- Select the graph store that fits your deployment (managed Aura vs. self-hosted Neo4j vs. AWS Neptune vs. local Kuzu).
- Decide when to enable graph writes per request; routine conversations may stay vector-only to save latency.
- Set a policy for pruning stale relationships so your graph stays fast and affordable.
Provider setup
Choose your backend and expand the matching panel for configuration details and links.Neo4j Aura or self-hosted
Neo4j Aura or self-hosted
Install the APOC plugin for self-hosted deployments, then configure Mem0:Additional docs: Neo4j Aura Quickstart, APOC installation.
Memgraph (Docker)
Memgraph (Docker)
Run Memgraph Mage locally with schema introspection enabled:Then point Mem0 at the instance:Learn more: Memgraph Docs.
Amazon Neptune Analytics
Amazon Neptune Analytics
Match vector dimensions between Neptune and your embedder, enable public connectivity (if needed), and grant IAM permissions:Reference: Neptune Analytics Guide.
Amazon Neptune DB (with external vectors)
Amazon Neptune DB (with external vectors)
Create a Neptune cluster, enable the public endpoint if you operate outside the VPC, and point Mem0 at the host:Reference: Accessing Data in Neptune DB.
Kuzu (embedded)
Kuzu (embedded)
Kuzu runs in-process, so supply a path (or Kuzu will clear its state when using
:memory:) for the database file::memory: once the process exits. See the Kuzu documentation for advanced settings.