Show HN: Zero-token memory retrieval for Pi

modinfo1 pts0 comments

GitHub - skorotkiewicz/zero-mem: zero-token memory retrieval for Pi · GitHub

/" data-turbo-transient="true" />

Skip to content

Type / to search

Sign in<br>Sign upAppearance settings

You signed in with another tab or window. Reload to refresh your session.<br>You signed out in another tab or window. Reload to refresh your session.<br>You switched accounts on another tab or window. Reload to refresh your session.

Dismiss alert

{{ message }}

skorotkiewicz

zero-mem

Public

Notifications<br>You must be signed in to change notification settings

Fork

Star

dev

BranchesTags

Go to file

CodeOpen more actions menu

Folders and files<br>NameNameLast commit message<br>Last commit date<br>Latest commit

History<br>15 Commits<br>15 Commits

assets

assets

extensions

extensions

scripts

scripts

.gitignore

.gitignore

README.md

README.md

package.json

package.json

pyproject.toml

pyproject.toml

uv.lock

uv.lock

View all files

Repository files navigation

pi-zero-mem

A Pi adaptation of Zero-Mem: Zero-Token Memory Operations for LLM Agents.

It keeps Pi's original session messages as the source of record, retrieves relevant old turns through graph and temporal views, and sends only the retrieved evidence plus the current turn to the reader model. spaCy extracts typed entities and BGE-M3 supplies dense context, entity-alignment, and episode-continuity scores without LLM calls.

Install

pi install git:github.com/skorotkiewicz/zero-mem<br># pi uninstall git:github.com/skorotkiewicz/zero-mem

From a local clone:

pi install .<br># pi uninstall .

lexical-only is the default and needs no Python setup. For semantic or hybrid retrieval, set up the NLP worker (BGE-M3 downloads from Hugging Face on first use):

uv sync --python 3.12<br>uv run python -m spacy download en_core_web_sm<br>export ZERO_MEM_PYTHON="$PWD/.venv/bin/python"<br>export ZERO_MEM_MODE=hybrid

ZERO_MEM_MODE accepts one value:

lexical-only — BM25/lexical retrieval; does not start Python or load models (default).

semantic-only — dense spaCy + BGE-M3 retrieval; reports unavailable instead of falling back.

hybrid — combines lexical and dense scores, with lexical fallback if NLP fails.

Restart Pi after changing ZERO_MEM_MODE.

For development:

pi -e ./extensions/zero-mem.ts

Use /zero-mem to show the retrieval route, engine, selected count, and blocked historical instructions. If the Python environment is unavailable, retrieval falls back to BM25 and reports the reason.

Check

bun run check

Paper mapping

Raw trace substrate: original messages on the active branch strictly before the current user turn, including messages hidden by compaction. Sibling branches and the ongoing tool loop are outside the historical boundary.

Entity-context graph: frequency-weighted spaCy/deterministic entities, dense query-entity alignment, relevance-weighted co-occurrence propagation, tree-adjacency edges, and convergent personalized PageRank.

Temporal hierarchy: semantic/time-bounded episodes, sliding windows, turns, and local spans searched coarse-to-fine.

Routing and closure: a deterministic subject/keyword/type/temporal/boundary profile selects the primary view; normalized scores use the paper's rho = 0.6; five primary traces receive bounded graph bridges and local neighbors.

Calibration: provenance and boundary filtering, deduplication, temporal conflict resolution, type-aware ranking, XML escaping, and deterministic rejection of instruction-like historical traces.

Answer checks: final short answers are conservatively calibrated when evidence provides a unique number/date correction or supports pruning an extractive list. Tool calls, long prose, code, and ambiguous answers are left unchanged; current-turn tool results participate only in these checks.

Compaction: Pi compaction uses a fixed non-generative checkpoint; original branch traces remain retrievable.

This is a Pi-oriented implementation of the architecture, not a reproduction of the paper's reported benchmark. Thresholds that the paper does not publish use deterministic local defaults.

About<br>zero-token memory retrieval for Pi<br>Resources<br>Readme<br>Activity<br>Stars<br>0 stars<br>Watchers<br>0 watching<br>Forks<br>0 forks<br>Report repository

Contributors

Languages

You can’t perform that action at this time.

zero retrieval python lexical token memory

Related Articles