Skip to main content

zeromem

Rust implementation of Zero-Mem (Xiao et al., arXiv:2607.29377): agent memory where every operation outside final question answering makes zero LLM calls and consumes zero tokens. Raw conversation turns are the source of record; retrieval is structured search over them, not generated summaries.

Ships as a Rust crate, a zm CLI, a Python module (PyO3), and a memory provider plugin for Hermes Agent.

How it works

Ingest indexes each turn three ways: an entity-context graph (heuristic NER, co-occurrence edges weighted per eq 4), a temporal hierarchy (turns, windows, episodes split on session change, time gap, or topic drift), and BM25 plus dense embeddings. A query builds a deterministic profile (subject, keywords, answer type, temporal cues, session boundary), routes to a primary view, runs both retrievals, fuses with min-max normalization, closes over graph bridges and local neighbors, and calibrates the evidence set. Optionally the host can calibrate the reader's answer against typed evidence candidates.

paper module
eq 3-4 entity-context graph graph.rs, ner.rs
eq 5 trace hierarchy hierarchy.rs
eq 6 query profile profile.rs
eq 7 routing route.rs
eq 8-10 graph view (PPR) graph_view.rs
eq 11 hierarchical view hier_view.rs
eq 12-13 fusion fuse.rs
eq 14 evidence closure closure.rs
eq 15-16 calibration calibrate.rs

Defaults follow the paper: gamma 0.6, rho 0.6, top-5 evidence.

Persistence is a single SQLite file (turns plus embedding cache). Graph, hierarchy, and BM25 rebuild from turns on open, so the store cannot drift from the indexes.

Deviations from the paper: spaCy NER is replaced with a heuristic extractor behind a trait, BGE-M3 with bge-small-en-v1.5 through fastembed (a deterministic hash embedder is the offline fallback and what tests use). Both are swappable. multilingual-e5-small is the other built-in dense model, for non-English conversations. Only the dense view changes with it: BM25 stopwords, relative time words, and entity extraction are still English-oriented.

Build

Rust core:

just test        # offline, hash embedder
just demo        # ingest examples/dungeon-books.jsonl, run queries
cargo build --release

The fastembed feature (default) pulls onnxruntime and downloads bge-small-en-v1.5 (~130MB) on first use. --no-default-features drops both. Pick the other model with zm --model multilingual-e5-small or zeromem.ZeroMem(path, model="multilingual-e5-small"). A store opened with a different model than it was written with re-embeds every turn on open, so switching needs no migration.

CLI:

zm --db mem.db ingest turns.jsonl     # {"session_id","speaker","text","ts"}
zm --db mem.db query "What is Carrie handling at the store?"
zm --db mem.db stats

Python:

just dev         # maturin develop into .venv
import zeromem
m = zeromem.ZeroMem("mem.db")
m.ingest_turn("s1", "user", "I moved to Jersey City on February 14, 2022.", 1644796800)
m.query("When did I move?")
m.calibrate_answer("When did I move?", "June 2021", ["I moved to Jersey City on February 14, 2022."])

Hermes Agent

ln -s $(pwd)/hermes/zeromem ~/.hermes/plugins/zeromem
uv pip install --python <hermes-python> zeromem

The first run downloads the embedding model from Hugging Face into ~/.hermes/memory/zeromem-models.

Set in ~/.hermes/config.yaml:

memory:
  provider: zeromem

Options go in ~/.hermes/memory/zeromem.json, e.g. {"model": "multilingual-e5-small"} for Spanish or other non-English conversations.

The provider syncs turns in a background thread, prefetches evidence before each turn, and exposes zeromem_recall and zeromem_stats tools. Prefetch and recall skip the active session, which is already in context, so "last session" means the one before it. Verify with just pysmoke.

Claude Code

One shared store across every project, default ~/.zeromem (override with ZEROMEM_HOME). A Stop/SessionEnd hook (zm hook) parses each session's transcript incrementally and spools clean turns without ever opening the DB; a stdio MCP server (zm mcp) holds the index open for the session, drains the spool before each call, and serves zeromem_recall, zeromem_stats, and zeromem_forget_session.

cargo install --path crates/zeromem     # zm on PATH
claude plugin marketplace add ptaranat/zeromem
claude plugin install zeromem@zeromem

