Skip to main content
Architecture

Mem0 Architecture

A two-stage incremental memory pipeline: extraction and update

Mem0 is an incremental memory pipeline that runs in real time alongside conversations. The overall flow consists of two stages: Extraction and Update.

Inputs and Outputs

Each new message pair (m_{t-1}, m_t) triggers one execution:
Input: New message pair (m_{t-1}, m_t) + conversation summary S + last m messages
Output: Updated memory store M'

Extraction Stage

The extraction stage constructs full context and calls the LLM to extract candidate facts.
ComponentRole
Conversation summary SGlobal topic understanding, refreshed asynchronously
Last m messagesFine-grained recent temporal context
Current message pairNew interaction to process
The extraction function φ(P) outputs a set of candidate facts Ω = {ω1, ω2, ..., ωn}.
Asynchronous summary: Conversation summaries are refreshed periodically by an independent module without blocking the main pipeline, ensuring extraction always has up-to-date semantic context.

Update Stage

For each candidate fact ω_i, the system first retrieves the top-s most similar existing memories via vector search, then decides one of four operations through LLM Tool Call.
OperationTrigger ConditionEffect
ADDNo semantically similar memory existsCreate new memory entry
UPDATEExisting memory needs supplementationMerge into existing entry
DELETEContradicts existing memoryMark or remove old entry
NOOPAlready exists or insignificantNo modification

Update Algorithm (Pseudocode)

for each fact f in F:
  operation = ClassifyOperation(f, M)
  if operation == ADD:
    M = M ∪ {(new_id, f, "ADD")}
  elif operation == UPDATE:
    m_i = FindRelatedMemory(f, M)
    if InformationContent(f) > InformationContent(m_i):
      M = (M \ {m_i}) ∪ {(id_i, f, "UPDATE")}
  elif operation == DELETE:
    m_i = FindContradictedMemory(f, M)
    M = M \ {m_i}
  # NOOP: no action
return M

Experimental Parameters

ParameterValueDescription
Recent message window m10Number of historical messages participating in extraction
Similar memory count s10Number of candidates for conflict detection
Extraction / update modelGPT-4o-miniTemperature set to 0
Vector indexDense vectors + similarity searchSupports efficient recall

Why Not Use a Classifier

Mem0 does not train an additional operation classifier; instead, it lets the LLM reason directly and choose appropriate operations between candidate facts and similar memories. Reasons:
  • Semantic relationships are highly context-dependent; rules or lightweight classifiers cannot cover all cases
  • Structured decisions output via tool calling are easy to integrate
  • Reduces additional training and maintenance costs
Basic memory suffices for single-hop and multi-hop QA; for cross-entity relational reasoning, see Mem0g Graph Memory.