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).

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.

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 && /plugin install lethe

To update: uv tool install --upgrade lethe-memory && /reload-plugins

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

lethe_memory-0.3.0.tar.gz (4.6 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.3.0-py3-none-any.whl (39.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lethe_memory-0.3.0.tar.gz
  • Upload date:
  • Size: 4.6 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.3.0.tar.gz
Algorithm Hash digest
SHA256 a07b5482b68f79703eaf2b3d73fa2e10705d2e7fae3a79f6b0623b5d454cb4ab
MD5 e8b84deb3160a519ab0a77f5a9a05a48
BLAKE2b-256 e1eb140776c7bde9d3164350119b6ab3ce4a8fff769c34894efa6e3e7878e88b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lethe_memory-0.3.0-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

Hashes for lethe_memory-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 55a7ec210baa02fc31401a7322c880b95f33ad0b8154c5a11d2800e0b3aa49d2
MD5 f9433dbdac7ffac436e8137cd076d08c
BLAKE2b-256 2647268cded0abda98b7aaf9cc8a73d38e823d59359550a46bf88bfbddf93a2a

See more details on using hashes here.

Provenance

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