Mem0mem0ai 2.0.20 · Python 3.10+
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
24 small wins to finish your pathNext lesson

An assistant that forgets

Before Mem0 exists, here is the problem it solves. A small support assistant, two conversations, and a customer repeating himself.

The assistant is a dictionary and a loop. It is not a model, and that is on purpose: for the next few lessons the point is the memory, not the answering.

Example
REPLIES = {
    "late": "Sorry about that. I can chase order A17 for you.",
    "update": "I can send you updates about your order.",
}

def reply(said):
    for word, answer in REPLIES.items():
        if word in said.lower():
            return answer
    return "I can help with orders and refunds."

print(reply("My order is late again."))
print(reply("Can you send me an update?"))

It answers both. Now run it again tomorrow, which in code means calling it again with nothing carried over.

What it never learns

Ravi said something important in the first conversation: he wants email rather than SMS. Watch what the assistant does with that.

Example
print(reply("I prefer email updates, not SMS."))
print(reply("Can you send me an update?"))

The second answer offers to send updates without saying how, because the assistant has no idea what was said one line earlier. Nothing was stored, so nothing could be used.

What is actually needed

You could write this yourself, and people do. The hard parts are not obvious until you start.

  • Deciding what is worth keeping. Not every sentence is; thanks! is not a memory.
  • Finding it again from a question that uses different words than the memory did.
  • Knowing whose memory it is, when one assistant serves thousands of people.
  • Handling a fact that changes. He preferred SMS last year and prefers email now.
  • Keeping it small, so a year of conversations does not become an unreadable log.

Mem0 is those five things, already written. The next lesson shows what a first attempt gets wrong instead.

Memory is not the conversation. Keeping the whole transcript and pasting it into the next prompt is a different thing, and it stops working quickly: it grows without limit, it costs tokens on every call, and the one useful sentence is buried in three hundred. Memory means storing the few facts worth keeping and finding them on demand.
Try it yourself
  • Add a third reply to REPLIES and check the assistant still forgets everything between calls.
  • Write down, in one sentence each, three things your own assistant would need to remember about a user.
  • Count the lines it would take to store those three things and search them properly.

Little by little, you're building something great.