Persistent AI memory for LLMs and AI agents. Local-first. Learns from every interaction.
Project description
1. Install
pip install loremem-ai
That's it. Python 3.9+. Includes sentence-transformers for semantic search.
2. Use
from lore_memory import Memory
m = Memory()
m.store("I live in Amsterdam and work at Google")
m.store("I love Python and hate Java")
m.query("where do I work?") #> Google (conf=0.867)
m.store("I moved to Berlin")
m.query("where do I live?") #> Berlin — Amsterdam auto-superseded
3. Connect to your AI tool
One config. Works with Claude, Cursor, Windsurf, or any MCP client.
{
"mcpServers": {
"lore-memory": {
"command": "python3",
"args": ["/path/to/lore-memory/mcp/server.py"]
}
}
}
| Tool | Where to put it |
|---|---|
| Claude Desktop | ~/Library/Application Support/Claude/claude_desktop_config.json |
| Claude Code | .mcp.json in project root |
| Cursor | .cursor/mcp.json in project root |
| Windsurf | ~/.codeium/windsurf/mcp_config.json |
Your AI now remembers everything across conversations.
Why LoreMem
|
Local-First SQLite + sentence-transformers. No API keys. No cloud. No cost. |
Grammar Extraction Parses by sentence structure. No regex. No dictionaries. No LLM. |
Self-Learning 7 retrieval channels adapt via feedback and Hebbian learning. |
|
Fast Sub-50ms at 10K facts. ~20ms at 1K. No network calls. |
User Isolation Separate database per user. Zero data leakage. |
Offline Everything local. No telemetry. Your data never leaves. |
| LoreMem | Cloud alternatives | |
|---|---|---|
| Requires LLM | No | Yes |
| Cost | Free | $19–249/mo |
| Works offline | Yes | No |
| Extraction | Grammar-based | LLM-dependent |
| Self-learning | 7 mechanisms | Limited |
| User isolation | Physical (file-per-user) | API-level |
How It Works
|
Grammar extraction |
7-channel retrieval |
Adaptive improvement |
Store — text in, structured facts out
"I live in Amsterdam and work at Google"
│ │
▼ ▼
(user, live_in, Amsterdam) (user, work_at, Google)
Parses English by grammar position. No verb dictionaries, no regex, no LLM. Raw text is always FTS5-indexed as a fallback.
Recall — 7 scoring channels, fused into one ranked result
| Channel | What it does |
|---|---|
| Semantic | Cosine similarity (embeddings) |
| Keyword | BM25-style term overlap (FTS5) |
| Temporal | Exponential recency decay |
| Belief | Bayesian posterior (evidence + contradictions) |
| Frequency | Log-scaled access count |
| Graph | Spreading activation, 3-hop |
| Resonance | Co-activation frequency |
Weights adapt automatically through feedback.
Learn — gets better the more you use it
m.feedback(results[0].id, helpful=True) # adapt channel weights
m.consolidate() # decay + replay + archive
| Mechanism | Effect |
|---|---|
| Adaptive weights | Channels shift toward what works |
| Hebbian synapses | Co-retrieved facts strengthen links |
| Memory replay | Active memories resist decay |
| Ebbinghaus forgetting | Unused facts fade over time |
| Contradiction resolution | New facts supersede old ones |
Benchmarks
Actual runs on Apple M-series, Python 3.9. Reproduce: python benchmarks/lore_bench.py
|
Test Suite — 138 tests
|
Latency — per operation
Hash embeddings. Real embeddings add ~7ms/write. |
[!NOTE] Negation detection (62%) is a known limitation. Phrases like "I can't stand X" and "I stopped doing X" are not yet reliably parsed.
API Reference
Core API
m = Memory(user_id="alice", org_id="acme", data_dir="~/.lore-memory")
m.store(text, scope="private") # Store from natural language
m.query(query, limit=10) # 7-channel retrieval
m.forget(memory_id=...) # Delete by ID
m.forget(subject="alice") # Delete by subject
m.forget_all() # Purge all user data
m.close() # Persist and close
Advanced API
m.store_triple("alice", "works_at", "Google", confidence=0.9)
m.profile() # All facts by predicate
m.profile_compact(max_tokens=200) # Token-budgeted LLM context
m.feedback(memory_id, helpful=True) # Drive adaptive learning
m.consolidate() # Decay + replay + archive
m.stats() # Memory counts by scope
Context manager
with Memory(user_id="alice") as m:
m.store("I live in Amsterdam")
results = m.query("where do I live?")
Custom embeddings
from sentence_transformers import SentenceTransformer
model = SentenceTransformer("all-MiniLM-L6-v2")
m = Memory(user_id="alice", embedding_dims=384, embed_fn=model.encode)
Multi-user isolation
alice = Memory(user_id="alice")
bob = Memory(user_id="bob")
alice.store("I work at Google")
bob.query("where does alice work?") #> [] — fully isolated
Shared org memories:
alice = Memory(user_id="alice", org_id="acme")
alice.store("Our mission is to democratize AI", scope="shared")
bob = Memory(user_id="bob", org_id="acme")
bob.query("what is our mission?") #> Returns shared memory
CLI
lore store "I work at Google"
lore query "where do I work?"
lore list
lore stats
lore forget --id <id>
lore serve --port 8420 # REST API
lore mcp # MCP server
REST API
pip install loremem-ai[api]
lore serve --port 8420
# Store
curl -X POST localhost:8420/memory \
-H "Content-Type: application/json" \
-d '{"user_id":"alice","text":"I prefer dark mode"}'
# Query
curl "localhost:8420/memory?user_id=alice&query=preferences"
Docker
docker build -t loremem -f docker/Dockerfile .
docker run -p 8420:8000 -v lore_data:/data loremem
Contributing
Contributions welcome. See CONTRIBUTING.md.
git clone https://github.com/loreMemory/loreMemory.git && cd loreMemory
pip install -e ".[dev]" && pytest tests/ -v
Security · Changelog · License
MIT — free for personal and commercial use.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loremem_ai-1.0.7.tar.gz.
File metadata
- Download URL: loremem_ai-1.0.7.tar.gz
- Upload date:
- Size: 120.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e0ef818fe71b50aebe64102923a45201dfc0dbf2d42313ab9f6f41f0da928e9
|
|
| MD5 |
0cddcbae36ab71b45cbe2c6e7e6d22df
|
|
| BLAKE2b-256 |
b4d897f47c17f5c937e3a63776696ab01801c3974c69d81237fb2c536bdc6643
|
Provenance
The following attestation bundles were made for loremem_ai-1.0.7.tar.gz:
Publisher:
publish.yml on loreMemory/loreMemory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loremem_ai-1.0.7.tar.gz -
Subject digest:
5e0ef818fe71b50aebe64102923a45201dfc0dbf2d42313ab9f6f41f0da928e9 - Sigstore transparency entry: 1319997022
- Sigstore integration time:
-
Permalink:
loreMemory/loreMemory@26d1e53625d7897c926ff9257a907b4d471b212d -
Branch / Tag:
refs/tags/v1.0.7 - Owner: https://github.com/loreMemory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26d1e53625d7897c926ff9257a907b4d471b212d -
Trigger Event:
release
-
Statement type:
File details
Details for the file loremem_ai-1.0.7-py3-none-any.whl.
File metadata
- Download URL: loremem_ai-1.0.7-py3-none-any.whl
- Upload date:
- Size: 71.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a99a4a3c417aaa07e03673b2789d65726d6d05bbe33ddb7d6b81be9c75f73e4e
|
|
| MD5 |
15d858653bbeb9fcfedfee1c9083401a
|
|
| BLAKE2b-256 |
1329f8d6bb32e273f960fadc415317c871896564588971fb64fe56fe333c1385
|
Provenance
The following attestation bundles were made for loremem_ai-1.0.7-py3-none-any.whl:
Publisher:
publish.yml on loreMemory/loreMemory
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
loremem_ai-1.0.7-py3-none-any.whl -
Subject digest:
a99a4a3c417aaa07e03673b2789d65726d6d05bbe33ddb7d6b81be9c75f73e4e - Sigstore transparency entry: 1319997089
- Sigstore integration time:
-
Permalink:
loreMemory/loreMemory@26d1e53625d7897c926ff9257a907b4d471b212d -
Branch / Tag:
refs/tags/v1.0.7 - Owner: https://github.com/loreMemory
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@26d1e53625d7897c926ff9257a907b4d471b212d -
Trigger Event:
release
-
Statement type: