Overview
Enhance your memory system with graph-based knowledge representation and retrieval
Mem0 now supports Graph Memory. With Graph Memory, users can now create and utilize complex relationships between pieces of information, allowing for more nuanced and context-aware responses. This integration enables users to leverage the strengths of both vector-based and graph-based approaches, resulting in more accurate and comprehensive information retrieval and generation.
Installation
To use Mem0 with Graph Memory support, install it using pip:
This command installs Mem0 along with the necessary dependencies for graph functionality.
Try Graph Memory on Google Colab.
Initialize Graph Memory
To initialize Graph Memory you’ll need to set up your configuration with graph store providers.
Currently, we support Neo4j as a graph store provider. You can setup Neo4j locally or use the hosted Neo4j AuraDB.
Moreover, you also need to set the version to v1.1
(prior versions are not supported).
User can also customize the LLM for Graph Memory from the Supported LLM list with three levels of configuration:
- Main Configuration: If
llm
is set in the main config, it will be used for all graph operations. - Graph Store Configuration: If
llm
is set in the graph_store config, it will override the main configllm
and be used specifically for graph operations. - Default Configuration: If no custom LLM is set, the default LLM (
gpt-4o-2024-08-06
) will be used for all graph operations.
Here’s how you can do it:
Graph Operations
The Mem0’s graph supports the following operations:
Add Memories
Get all memories
Search Memories
Delete all Memories
Example Usage
Here’s an example of how to use Mem0’s graph operations:
- First, we’ll add some memories for a user named Alice.
- Then, we’ll visualize how the graph evolves as we add more memories.
- You’ll see how entities and relationships are automatically extracted and connected in the graph.
Add Memories
Below are the steps to add memories and visualize the graph:
Add memory 'I like going to hikes'
Add memory 'I love to play badminton'
Add memory 'I hate playing badminton'
Add memory 'My friend name is john and john has a dog named tommy'
Add memory 'My name is Alice'
Add memory 'John loves to hike and Harry loves to hike as well'
Add memory 'My friend peter is the spiderman'
Search Memories
Below graph visualization shows what nodes and relationships are fetched from the graph for the provided query.
Note: The Graph Memory implementation is not standalone. You will be adding/retrieving memories to the vector store and the graph store simultaneously.
If you want to use a managed version of Mem0, please check out Mem0. If you have any questions, please feel free to reach out to us using one of the following methods: