Why a dictionary is not memory
The obvious fix is a dictionary keyed by user. It works for about ten minutes, and the ways it breaks are exactly the features Mem0 has.
Here is that first attempt. Everything the customer says gets stored under his name.
NOTES = {}
def remember(user, said):
NOTES.setdefault(user, []).append(said)
def recall(user, about):
return [note for note in NOTES.get(user, []) if about in note]
remember("ravi", "I prefer email updates, not SMS.")
remember("ravi", "Thanks!")
print(recall("ravi", "email"))It stored the useful sentence and it found it. It also stored Thanks!, which is not a memory, and it found the note only because the question happened to use the word email.
The first break: the question uses different words
print(recall("ravi", "contact"))
print(recall("ravi", "how should we reach him"))Nothing. The fact is sitting right there and a substring search cannot reach it, because nobody says email when they ask how to contact someone. Matching text is not the same as matching meaning, and that gap is what an embedder closes.
The second break: facts change
Ravi changes his mind and asks for SMS after all. The dictionary now holds both, contradicting each other, and neither is marked as the current one. Whatever you search for, you get an answer that might be a year out of date.
The third break: it never stops growing
Every thanks, every ok, every greeting is in there forever. After a thousand conversations the useful facts are a tiny fraction of the pile, and every search has to wade through the rest.
| The dictionary | What Mem0 does instead | Lesson |
|---|---|---|
| Stores every sentence | Asks a model what is worth keeping | 5 and 8 |
| Matches substrings | Matches meaning, through an embedder | 6 and 9 |
| Keeps contradictions | Updates the memory that changed | 15 |
| One flat list per user | Scoped by user, agent and run, and tagged | 12 and 13 |
| No record of changes | A history for every memory | 16 |
- Add
remember("ravi", "Actually SMS is fine.")and runrecall("ravi", "SMS"). Decide which of the two answers is true. - Try to write
recallso that contact finds the email note, without listing synonyms by hand. - Count how many of the sentences in your last support chat were worth storing.
You understood something today that you didn't yesterday.