What is Memory Customization?
Memory customization (available on the Mem0 platform) allows developers to fine-tune what information their AI applications store and retrieve. This feature goes beyond traditional RAG (Retrieval-Augmented Generation) systems by providing granular control over memory storage through two main approaches: Memory Inclusion and Memory Exclusion.
Why Memory Customization Matters
Traditional RAG systems store and retrieve all available information, which can lead to noise in your AI's responses and unnecessary resource usage. Mem0's memory customization offers several key advantages:
Focused Storage: Store only the information that matters for your specific use case
Improved Accuracy: By curating memories, your AI retrieves more relevant information
Enhanced Privacy: Better control over sensitive information storage
Resource Efficiency: Optimize storage by keeping only pertinent data
Personalization: Create more targeted AI experiences
Contextual Relevance: Improve effectiveness in specialized domains
How is works
Memory Inclusion
Memory inclusion allows you to specify exactly what types of information your AI should remember. Here's a simple example:
from mem0 import MemoryClient
client = MemoryClient(api_key="xxx")
includes = "technology related things"
messages = [
{"role": "user", "content": "Hi, I'm David and I love coding in Python"},
{"role": "assistant", "content": "Great to meet you, David! Python is an excellent programming language."},
{"role": "user", "content": "I enjoy hiking on weekends"},
{"role": "assistant", "content": "Hiking is a great way to disconnect! Do you have a favorite trail?"},
{"role": "user", "content": "I collect vintage vinyl records"},
{"role": "assistant", "content": "Vinyl records are amazing! What's your favorite album in your collection?"},
{"role": "user", "content": "I build custom mechanical keyboards as a hobby"},
{"role": "assistant", "content": "Building mechanical keyboards sounds fascinating!"},
]
client.add(messages, user_id="david", includes=includes, output_format="v1.1")
{
"results": [
{
"memory": "User's name is David",
"event": "ADD"
},
{
"memory": "Codes in Python",
"event": "ADD"
},
{
"memory": "Builds custom mechanical keyboards",
"event": "ADD"
}
]
}from mem0 import MemoryClient
client = MemoryClient(api_key="xxx")
includes = "technology related things"
messages = [
{"role": "user", "content": "Hi, I'm David and I love coding in Python"},
{"role": "assistant", "content": "Great to meet you, David! Python is an excellent programming language."},
{"role": "user", "content": "I enjoy hiking on weekends"},
{"role": "assistant", "content": "Hiking is a great way to disconnect! Do you have a favorite trail?"},
{"role": "user", "content": "I collect vintage vinyl records"},
{"role": "assistant", "content": "Vinyl records are amazing! What's your favorite album in your collection?"},
{"role": "user", "content": "I build custom mechanical keyboards as a hobby"},
{"role": "assistant", "content": "Building mechanical keyboards sounds fascinating!"},
]
client.add(messages, user_id="david", includes=includes, output_format="v1.1")
{
"results": [
{
"memory": "User's name is David",
"event": "ADD"
},
{
"memory": "Codes in Python",
"event": "ADD"
},
{
"memory": "Builds custom mechanical keyboards",
"event": "ADD"
}
]
}from mem0 import MemoryClient
client = MemoryClient(api_key="xxx")
includes = "technology related things"
messages = [
{"role": "user", "content": "Hi, I'm David and I love coding in Python"},
{"role": "assistant", "content": "Great to meet you, David! Python is an excellent programming language."},
{"role": "user", "content": "I enjoy hiking on weekends"},
{"role": "assistant", "content": "Hiking is a great way to disconnect! Do you have a favorite trail?"},
{"role": "user", "content": "I collect vintage vinyl records"},
{"role": "assistant", "content": "Vinyl records are amazing! What's your favorite album in your collection?"},
{"role": "user", "content": "I build custom mechanical keyboards as a hobby"},
{"role": "assistant", "content": "Building mechanical keyboards sounds fascinating!"},
]
client.add(messages, user_id="david", includes=includes, output_format="v1.1")
{
"results": [
{
"memory": "User's name is David",
"event": "ADD"
},
{
"memory": "Codes in Python",
"event": "ADD"
},
{
"memory": "Builds custom mechanical keyboards",
"event": "ADD"
}
]
}In this example, only technology related information will be stored in the memory system.
Memory Exclusion
Conversely, you can specify what types of information to exclude:
from mem0 import MemoryClient
client = MemoryClient(api_key="xxx")
excludes = "food preferences"
messages = [
{"role": "user", "content": "Hi, I'm Emma and I work as a software developer"},
{"role": "assistant", "content": "Nice to meet you, Emma! Being a software developer is interesting."},
{"role": "user", "content": "I'm allergic to shellfish"},
{"role": "assistant", "content": "I'll make note of your shellfish allergy."},
{"role": "user", "content": "I play tennis every Wednesday"},
{"role": "assistant", "content": "Regular tennis practice is great exercise!"},
{"role": "user", "content": "I'm on a gluten-free diet"},
{"role": "assistant", "content": "I understand you follow a gluten-free diet."},
]
client.add(messages, user_id="emma", excludes=excludes, output_format="v1.1")
{
"results": [
{
"memory": "Works as a software developer",
"event": "ADD"
},
{
"memory": "Plays tennis on Wednesdays",
"event": "ADD"
}
]
}from mem0 import MemoryClient
client = MemoryClient(api_key="xxx")
excludes = "food preferences"
messages = [
{"role": "user", "content": "Hi, I'm Emma and I work as a software developer"},
{"role": "assistant", "content": "Nice to meet you, Emma! Being a software developer is interesting."},
{"role": "user", "content": "I'm allergic to shellfish"},
{"role": "assistant", "content": "I'll make note of your shellfish allergy."},
{"role": "user", "content": "I play tennis every Wednesday"},
{"role": "assistant", "content": "Regular tennis practice is great exercise!"},
{"role": "user", "content": "I'm on a gluten-free diet"},
{"role": "assistant", "content": "I understand you follow a gluten-free diet."},
]
client.add(messages, user_id="emma", excludes=excludes, output_format="v1.1")
{
"results": [
{
"memory": "Works as a software developer",
"event": "ADD"
},
{
"memory": "Plays tennis on Wednesdays",
"event": "ADD"
}
]
}from mem0 import MemoryClient
client = MemoryClient(api_key="xxx")
excludes = "food preferences"
messages = [
{"role": "user", "content": "Hi, I'm Emma and I work as a software developer"},
{"role": "assistant", "content": "Nice to meet you, Emma! Being a software developer is interesting."},
{"role": "user", "content": "I'm allergic to shellfish"},
{"role": "assistant", "content": "I'll make note of your shellfish allergy."},
{"role": "user", "content": "I play tennis every Wednesday"},
{"role": "assistant", "content": "Regular tennis practice is great exercise!"},
{"role": "user", "content": "I'm on a gluten-free diet"},
{"role": "assistant", "content": "I understand you follow a gluten-free diet."},
]
client.add(messages, user_id="emma", excludes=excludes, output_format="v1.1")
{
"results": [
{
"memory": "Works as a software developer",
"event": "ADD"
},
{
"memory": "Plays tennis on Wednesdays",
"event": "ADD"
}
]
}Use Cases
Sports Training Assistant
Imagine building an AI coach that needs to focus on athletic performance and training details. Using memory inclusion, you can ensure the AI remembers only sports-related information:
includes = "training routines, performance metrics, sports techniques"
includes = "training routines, performance metrics, sports techniques"
includes = "training routines, performance metrics, sports techniques"
Personal AI Assistant with Privacy Focus
For a personal AI assistant that handles various tasks but should avoid storing sensitive information:
excludes = "financial details, personal identification information"
excludes = "financial details, personal identification information"
excludes = "financial details, personal identification information"
Conclusion
Memory customization in Mem0 provides developers with powerful tools to create more focused, efficient, and personalized AI applications. By carefully controlling what information your AI remembers, you can build applications that are not only more resource-efficient but also more effective at their specific tasks.
View Mem0's memory customization documentation to learn more about customizing your memory. You can also reach out to us at [email protected].