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.
Each new message pair
The extraction stage constructs full context and calls the LLM to extract candidate facts.
The extraction function
For each candidate fact
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:
Inputs and Outputs
Each new message pair (m_{t-1}, m_t) triggers one execution:
Extraction Stage
The extraction stage constructs full context and calls the LLM to extract candidate facts.
| Component | Role |
|---|---|
| Conversation summary S | Global topic understanding, refreshed asynchronously |
| Last m messages | Fine-grained recent temporal context |
| Current message pair | New interaction to process |
φ(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.
| Operation | Trigger Condition | Effect |
|---|---|---|
| ADD | No semantically similar memory exists | Create new memory entry |
| UPDATE | Existing memory needs supplementation | Merge into existing entry |
| DELETE | Contradicts existing memory | Mark or remove old entry |
| NOOP | Already exists or insignificant | No modification |
Update Algorithm (Pseudocode)
Experimental Parameters
| Parameter | Value | Description |
|---|---|---|
| Recent message window m | 10 | Number of historical messages participating in extraction |
| Similar memory count s | 10 | Number of candidates for conflict detection |
| Extraction / update model | GPT-4o-mini | Temperature set to 0 |
| Vector index | Dense vectors + similarity search | Supports 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