Source-linked AI summary

Mem0: Building Production-Ready AI Agents with Scalable Long-Term Memory

Prateek Chhikara, Dev Khant, Saket Aryan, Taranjeet Singh, Deshraj Yadav

arXiv:2504.19413v1cs.CLcs.AI

TL;DR

Fixed context windows limit coherent reasoning across extended, multi-session conversations, motivating persistent memory for long-term interaction. The paper introduces Mem0 and graph-enhanced Mem0g, which extract, consolidate, and retrieve conversational information; on LOCOMO, they outperform existing memory systems while reducing deployment overhead, although graph operations remain a latency concern.

  • Problem

    Fixed context windows and absent persistent memory limit coherent reasoning across extended conversations and separate sessions.

  • Method

    Mem0 dynamically extracts, consolidates, and retrieves salient memories, while Mem0g represents conversational entities and relationships in graph-based memory.

  • Results

    Across LOCOMO question types, the methods outperform existing memory systems and reduce p95 latency by over 91% compared with full-context baselines.

  • Takeaways & Limitations

    Compact memory representations support a balance between reasoning performance and responsiveness for long-term conversational AI.

  • Takeaways & Limitations

    Future work identifies graph-operation latency overhead and calls for broader validation beyond conversational scenarios.

Abstract

from arXiv · show

Large Language Models (LLMs) have demonstrated remarkable prowess in generating contextually coherent responses, yet their fixed context windows pose fundamental challenges for maintaining consistency over prolonged multi-session dialogues. We introduce Mem0, a scalable memory-centric architecture that addresses this issue by dynamically extracting, consolidating, and retrieving salient information from ongoing conversations. Building on this foundation, we further propose an enhanced variant that leverages graph-based memory representations to capture complex relational structures among conversational elements. Through comprehensive evaluations on LOCOMO benchmark, we systematically compare our approaches against six baseline categories: (i) established memory-augmented systems, (ii) retrieval-augmented generation (RAG) with varying chunk sizes and k-values, (iii) a full-context approach that processes the entire conversation history, (iv) an open-source memory solution, (v) a proprietary model system, and (vi) a dedicated memory management platform. Empirical results show that our methods consistently outperform all existing memory systems across four question categories: single-hop, temporal, multi-hop, and open-domain. Notably, Mem0 achieves 26% relative improvements in the LLM-as-a-Judge metric over OpenAI, while Mem0 with graph memory achieves around 2% higher overall score than the base configuration. Beyond accuracy gains, we also markedly reduce computational overhead compared to full-context method. In particular, Mem0 attains a 91% lower p95 latency and saves more than 90% token cost, offering a compelling balance between advanced reasoning capabilities and practical deployment constraints. Our findings highlight critical role of structured, persistent memory mechanisms for long-term conversational coherence, paving the way for more reliable and efficient LLM-driven AI agents.

1. Introduction

LLMs generate fluent responses but fixed context windows and absent persistent memory undermine coherence across long, multi-session conversations. Mem0 and its graph-enhanced variant address this limitation by retaining salient information for consistent retrieval and reasoning.

  • Fixed context windows prevent LLMs from maintaining coherent reasoning across extended, multi-session interactions.
  • Without persistent memory, agents forget user preferences, repeat questions, and contradict established facts across sessions.The paper illustrates this with dietary preferences that are lost between conversations.
  • Longer context windows delay rather than solve the problem because histories eventually exceed limits and relevant details may be distant from current queries.
  • Robust AI memory should selectively store important information, consolidate related concepts, and retrieve relevant details when needed.
  • Mem0 dynamically captures, organizes, and retrieves salient conversational information, while Mem0g adds graph-based representations for complex relationships.
  • 91% lower response times than full-context approaches are reported for Mem0, alongside significantly lower computational resource requirements.

2. Proposed Methods

