Skip to main content

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.md per project. Plain markdown, edit by hand if you want.
  • Claude sees recent memory at session start and calls the recall skill when a past session in this project would help.
  • For cross-repo context, the recall-global skill searches every registered project at once (uses lethe search --all under 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

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lethe_memory-0.4.0.tar.gz (4.7 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lethe_memory-0.4.0-py3-none-any.whl (45.8 kB view details)

Uploaded Python 3

File details

Details for the file lethe_memory-0.4.0.tar.gz.

File metadata

  • Download URL: lethe_memory-0.4.0.tar.gz
  • Upload date:
  • Size: 4.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lethe_memory-0.4.0.tar.gz
Algorithm Hash digest
SHA256 3805e25090da1d9018252f3aba07443454ab50e52fa48560d50890f35ed4bb59
MD5 dfcb7738b410f6cd3daa265bd112f851
BLAKE2b-256 bc061fe287c998d3db4530add799c44f7de34d9e7a226fd1223f9f70f701d998

See more details on using hashes here.

Provenance

The following attestation bundles were made for lethe_memory-0.4.0.tar.gz:

Publisher: release-please.yml on teimurjan/lethe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lethe_memory-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: lethe_memory-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 45.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lethe_memory-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3402d8f5f64dfc9b80d5d86a0c407172e6d305c4a77ddf147ca3b54f230b3e2b
MD5 2e80964b656d2c0174d09dbcde00b114
BLAKE2b-256 80da82f033622eb00a419c2400ab5d448ffb0f2ece2e2aafe42703ce939a3d7a

See more details on using hashes here.

Provenance

The following attestation bundles were made for lethe_memory-0.4.0-py3-none-any.whl:

Publisher: release-please.yml on teimurjan/lethe

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page