github mem0ai/mem0 v2.0.0
Mem0 Python SDK (v2.0.0)

latest release: ts-v3.0.0
9 hours ago

Mem0 Python SDK (v2.0.0)

A ground-up redesign of how memories are extracted, stored, and retrieved — plus a long-overdue cleanup of the SDK surface.

Highlights

  • New extraction algorithm — single-pass, ADD-only, roughly half the latency
  • Multi-signal hybrid retrieval — semantic + BM25 keyword + entity matching fused into one score
  • Built-in entity linking — replaces graph memory with no external store to manage
  • Cleaner SDK surface — constructor and method signatures aligned with the Platform API

What's new

Single-pass ADD-only extraction

One LLM call per add(). No separate UPDATE/DELETE pass. The model now spends its capacity on understanding the input instead of diffing against existing memories, and agent-generated facts ("I've booked your flight for March 3rd") are captured as first-class memories for the first time. Hash-based deduplication prevents exact duplicates; ranking at retrieval time handles the rest.

Hybrid retrieval

Semantic vector similarity, BM25 keyword matching, and entity-graph boosting are normalized and fused into a single score on every result. The fusion adapts at runtime — if spaCy or fastembed aren't installed, search gracefully degrades to semantic-only instead of breaking.

Entity linking (replaces graph memory)

Entities (proper nouns, quoted text, compound noun phrases) are extracted automatically during add() and stored in a parallel {collection}_entities collection inside your existing vector store. At query time, entities from the query boost ranking on matching memories. No Neo4j, Memgraph, Kuzu, or Apache AGE deployment needed — ~4,000 lines of graph driver code have been removed from the SDK.

Vector store enhancements

All 15 vector stores now implement keyword_search() and search_batch(). Qdrant uses sparse vectors (BM25) alongside dense vectors in the same collection via fastembed; every other store uses its native full-text capability with no extra dependency.

Stricter, clearer validation

  • Empty or whitespace-only entity IDs raise ValueError with a specific message
  • threshold must be in [0, 1] — out-of-range values raise instead of silently behaving oddly
  • messages=None or wrong type raises Mem0ValidationError (code VALIDATION_003)
  • custom_fact_extraction_prompt → renamed to custom_instructions (consolidates with custom_update_memory_prompt, which was deprecated)

Platform client

  • MemoryClient(api_key="...")org_id / project_id no longer in the constructor
  • get_all returns a paginated envelope: {count, next, previous, results}
  • add is async by default and returns {status: "PENDING", event_id} — poll /v1/event/{event_id}/ for completion
  • Removed: api_version, output_format, async_mode, enable_graph, filter_memories, expiration_date, keyword_search, force_add_only, batch_size, immutable, includes, excludes, org_name, project_name

Breaking changes at a glance

Change Migration
Entity IDs on search() / get_all() Must be inside filters={"user_id": "..."}; top-level kwargs now raise ValueError
top_k default 10020 Pass top_k=100 explicitly to restore
threshold default None0.1 Pass threshold=0.0 to disable
rerank default TrueFalse Pass rerank=True to restore
graph_store / enable_graph Removed — uninstall graph drivers
custom_update_memory_prompt Removed — use custom_instructions
qdrant-client Bumped to >=1.12.0
upstash-vector Bumped to >=0.6.0

add() and delete_all() continue to accept entity IDs as top-level kwargs.

Install

pip install --upgrade mem0ai

# Recommended — full hybrid search (Python 3.10–3.12):
pip install --upgrade "mem0ai[nlp]" fastembed
python -m spacy download en_core_web_sm

The base package works on any supported Python version; the [nlp] extra currently requires Python 3.10–3.12 (spaCy's blis / thinc don't ship Python 3.13 wheels yet).

Full migration guide: docs.mem0.ai/migration/oss-v2-to-v3

Don't miss a new mem0 release

NewReleases is sending notifications on new releases.