The paper proposes Mem0, an incremental memory architecture that extracts salient facts and updates a persistent knowledge base, plus Mem0g, which represents entities and relations as a graph. Both pipelines use language-model-based extraction and structured memory updates to support coherent retrieval.

  • Mem0: Mem0 extracts, evaluates, and manages salient conversational information through dedicated memory-extraction and update modules.
  • Mem0g: Mem0g stores directed labeled graphs whose nodes represent entities and whose edges represent relationships between them.
  • Mem0: Mem0 processes new message pairs incrementally through extraction and update phases during ongoing conversations.
  • Mem0: Extraction combines a database conversation summary, a recent-message window, and the new exchange to produce candidate salient memories.
  • Mem0: The update phase compares each candidate with similar existing memories and selects ADD, UPDATE, DELETE, or NOOP through an LLM tool call.
  • Mem0g: Mem0g assigns entity types, embeddings, and creation timestamps to nodes and represents relationships as source-relation-destination triplets.
  • Mem0g: Mem0g uses LLMs to extract entities and relations, then integrates new graph information through semantic matching and update strategies.
  • Mem0g: Mem0g retrieves context through entity-centric graph exploration complemented by semantic triplet retrieval.

3. Experimental Setup

The evaluation uses LOCOMO long-term conversations and compares Mem0-family systems with diverse memory, RAG, full-context, proprietary, open-source, and platform baselines. It measures answer quality alongside token consumption and latency to expose deployment trade-offs.

  • Dataset: LOCOMO contains 10 extended, multi-session conversations averaging approximately 600 dialogues and 26000 tokens each.
  • Dataset: The adversarial question category was excluded because ground-truth answers were unavailable and expected unanswerability behavior could not be evaluated.
  • Metrics: The framework evaluates response quality and operational efficiency using separate performance and deployment metric groups.
  • Metrics: F1 and BLEU-1 are included as lexical metrics, while the evaluation recognizes their limitations for factual conversational accuracy.
  • Deployment metrics: Token consumption measures retrieved context under cl100k_base encoding, distinguishing concise memories from larger RAG text chunks.
  • Deployment metrics: Latency and token usage reveal trade-offs between factual accuracy and computational efficiency in memory-system design.
  • Baselines: The study compares six baseline categories spanning established benchmarks, open-source memory, RAG, full-context processing, proprietary models, and memory providers.
  • Baselines: RAG varies chunk sizes from 128 to 8192 tokens and retrieves k∈{1,2} chunks for answer generation.

4. Evaluation Results, Analysis and Discussion.

Mem0 and Mem0g generally achieve stronger quality than memory and RAG baselines across question types, while offering substantially lower latency and token usage than full-context processing. Their strengths differ by task: dense natural-language memory favors simpler retrieval, whereas graph structure helps temporal reasoning but can add overhead elsewhere.

  • Cross-category results: Both Mem0 and Mem0g set state-of-the-art marks on F1, B1, and J for most single-hop, multi-hop, open-domain, and temporal question types.
  • Single-hop questions: Mem0 leads single-hop performance with F1=38.72, B1=27.13, and J=67.13, while graph memory provides limited utility for single-turn retrieval.
  • Multi-hop questions: Mem0 leads multi-hop performance with F1=28.64 and J=51.15, although Mem0g adds no performance gain for dispersed multi-session information.
  • Open-domain questions: Zep leads open-domain performance with F1=49.56 and J=76.60, narrowly surpassing Mem0g’s J=75.71 and Mem0’s J=72.93.
  • Temporal reasoning: Mem0g leads temporal reasoning with F1=51.55 and J=58.13, indicating that structured relational representations aid event ordering and duration judgments.
  • RAG comparison: Mem0 and Mem0g outperform all tested RAG configurations, reaching about 10% and 12% relative gains in Overall J, respectively.
  • Full-context comparison: Full-context processing reaches approximately 73% J but incurs around 17 seconds p95 latency, compared with Mem0’s 1.44 seconds and Mem0g’s 2.6 seconds.
  • Latency and memory footprint: Mem0 has the lowest search latency at p50=0.148s and p95=0.200s, while Mem0g reaches J=68.44% with total p95 latency of 2.590s.

5. Conclusion and Future Work

