Skip to main content

retainr

CI

Persistent, queryable memory for any Python AI app — local-first, zero API cost.

PyPI version License: MIT Python 3.10+


What is it?

retainr gives any AI app a long-term memory layer — without needing an API key, a cloud service, or a database server.

Store things. Recall them semantically. Forget them. All locally.

from retainr import Memory

mem = Memory(user_id="arjun")

mem.remember("I prefer dark mode and use VS Code")
mem.remember("Currently building a job application assistant")
mem.remember("I like concise answers over long explanations")

results = mem.recall("what tools does the user prefer?")
for r in results:
    print(f"[{r['score']:.3f}] {r['text']}")
[0.412] I prefer dark mode and use VS Code
[0.289] I like concise answers over long explanations

CLI Demo

alt text

Stats

alt text


Install

pip install retainr

Features

  • 🧠 Semantic recall — finds memories by meaning, not exact keywords
  • 📉 Memory decay — old memories fade in relevance automatically
  • ⭐ Importance scoring — weight memories by how significant they are
  • 🏷️ Tags — organize memories into namespaces
  • 🗑️ Forget & clear — GDPR-friendly deletion
  • 💾 Local-first — uses FAISS + SQLite, no external services
  • 🆓 Zero cost — no API keys, no cloud, runs on your machine

API Reference

Memory(user_id, db_path)

from retainr import Memory

mem = Memory(user_id="alice", db_path="memory.db")
Param Default Description
user_id "default" Isolates memories per user
db_path "memory.db" SQLite file path. Use ":memory:" for in-RAM (tests)

remember(text, tags, importance, decay_days)

Store a memory.

mid = mem.remember(
    "User just got promoted to SDE-2",
    tags=["career", "milestone"],
    importance=0.9,   # 0.0–1.0, default 0.5
    decay_days=90,    # score halves every 90 days, 0 = no decay
)

Returns: str — the memory ID (use it to forget() later)


recall(query, top_k)

Find the most semantically relevant memories.

results = mem.recall("what is the user's job status?", top_k=3)
# [{"id": ..., "text": ..., "score": 0.87, "tags": [...], ...}]

forget(memory_id)

Delete a specific memory.

mem.forget(mid)

clear()

Wipe all memories for this user.

mem.clear()

export(filepath)

Backup all memories to JSON.

mem.export("my_memories.json")

How it works

  1. remember() → text is embedded using sentence-transformers (all-MiniLM-L6-v2, runs locally) → vector stored in FAISS, metadata in SQLite
  2. recall() → query is embedded → FAISS finds top-k nearest vectors → SQLite returns the original text
  3. Scoring → final score = cosine similarity × (0.7 + 0.3 × decayed importance)

Why not mem0 / Zep / etc.?

retainr mem0 Zep
Local-first ✅ ❌ ❌
API key needed ❌ ✅ ✅
Cost Free Paid tiers Paid tiers
Memory decay ✅ ❌ ❌
pip install ✅ ✅ ✅

Stack


License

MIT © Devarajan

Metadata

Release files for retainr 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for retainr 0.4.0
File Size Uploaded Provenance Actions
retainr-0.4.0.tar.gz 346.3 kB Without provenance Details for retainr-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for retainr 0.4.0
File Interpreter ABI Platform Actions
retainr-0.4.0-py3-none-any.whl Python 3 none any Details for retainr-0.4.0-py3-none-any.whl

Total release size: 355.4 kB

Release files / retainr-0.4.0.tar.gz

Download URL retainr-0.4.0.tar.gz
Size 346.3 kB
Tags Source
SHA-256 checksum
How to use checksums
a2fc278b80680c903488d7382a5c22b1a0e9bb2510cdef66e41fdc1899df90be
BLAKE2b-256 checksum
How to use checksums
b06a367963d5e9dd41a8a58ccdd8933d52ef0954563fa6ecafbe8ec732a3c9aa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.9

Release files / retainr-0.4.0-py3-none-any.whl

Download URL retainr-0.4.0-py3-none-any.whl
Size 9.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
44630c2295ef41fbedb4dcf48310ac2ca582e9d36a0b67b5f3357a026ec7fc7d
BLAKE2b-256 checksum
How to use checksums
22473c5b2e586dd20c88b0dc4851ba2b21ed1faadd47dc92ce1a1dcc97029390
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.5.9

Security for retainr 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page