Without the plugin: add the two hooks to ~/.claude/settings.json (command zm hook on Stop and SessionEnd) and register the server with claude mcp add --scope user zeromem -- zm mcp. Verify with just ccsmoke.

Caveats: Claude Code gives MCP servers no session identity, so recall can echo turns from the current session (the exclude_session argument exists for hosts that know theirs). Forgetting a session that is still open in another window partially resurrects it as that session keeps talking. There is no prompt-time prefetch; recall is tool-driven.

Credits

Method from the Zero-Mem paper by Yilin Xiao, Zhehan Zhu, Yujing Zhang, Jin Chen, Zijin Hong, Luyao Zhuang, Qinggang Zhang, Shengyuan Chen, Xiaocao Ouyang, Lingfei Ren, and Xiao Huang. This is an independent clean-room implementation from the paper text; the authors' reference code was not published at the time of writing. Integration shape follows mnemosyne.

MIT licensed.

Metadata

Release files for zeromem 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for zeromem 0.4.0
File Actions
zeromem-0.4.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for zeromem-0.4.0-cp39-abi3-win_amd64.whl
zeromem-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl CPython 3.9 abi3 Linux glibc 2.28+ x86-64 Details for zeromem-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl
zeromem-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl CPython 3.9 abi3 Linux glibc 2.28+ ARM64 Details for zeromem-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl
zeromem-0.4.0-cp39-abi3-macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 11.0+ ARM64 Details for zeromem-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
zeromem-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl CPython 3.9 abi3 macOS 10.12+ x86-64 Details for zeromem-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl

Total release size: 56.2 MB

Release files / zeromem-0.4.0-cp39-abi3-win_amd64.whl

Download URL zeromem-0.4.0-cp39-abi3-win_amd64.whl
Size 9.9 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
d21bcbc5b7dcd2932c0bd67cc6900a8e41dbf0e24dcb39eaedcc7d7f58115d94
BLAKE2b-256 checksum
How to use checksums
c3176f73513f7ea4aa00b86486d6db1990848cf44f92f43b94d7561e746b9fad
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / zeromem-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl

Download URL zeromem-0.4.0-cp39-abi3-manylinux_2_28_x86_64.whl
Size 12.8 MB
Tags CPython 3.9 Linux glibc 2.28+ x86-64 abi3
SHA-256 checksum
How to use checksums
ada9f0e2af28fb26b0597d38236ff9642ce23f39f6f014f12e7fd19b97b97f87
BLAKE2b-256 checksum
How to use checksums
62aacae7dffd613faa56b42e21e1c0235d36614db479f2c87e9ead637a1f045e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / zeromem-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl

Download URL zeromem-0.4.0-cp39-abi3-manylinux_2_28_aarch64.whl
Size 12.4 MB
Tags CPython 3.9 Linux glibc 2.28+ ARM64 abi3
SHA-256 checksum
How to use checksums
94d8c363fb72d723e36fc6fe12659b56c6e344481e1e1269973ae22511c8b0af
BLAKE2b-256 checksum
How to use checksums
74ccbefba03bc84f07cf57c5d01f895506222de0a92710757c86cb3a93c6bb2d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / zeromem-0.4.0-cp39-abi3-macosx_11_0_arm64.whl

Download URL zeromem-0.4.0-cp39-abi3-macosx_11_0_arm64.whl
Size 10.0 MB
Tags CPython 3.9 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
e9855ef0a08b9b0d9274bd8f1aaa703e083a76285a4feb5fa88c27b626633dac
BLAKE2b-256 checksum
How to use checksums
601983dd53e55829bc95d19bdb289a57b4f2ee76349a6ab82ef2e11d84ccef03
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Release files / zeromem-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl

Download URL zeromem-0.4.0-cp39-abi3-macosx_10_12_x86_64.whl
Size 11.1 MB
Tags CPython 3.9 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
0970ba9deb93a520d7c7039c9f6c46c736066d6cfdd783ec798de634239341c6
BLAKE2b-256 checksum
How to use checksums
55f61f0dd0711b04b3f981f44144b9555837fe0927ba780f4ba2a998aa434c0c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

Security for zeromem 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for zeromem-0.4.0-cp39-abi3-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 5, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page