Local long-term memory for AI pets

MemMe

Remember the owner. Keep each pet relationship separate. Stay on the device.
A Rust core in one SQLite file — memory that survives restarts, model changes, and network loss.

~2ms Search p50 · PetMemBench
100% Recall@10 · required scenarios
1 File SQLite · portable
0 Cloud API keys required
Scroll to explore
00

Try it locally

Run the complete memory demo with local ONNX inference and no API key. Requires macOS or Linux (x64 / arm64), Rust, Python 3, and curl. The first run downloads dependencies and a model.

1

Run the demo from source

git clone --branch main https://github.com/vibeinging/MemMe.git
cd MemMe
bash demos/rest-demo.sh

The script downloads and configures VexDB-Lite and ONNX Runtime, builds the server, and keeps the model cache with the demo data. The v0.1.2 source archive predates these scripts; use main as shown above.

2

Watch seven checks pass

PASS wrote memories for an owner and two pets
PASS Momo sees his promise
PASS no leak to Luna
PASS Luna sees her toy
PASS owner-global allergy visible to Momo
PASS after restart, Momo still remembers
PASS isolation survives restarts

These are the expected results. The script stops the server completely, restarts it on the same SQLite file, and checks memory and isolation again. Any failure exits with an error.

3

Keep the data and run again

bash demos/rest-demo.sh

# If port 18070 is busy:
MEMME_DEMO_PORT=18071 bash demos/rest-demo.sh

Data and the model cache stay in ~/.cache/memme-demo. Later runs reuse them; loading the model still takes time. Startup logs are in server.log in that directory. The default startup timeout is 600 seconds; override it with MEMME_DEMO_START_TIMEOUT.

For individual API calls, follow the manual REST guide. Prefer Node.js? npm install @wjmwjmwb/memme (macOS / Linux) — see the Node.js guide.

01

What an AI pet gets

Three behaviors you can verify yourself in the quick start above.

🔁

Memory survives restarts

Everything durable lives in one SQLite file. Quit the process, reopen the same database, and the recall results are unchanged — even after switching to a different model.

🐾

Pets never cross memories

Owner-global facts are shared across the owner’s pets; each pet’s relationship memory is scoped to that pet. Ask as Momo, and another pet’s promise never appears.

✏️

Corrections take effect

Expired and superseded facts are filtered before they can reach a reply, while the full change history stays auditable in the same file.

02

The Memory Pipeline

From raw conversation to structured knowledge, step by step through the engine.

1 / 8
04

Meditation

LLM-powered memory consolidation. Four phases transform raw episodes into structured knowledge.

1

Decay

Time-based importance decay applied to all existing memories. Memories below threshold auto-pruned.

importance -= decay_rate × days_since_access
2

Per-Episode Fact Extraction

LLM reads each episode independently and extracts atomic, self-contained facts with timestamps.

Episode "Alice and I discussed the project. She mentioned visiting Shanghai next month."
Facts
  • "Alice is involved in the project"
  • "Alice plans to visit Shanghai"
3

Reconciliation

Extracted facts are reconciled against existing memories. The LLM proposes ADD / UPDATE / DELETE against integer-indexed IDs; without an LLM, deterministic cosine dedup applies.

ADDNo similar memory exists
UPDATEFact changed — supersede the old one
DELETEContradicted or expired

No-LLM fallback: cosine distance < 0.15 → considered duplicate. Deterministic, no hallucination risk.

4

Graph + Entity Linking

Single combined LLM call extracts entities and relationships. Aho-Corasick automaton links memories ↔ entities for spreading activation.

Alice
works_on
Project
plans_visit
Shanghai
05

Forgetting Curve

FSRS-inspired power-law decay. Memories fade, but access reinforces stability.

Retention

R(t, S) = (1 + t/(c·S))−p
t — days since last access
S — stability
c = 5.0
p = 0.5

Reinforcement

S′ = S × (1 + g × (1 − R))

Accessed memories grow exponentially more stable.

Search Scoring

score = sim × (0.7·R + 0.3·imp)

70% recency/stability, 30% tagged importance.

06

Architecture

Rust workspace. Single SQLite file. No external infrastructure.

Core Engine Providers Bindings Server
memme-core
Memory engine: CRUD, search, graph, dedup, forgetting curve, meditation, analytics
memme-embeddings
OpenAI, ONNX, Ollama
memme-llm
OpenAI, Anthropic, Gemini, Ollama
memme-python
PyO3 + maturin
memme-node
NAPI-RS
memme-ffi
Swift/C via UniFFI
memme-wasm
wasm-bindgen
memme-server
REST API (axum)
memme-mcp
MCP stdio server

SQLite Schema

memories
embeddings, content, importance, stability, access_count
events
raw content, purified, session_id, processed flag
episodes
title, summary, significance, event_ids
identity
personality traits, behavioral patterns
entities
names, types, salience scores
relationships
subject → predicate → object
memory_entities
memory ↔ entity links
sessions
session lifecycle tracking
meditations
consolidation history & stats
history
memory change audit trail
07

Bindings & API

One Rust core, several ways to use it — each route labeled with its real status.

Node.js
Published · macOS & Linux

NAPI-RS binding for Electron and Node services.

npm install @wjmwjmwb/memme
const { MemoryStore } = require('@wjmwjmwb/memme');
Rust
From source

The core engine, used directly as a workspace crate.

use memme_core::{MemoryStore, AddOptions};
store.add("主人对花生严重过敏。", AddOptions::new("owner-001"))?;
Python
Build from source

PyO3 + maturin. The PyPI 0.1.1 wheel is the legacy DuckDB build.

# From the repository root:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install maturin
maturin develop \
  --manifest-path crates/memme-python/Cargo.toml \
  --release

Then configure the SQLite extension using the Python installation guide.

Swift / C
Mobile wiring pending

UniFFI bindings exist; VexDB-Lite mobile runtime wiring is still in progress.

cargo build -p memme-ffi
WebAssembly
Not yet on VexDB-Lite

wasm-bindgen crate exists, but is not yet wired to the VexDB-Lite SQLite runtime.

REST API
Self-hosted

Axum server with Bearer auth, backups, and OpenAPI. Local ONNX embeddings by default.

POST /v1/events      POST /v1/recall
POST /v1/backups    GET  /diagnose
MCP Server
Available

Model Context Protocol stdio server for Codex Desktop, Cursor, Claude Desktop.

{
  "command": "memme-mcp",
  "args": ["--db-path", "memory.db"]
}

Also configure MEMME_VEXDB_LITE_EXTENSION, OPENAI_API_KEY, EMBEDDING_URL, and LLM_URL in the client environment. Both URLs must be full API endpoints.

08

Security

Defense in depth. From immutable records to privacy-aware exports — security is built into the engine, not bolted on.

🔒 Memory Immutability

Mark any memory as immutable. Once locked, it cannot be modified or deleted — guaranteed at the storage layer.

Public API

🛡 Privacy Levels

Three tiers: LocalOnly (never leaves device), Syncable, and EncryptedSync. Enforced on export and sync.

Public API

⏱ Data Expiration (TTL)

Set per-memory TTL. Expired memories are automatically pruned during meditation — no manual cleanup needed.

Public API

📜 Audit Trail

Every create, update, and delete is logged in the history table with timestamp, operation type, and before/after snapshot.

Public API

🔑 Bearer Token Auth

REST server supports optional API key authentication via Bearer token. Configurable per deployment.

Public API

🌐 CORS Protection

Configurable cross-origin policy on the REST server. Restrict access to trusted domains only.

Public API

🚫 Exclusion Prompts

Configure LLM extraction to skip sensitive content categories. Tell the engine what not to remember.

Public API

💉 SQL Injection Prevention

All queries use parameterized $N placeholders. Collection names validated against alphanumeric whitelist.

Internal

🧮 Content Hashing

Content hash-based deduplication and integrity checking. Detect and prevent duplicate or corrupted entries.

Internal

🔔 Webhook Notifications

Subscribe to memory lifecycle events (create, update, delete) via configurable webhook endpoints. Feature-gated.

Public API
09

Backup & Sync

From atomic file backup to cross-platform conversation import. Your data, your control.

Full Database Backup

SQLite WAL checkpoint followed by atomic file copy. Consistent snapshot guaranteed even under concurrent writes.

CHECKPOINT → atomic copy → .db backup

Database Restore

Validates backup file integrity before restoring. Atomic swap — either fully restores or leaves the original untouched.

Replica Management

Continuous backup with configurable replica paths. On startup, automatically detects and recovers from the latest valid replica.

Full Export / Import

Complete data export as JSON: memories, events, episodes, entities, relationships, identity, sessions. Portable across deployments.

Delta Sync Export

Incremental export based on version numbers. Only changed data since last sync — bandwidth-efficient for mobile and edge devices.

Memory Export / Import

Lightweight memory-level export for sharing or migration. Includes embeddings, metadata, and entity links.

External Conversation Import

Import conversation history from ChatGPT, Claude, and Gemini. Auto-detects format and maps to MemMe events.

Privacy-Aware Export

Exports automatically skip LocalOnly memories. Privacy levels are enforced at the export boundary, not just the API.

10

PetMemBench

MemMe’s product benchmark. Scenarios cover owner safety, per-pet relationships, fresh events, privacy isolation, Chinese retrieval, expiration, correction, and deletion.

Metric0.1.2 release
Required scenarios11 / 11
Extended scenarios3 / 3
Recall@10100%
Search p501.999 ms
Search p953.062 ms
Search p9917.128 ms
Write throughput445.7 memories/s
SQLite file size10.4 MB

2,000 memories · median of three independent runs · deterministic local test embeddings · x86_64 process under Rosetta on Apple Silicon. These numbers validate the storage and retrieval contract — they do not prove final reply quality or production performance.