Mem0 and Mem0g address fixed context-window limitations through compact memory representations, with complementary strengths across reasoning tasks and deployment efficiency. Future work targets graph efficiency, hierarchical memory, consolidation, and broader domains.

  • Conclusion: Mem0 dynamically extracts, consolidates, and retrieves compact memory representations, while Mem0g adds graph-based extensions for relational clarity.Mem0 supports rapid retrieval for straightforward queries; Mem0g models complex event sequencing and richer context integration.
  • Conclusion: 5%, 11%, and 7% relative improvements were achieved in single-hop, temporal, and multi-hop reasoning question types, respectively, over the best-performing methods.These results were reported on the LOCOMO benchmark.
  • Conclusion: Over 91% lower p95 latency than full-context baselines demonstrates the systems’ balance between precision and responsiveness.The paper attributes this efficiency to reduced token usage and computational overhead, particularly in Mem0’s dense memory pipeline.
  • Future Work: Future research includes reducing Mem0g’s graph-operation latency, combining efficiency with relational representation, and improving biologically inspired memory consolidation.These directions are presented alongside broader validation of the architectures.
  • Future Work: Extending the frameworks to procedural reasoning and multimodal interactions would further test their applicability beyond conversational scenarios.The paper frames this extension as a way to validate broader applicability.

A. Prompts

The prompts specify how memory-based answers should be generated and evaluated, emphasizing timestamp-aware evidence use, concise answers, and tolerant correctness judgments. Separate templates provide memories and graph relations for Mem0g, while the OpenAI comparison uses all generated memories as context.

  • Prompt Templates: The LLM-as-a-Judge prompt labels generated answers CORRECT or WRONG against a question, gold answer, and generated answer.It instructs the evaluator to return the label in JSON format.
  • Prompt Templates: For time-related questions, answers are judged correct when they refer to the same date or period as the gold answer, even if formatting differs.Relative expressions such as “last Tuesday” may be accepted when they identify the same time period.
  • Prompt Templates: The Mem0 results-generation prompt instructs the assistant to analyze both speakers’ timestamped memories, resolve contradictions by recency, and answer in fewer than 5–6 words.It also directs conversion of relative time references into specific dates, months, or years.
  • Prompt Templates: The Mem0g prompt adds analysis of knowledge-graph relations to the timestamp and content checks used for memory-based answers.Its inputs include speaker memories and graph relations.
  • Prompt Templates: The OpenAI comparison asks the model to create timestamped memory entries for each user and uses all generated memories as complete answering context.This gives the OpenAI approach privileged access to all memories rather than only question-relevant ones.

B. Algorithm

The memory-management algorithm updates an existing store by classifying each retrieved fact as ADD, DELETE, UPDATE, or NOOP. Decisions depend on semantic similarity, contradiction, augmentation, and information content.

  • Algorithm: The procedure takes retrieved memories F and an existing store M, then outputs an updated memory store M′.The update process applies an operation to each retrieved fact.
  • Operation Classification: New information that is not semantically similar to existing memories is classified as ADD and inserted with a unique identifier.The store is expanded with the new fact.
  • Operation Classification: Contradictory information is classified as DELETE, replacing conflicting existing information when the operation is executed.The classification rule identifies conflict with existing memory as the trigger.
  • Operation Classification: Information that augments an existing memory is classified as UPDATE and replaces it when the new fact has greater information content.The richer fact supersedes the prior memory.
  • Operation Classification: NOOP leaves the store unchanged when a fact already exists or is irrelevant.No operation is performed in this case.

C. Selected Baselines

The selected baselines represent diverse strategies for long-term memory, including dual-memory summaries and observations, gist-based compression, hierarchical storage, and interconnected notes. These systems differ in how they store, retrieve, and organize conversational information.

  • LoCoMo: LoCoMo combines recent session summaries with selectively retrieved long-term observations about speakers’ personas and life events.Its pipeline also includes references to source dialogue turns and a temporal event graph for connected life events.
  • ReadAgent: ReadAgent segments lengthy text at cognitive boundaries and compresses each segment into concise memory gists.The gists preserve essential meaning while reducing token count.
  • MemoryBank: MemoryBank stores detailed logs, hierarchical event summaries, and evolving personality profiles, then retrieves relevant context with a dual-tower dense model.Its updating component includes a human-like forgetting mechanism.
  • MemGPT: MemGPT separates bounded main context from unlimited external context and manages transfers through self-directed memory operations.The operating-system-inspired design supports extended interactions and multi-hop retrieval with fixed-context models.
  • A-Mem: A-Mem dynamically evolves interconnected notes enriched with keywords, descriptions, and tags, linking new memories to relevant existing notes.Semantic embeddings retrieve candidate notes before an LLM establishes meaningful links.
Loading 2504.19413v1…