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).
Install and quick start
As a Claude Code plugin (recommended for daily use)
/plugin marketplace add teimurjan/lethe
/plugin install lethe
What happens after install:
- Every session is summarized into
.lethe/memory/YYYY-MM-DD.mdper project. Plain markdown, edit by hand if you want. - Claude sees recent memory at session start and calls the
recallskill when a past session in this project would help. - For cross-repo context, the
recall-globalskill searches every registered project at once (useslethe search --allunder the hood).
Update: uv tool install --upgrade lethe-memory && /reload-plugins
See plugins/claude-code/README.md for the full hook table, config knobs, and debugging.
As a CLI
uv tool install lethe-memory
lethe --version
lethe index # reindex .lethe/memory
lethe search "your query" --top-k 5 # single project
lethe search "your query" --all --top-k 5 # all registered projects
lethe projects list
lethe status
Interactive TUI
uv tool install --force 'lethe-memory[tui]'
# or, if lethe is already installed as a uv tool:
uv tool install --force --reinstall --with textual lethe-memory
lethe tui
uv tool install does not read [project.optional-dependencies] from extras syntax unless quoted; the --with textual form is the reliable fallback. Keys inside the TUI: ↑↓ nav, ⏎ search/open, Esc back, Ctrl+Q quit. Type anywhere to jump focus to the search box.
As a Python library
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()
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 (paired permutation p<0.002, 95% CI excludes zero) |
| + LLM enrichment, on covered queries | 0.473 | +21% on the 75 queries where the answer turn was Haiku-enriched |
Scope. The RIF gain is workload-specific. The mechanism targets the chronic-false-positive pattern in a single user's long-term conversation memory. On NFCorpus (a non-conversational medical IR benchmark) it doesn't transfer: three of four variants significantly regress. We diagnose this in the arXiv paper (corpus saturation + workload mismatch) and scope the claim to long-term conversational memory. Use lethe for what it's good at; don't expect it to help on general ad-hoc retrieval.
Full methodology in BENCHMARKS.md. 18 checkpoints (11 failed or null) in RESEARCH_JOURNEY.md. Statistical rigor and the NFCorpus replication in arxiv/paper.tex.
How it works
ARCHITECTURE.md - pipeline diagram, RIF formula, storage layers, entry lifecycle, cross-project search.
RESEARCH_JOURNEY.md - 18 checkpoints from biology-inspired mutation (all failed) through cognitive-science RIF (+6.5% on conversational memory, does not generalize to ad-hoc IR) to LLM enrichment (+21% on covered queries) and statistical rigor with a second-dataset replication.
License
MIT
Project details
Release history Release notifications | RSS feed
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.5.1.tar.gz.
File metadata
- Download URL: lethe_memory-0.5.1.tar.gz
- Upload date:
- Size: 6.0 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43746c57e6534699c9f925436ffcc3a25e1bf947421946b6a6ce9d621e732116
|
|
| MD5 |
11e55a291918b16ecd1756da8aa521ed
|
|
| BLAKE2b-256 |
982ef440cc569c13af2d002ee380d78ba9869d5781cbac5766f8ca2695a7ec95
|
Provenance
The following attestation bundles were made for lethe_memory-0.5.1.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.5.1.tar.gz -
Subject digest:
43746c57e6534699c9f925436ffcc3a25e1bf947421946b6a6ce9d621e732116 - Sigstore transparency entry: 1368077381
- Sigstore integration time:
-
Permalink:
teimurjan/lethe@9d649fba7da8900a6850d0286bab0c2603aaa539 -
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@9d649fba7da8900a6850d0286bab0c2603aaa539 -
Trigger Event:
push
-
Statement type:
File details
Details for the file lethe_memory-0.5.1-py3-none-any.whl.
File metadata
- Download URL: lethe_memory-0.5.1-py3-none-any.whl
- Upload date:
- Size: 48.4 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 |
eb36cd7a364f9f5d1360e78de5bb5422ade11248da42dd560e388d56175bad77
|
|
| MD5 |
70461e66fd128f2e8255c4dc39a71b9e
|
|
| BLAKE2b-256 |
6e6cd860f62f25376f20ae20adb3cc4f129340aba2b1448060fe92260fd49705
|
Provenance
The following attestation bundles were made for lethe_memory-0.5.1-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.5.1-py3-none-any.whl -
Subject digest:
eb36cd7a364f9f5d1360e78de5bb5422ade11248da42dd560e388d56175bad77 - Sigstore transparency entry: 1368077400
- Sigstore integration time:
-
Permalink:
teimurjan/lethe@9d649fba7da8900a6850d0286bab0c2603aaa539 -
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@9d649fba7da8900a6850d0286bab0c2603aaa539 -
Trigger Event:
push
-
Statement type: