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

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


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.2.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.2-py3-none-any.whl (46.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lethe_memory-0.4.2.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.2.tar.gz
Algorithm Hash digest
SHA256 9b85946dbb89d7b23e365cec7ddf61cf32ca747cd58287be32c4f16370d95fb5
MD5 06f0f1b6e00bde61f6359736e7ae3636
BLAKE2b-256 31b3438f1a41292abd484a719beb03b20558bfcdd9a9c4da972cebf12e8ba015

See more details on using hashes here.

Provenance

The following attestation bundles were made for lethe_memory-0.4.2.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.2-py3-none-any.whl.

File metadata

  • Download URL: lethe_memory-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 46.2 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.2-py3-none-any.whl
Algorithm Hash digest
SHA256 71cbad3f7d955e4b5784438ec43bd1351726040f23bd57fb3b534e8b760e077f
MD5 495b93370480ff6496e278d6c1a4a6aa
BLAKE2b-256 10826c0a8432a6bb54144cbc1dfcbc4e3bbca8b171e9e29259efa014aee618b6

See more details on using hashes here.

Provenance

The following attestation bundles were made for lethe_memory-0.4.2-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