|
| 1 | +--- |
| 2 | +title: Memory Customization |
| 3 | +description: 'Mem0 supports customizing the memories you store, allowing you to focus on pertinent information while omitting irrelevant data.' |
| 4 | +--- |
| 5 | + |
| 6 | +## Benefits of Memory Customization |
| 7 | + |
| 8 | +Memory customization offers several key benefits: |
| 9 | + |
| 10 | +• **Focused Storage**: Store only relevant information for a streamlined system. |
| 11 | + |
| 12 | +• **Improved Accuracy**: Curate memories for more accurate and relevant retrieval. |
| 13 | + |
| 14 | +• **Enhanced Privacy**: Exclude sensitive information for better privacy control. |
| 15 | + |
| 16 | +• **Resource Efficiency**: Optimize storage and processing by keeping only pertinent data. |
| 17 | + |
| 18 | +• **Personalization**: Tailor the experience to individual user preferences. |
| 19 | + |
| 20 | +• **Contextual Relevance**: Improve effectiveness in specialized domains or applications. |
| 21 | + |
| 22 | +These benefits allow users to fine-tune their memory systems, creating a more powerful and personalized AI assistant experience. |
| 23 | + |
| 24 | + |
| 25 | +## Memory Inclusion |
| 26 | +Users can define specific kinds of memories to store. This feature enhances memory management by focusing on relevant information, resulting in a more efficient and personalized experience. |
| 27 | +Here’s how you can do it: |
| 28 | + |
| 29 | +```python |
| 30 | +from mem0 import MemoryClient |
| 31 | + |
| 32 | +m = MemoryClient(api_key="xxx") |
| 33 | + |
| 34 | +# Define what to include |
| 35 | +includes = "sports related things" |
| 36 | + |
| 37 | +messages = [ |
| 38 | + {"role": "user", "content": "Hi, my name is Alice and I love to play badminton"}, |
| 39 | + {"role": "assistant", "content": "Nice to meet you, Alice! Badminton is a great sport."}, |
| 40 | + {"role": "user", "content": "I love music festivals"}, |
| 41 | + {"role": "assistant", "content": "Music festivals are exciting! Do you have a favorite one?"}, |
| 42 | + {"role": "user", "content": "I love eating spicy food"}, |
| 43 | + {"role": "assistant", "content": "Spicy food is delicious! What's your favorite spicy dish?"}, |
| 44 | + {"role": "user", "content": "I love playing baseball with my friends"}, |
| 45 | + {"role": "assistant", "content": "Baseball with friends sounds fun!"}, |
| 46 | +] |
| 47 | +``` |
| 48 | + |
| 49 | +<CodeGroup> |
| 50 | +```python Code |
| 51 | +client.add("I love music festivals", user_id="alice", includes=includes) |
| 52 | +``` |
| 53 | + |
| 54 | +```json Stored Memories |
| 55 | +User's name is Alice. |
| 56 | +Alice loves to play badminton. |
| 57 | +User loves playing baseball with friends. |
| 58 | +``` |
| 59 | +</CodeGroup> |
| 60 | + |
| 61 | + |
| 62 | + |
| 63 | + |
| 64 | +## Memory Exclusion |
| 65 | + |
| 66 | +In addition to specifying what to include, users can also define exclusion rules for their memory management. This feature allows for fine-tuning the memory system by instructing it to omit certain types of information. |
| 67 | +Here’s how you can do it: |
| 68 | + |
| 69 | +```python |
| 70 | +from mem0 import MemoryClient |
| 71 | + |
| 72 | +m = MemoryClient(api_key="xxx") |
| 73 | + |
| 74 | +# Define what to exclude |
| 75 | +excludes = "food preferences" |
| 76 | + |
| 77 | +messages = [ |
| 78 | + {"role": "user", "content": "Hi, my name is Alice and I love to play badminton"}, |
| 79 | + {"role": "assistant", "content": "Nice to meet you, Alice! Badminton is a great sport."}, |
| 80 | + {"role": "user", "content": "I love music festivals"}, |
| 81 | + {"role": "assistant", "content": "Music festivals are exciting! Do you have a favorite one?"}, |
| 82 | + {"role": "user", "content": "I love eating spicy food"}, |
| 83 | + {"role": "assistant", "content": "Spicy food is delicious! What's your favorite spicy dish?"}, |
| 84 | + {"role": "user", "content": "I love playing baseball with my friends"}, |
| 85 | + {"role": "assistant", "content": "Baseball with friends sounds fun!"}, |
| 86 | +] |
| 87 | +``` |
| 88 | + |
| 89 | +<CodeGroup> |
| 90 | +```python Code |
| 91 | +client.add(messages, user_id="alice", includes=includes) |
| 92 | +``` |
| 93 | + |
| 94 | +```json Stored Memories |
| 95 | +User's name is Alice. |
| 96 | +Alice loves to play badminton. |
| 97 | +Loves music festivals. |
| 98 | +User loves playing baseball with friends. |
| 99 | +``` |
| 100 | +</CodeGroup> |
| 101 | + |
| 102 | + |
| 103 | + |
| 104 | +If you have any questions, please feel free to reach out to us using one of the following methods: |
| 105 | + |
| 106 | +<Snippet file="get-help.mdx" /> |
0 commit comments