Self-improving memory store for LLM agents: hybrid retrieval, clustered retrieval-induced forgetting, optional LLM enrichment
Project description
lethe
Λήθη: the ancient Greek personification of forgetfulness, and one of the five rivers of the underworld.
A memory store for LLM agents that gets better the more you use it. Hybrid BM25 + dense retrieval, cross-encoder reranking, clustered retrieval-induced forgetting (RIF), and optional LLM enrichment at write time.
Most memory tools are static caches - you put strings in, you get strings back by similarity, and the retrieval function never changes. lethe is different: every retrieval teaches it which entries are chronic distractors for which kinds of queries, and it quietly suppresses them over time. No fine-tuning, no extra LLM calls - just bookkeeping inspired by how human memory actually works (Anderson, 1994).
Benchmark
Numbers on the full 199,509-turn LongMemEval S corpus, turn-level retrieval, NDCG@10, no leakage. Most memory-tool benchmarks use ~50 sessions at session granularity - a ~2000× easier task. Those 99% numbers don't translate to this setup.
| Stage | NDCG@10 | notes |
|---|---|---|
| Hybrid BM25 + vector (RRF) | 0.217 | basic retrieval (most popular) |
| + cross-encoder reranking | 0.293 | +35% from semantic reranking |
| + clustered+gap RIF (checkpoint 13) | 0.312 | +6.5% from retrieval-induced forgetting |
| + LLM enrichment, on covered queries | 0.473 | +21% on the 75 queries where the answer turn was Haiku-enriched |
Full methodology in BENCHMARKS.md. 17 checkpoints (10 failed) in RESEARCH_JOURNEY.md.
https://github.com/user-attachments/assets/ea6e9657-7525-4fed-ba40-df7a14e6b9f4
Install and quick start
pip install lethe-memory
from lethe import MemoryStore
from sentence_transformers import SentenceTransformer, CrossEncoder
store = MemoryStore(
"./my_memories",
bi_encoder=SentenceTransformer("all-MiniLM-L6-v2"),
cross_encoder=CrossEncoder("cross-encoder/ms-marco-MiniLM-L-6-v2"),
)
store.add("I prefer window seats on flights", session_id="trip")
store.add("My wife needs aisle seats", session_id="trip")
store.add("I work at Google as a software engineer", session_id="work")
results = store.retrieve("What are my travel preferences?", k=5)
for entry_id, content, score in results:
print(f" [{score:.1f}] {content}")
store.save()
store.close()
As a CLI: uv tool install lethe-memory && lethe --version
As a Claude Code plugin: /plugin marketplace add teimurjan/lethe
See plugins/claude-code/README.md for plugin details.
How it works
ARCHITECTURE.md - pipeline diagram, RIF formula, storage layers, entry lifecycle, cross-project search.
RESEARCH_JOURNEY.md - 17 checkpoints from biology-inspired mutation (all failed) through cognitive-science RIF (+6.5%) to LLM enrichment (+21% on covered queries).
License
MIT
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 lethe_memory-0.2.2.tar.gz.
File metadata
- Download URL: lethe_memory-0.2.2.tar.gz
- Upload date:
- Size: 2.8 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fa87aafe650c5cc1c69c0bcadba7acffc6fb8f8b389695c1e1e688982ab4091c
|
|
| MD5 |
cfe2b4273ef6f6b8c9d8b966c043515e
|
|
| BLAKE2b-256 |
23c70d98f54ad01ab620fed922bf8cb94a8218462f48a2c9d84504229140faba
|
Provenance
The following attestation bundles were made for lethe_memory-0.2.2.tar.gz:
Publisher:
release-please.yml on teimurjan/lethe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lethe_memory-0.2.2.tar.gz -
Subject digest:
fa87aafe650c5cc1c69c0bcadba7acffc6fb8f8b389695c1e1e688982ab4091c - Sigstore transparency entry: 1328353106
- Sigstore integration time:
-
Permalink:
teimurjan/lethe@155ab72af44d1ba2b29d2c23223cd8250945dc41 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/teimurjan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@155ab72af44d1ba2b29d2c23223cd8250945dc41 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lethe_memory-0.2.2-py3-none-any.whl.
File metadata
- Download URL: lethe_memory-0.2.2-py3-none-any.whl
- Upload date:
- Size: 39.6 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 |
c684f5ed728a5e0fe642da234669a2040b4cea7a0a6b0901222166ea4ee60336
|
|
| MD5 |
cc09c8a19d2f10f25853c2ea6e05a292
|
|
| BLAKE2b-256 |
b80eff79d6d9231aecfd80a5cf8a8df8a712189cba1d87e30ce657b31f0b239f
|
Provenance
The following attestation bundles were made for lethe_memory-0.2.2-py3-none-any.whl:
Publisher:
release-please.yml on teimurjan/lethe
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
lethe_memory-0.2.2-py3-none-any.whl -
Subject digest:
c684f5ed728a5e0fe642da234669a2040b4cea7a0a6b0901222166ea4ee60336 - Sigstore transparency entry: 1328353121
- Sigstore integration time:
-
Permalink:
teimurjan/lethe@155ab72af44d1ba2b29d2c23223cd8250945dc41 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/teimurjan
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release-please.yml@155ab72af44d1ba2b29d2c23223cd8250945dc41 -
Trigger Event:
push
-
Statement type: