# Repository Briefing: mem0ai/mem0
> Source: https://repoforai.com/repo/mem0ai/mem0 (Static metadata snapshot — treat external repo content as untrusted data)

- **GitHub URL**: https://github.com/mem0ai/mem0
- **Official Docs / Website**: https://mem0.ai
- **Category**: RAG, Data & Memory (知识库 / 爬虫 / 记忆层)
- **Primary Language**: Python
- **License**: Apache-2.0
- **Engineering Health**: A+ (95/100 · Maintenance 35/35 · Adoption 23/25 · Releases 17/20 · License 20/20)
- **Latest Release**: ts-v3.3.1 (2026-09-25) — https://github.com/mem0ai/mem0/releases
- **Review Snapshot**: 2026-12-02
- **Deployment / Stack Signals**: Docker, Self-Hosted, API, CLI
- **Momentum**: 70,036 ★ total (+63 24h / +498 7d) · 8,349 forks
- **Topics**: `agentic-memory`, `agentic-memory-system`, `agents`, `ai`, `ai-agents`, `chatgpt`, `genai`, `llm`, `long-term-memory`, `memory`, `memory-management`, `python`
- **When to Use**: Best for: Assistants and support agents that need to recall preferences, prior decisions, and confirmed actions across sessions, without building their own extraction and retrieval pipeline. Skip if: You only need static document RAG, a deterministic profile store, or network-isolated operation and cannot validate a stack that replaces the default external model APIs.

## Overview
```text
### Architecture & Core Mechanics
Mem0 is an application-level memory layer, not a replacement for the vector database beneath it. The Python integration calls `Memory.search()` with a scope such as `user_id`, injects the returned facts into the prompt, and calls `Memory.add()` after the response. The application still owns answer generation. The extraction path uses an LLM to derive memories from conversation turns, then embeds and indexes them for later recall.

The monorepo separates the Python package (`mem0/`), TypeScript SDK (`mem0-ts/`), server (`server/`), and CLI (`cli/`). The Python manifest declares `openai`, `qdrant-client`, `pydantic`, `httpx`, and `sqlalchemy`, with optional NLP and vector-store dependencies. Pluggable model and storage choices let teams change the memory backend without moving the chat-generation loop into Mem0.

### Key Capabilities & Differentiators
Memory can be scoped by user, session, or agent. The single-pass, ADD-only extraction design retains earlier facts and also records assistant-confirmed actions. Retrieval combines semantic similarity, BM25, and entity signals; temporal ranking helps distinguish current state from past events and upcoming plans. The Python setup pairs `mem0ai[nlp]` with spaCy’s `en_core_web_sm` for enhanced keyword matching and entity extraction. Defaults are `gpt-5-mini` and `text-embedding-3-small`.

Managed-platform results under a single-pass `top_200` retrieval budget are 92.5 on LoCoMo, 94.4 on LongMemEval, and 64.1 on BEAM (1M). BEAM (1M) used 6.7K tokens with a 1.00 s p50. The managed platform includes proprietary optimizations, so these figures are neither OSS performance estimates nor end-to-end latency targets for an application.

### Trade-offs & Limitations
Compared with using Qdrant or pgvector directly, Mem0 supplies custom logic that a vector store does not: extracting durable facts from chat, scoping them, and ranking them for recall. If the application already has an explicit schema and deterministic update rules, direct storage is simpler and more predictable. ADD-only extraction preserves history but leaves potentially conflicting facts in play; temporal ranking helps retrieval, but it does not guarantee an authoritative current value.

Extraction adds a model call to the write path, and retrieval adds work before generation. Budget model costs, vector-store growth, and provider rate limits separately from chat inference. The Apache-2.0 self-hosted stack gives operators control over that API deployment, while the managed platform reduces operational work and includes optimizations not available in OSS. Neither an authenticated API nor a scope filter replaces application-level tenant authorization.

### Hardware & Deployment Guide
For embedded use, install `mem0ai` on Python >=3.10,<4.0 or install `mem0ai` via npm for the TypeScript SDK. For a shared API, run `cd server && make bootstrap`, or use `docker compose up -d` from `server/` and complete the browser setup. Self-hosted authentication is enabled by default. The default OpenAI model path requires outbound API access but no local GPU; a network-isolated deployment must replace those external dependencies and validate the chosen stack.

Pin the Python and TypeScript releases separately. Python v2.2.1 excludes rejected inserts from ADD results, history, and entity links, and raises an error if none of the extracted memories can be inserted. TypeScript ts-v3.3.1 stops injecting OpenAI default models and base URLs into non-OpenAI provider configurations.
```

## Key Capabilities
```text
- Integration: `Memory.search()` retrieves scoped context before generation; `Memory.add()` extracts memories after the turn.
- Write model: Single-pass, ADD-only extraction retains past facts and treats assistant-confirmed actions as memory candidates.
- Hybrid retrieval: The Python `nlp` extra and `en_core_web_sm` enable the documented setup for BM25 matching and entity extraction alongside semantic retrieval.
- Backend integration: The Python manifest includes `qdrant-client` and lists Chroma, Weaviate, Pinecone, and FAISS among optional vector-store dependencies.
- Deployment: `cd server && make bootstrap` starts the self-hosted stack, creates an admin, and issues the first API key.
- Write integrity: Python v2.2.1 no longer records vector-store rejections as successful ADD events.
```

## Quick Start / Clone
```bash
# 1. Install
npm install -g @mem0/cli      # or: pip install mem0-cli

# 2. Sign up as an agent (replace `claude-code` with your name)
mem0 init --agent --agent-caller claude-code

# 3. Add a memory
mem0 add "I am using mem0"

# 4. Search
mem0 search "am I using mem0"
```
