sqlite-graph-memory 0.3.6__tar.gz → 0.3.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/CHANGELOG.md +40 -0
  2. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/PKG-INFO +77 -22
  3. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/README.md +76 -21
  4. sqlite_graph_memory-0.3.8/docs/demo.gif +0 -0
  5. sqlite_graph_memory-0.3.8/docs/demo.sh +44 -0
  6. sqlite_graph_memory-0.3.8/docs/memory-compare-2026-11.md +83 -0
  7. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/eval/build_gold.py +32 -6
  8. sqlite_graph_memory-0.3.8/eval/run_ablation.py +328 -0
  9. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/eval/run_eval.py +9 -5
  10. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/examples/README.md +1 -1
  11. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/examples/mcp-config.json +1 -1
  12. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/pyproject.toml +1 -1
  13. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/__init__.py +1 -1
  14. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/brain_ask.py +204 -22
  15. sqlite_graph_memory-0.3.8/src/sqlite_graph_memory/index_notes.py +280 -0
  16. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/mcp_server.py +1 -1
  17. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/vault_stats.py +17 -3
  18. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_bench.py +102 -0
  19. sqlite_graph_memory-0.3.8/tests/test_brain_ask.py +326 -0
  20. sqlite_graph_memory-0.3.8/tests/test_eval.py +627 -0
  21. sqlite_graph_memory-0.3.8/tests/test_incremental_index.py +307 -0
  22. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_onnx_backend.py +19 -0
  23. sqlite_graph_memory-0.3.8/tests/test_rerank_default.py +53 -0
  24. sqlite_graph_memory-0.3.8/tests/test_rerank_flag_eval.py +22 -0
  25. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_star_prompt.py +1 -1
  26. sqlite_graph_memory-0.3.8/tests/test_uvx_python_pin.py +75 -0
  27. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_vault_stats.py +35 -0
  28. sqlite_graph_memory-0.3.6/docs/demo.gif +0 -0
  29. sqlite_graph_memory-0.3.6/docs/demo.sh +0 -33
  30. sqlite_graph_memory-0.3.6/src/sqlite_graph_memory/index_notes.py +0 -160
  31. sqlite_graph_memory-0.3.6/tests/test_brain_ask.py +0 -141
  32. sqlite_graph_memory-0.3.6/tests/test_eval.py +0 -266
  33. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/.gitignore +0 -0
  34. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/CITATION.cff +0 -0
  35. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/LICENSE +0 -0
  36. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/bench/README.md +0 -0
  37. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/bench/requirements.txt +0 -0
  38. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/docs/RELEASING.md +0 -0
  39. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/docs/bitemporal.md +0 -0
  40. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/examples/claude-code-stop-hook.json +0 -0
  41. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/requirements.txt +0 -0
  42. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/doctor.py +0 -0
  43. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/onnx_backend.py +0 -0
  44. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/ppr.py +0 -0
  45. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/schema.sql +0 -0
  46. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/turnstate_hook.py +0 -0
  47. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/src/sqlite_graph_memory/turnstate_show.py +0 -0
  48. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_changelog_released.py +0 -0
  49. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_doctor.py +0 -0
  50. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_feedback_link.py +0 -0
  51. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_index_notes.py +0 -0
  52. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_index_notes_dotfiles.py +0 -0
  53. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_llms_txt.py +0 -0
  54. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_mcp_script_mode.py +0 -0
  55. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_mcp_server.py +0 -0
  56. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_optional_extra.py +0 -0
  57. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_ppr.py +0 -0
  58. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_turnstate_hook.py +0 -0
  59. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_turnstate_show.py +0 -0
  60. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_version_consistent.py +0 -0
  61. {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.8}/tests/test_version_flag.py +0 -0
@@ -6,6 +6,46 @@ recorded after the fact rather than backdated to look contemporaneous.
6
6
 
7
7
  ## Unreleased
8
8
 
9
+ ## v0.3.8 - 2026-11-10
10
+
11
+ Five of the six entries below came from one outside contributor in one week. Thank you, @Jason-Vaughan.
12
+
13
+ **Bench: `mempalace` row.** MemPalace 3.11.0 with its defaults (`miner.mine()` projects mode, ChromaDB default embedder, `search_memories(n_results=20)`, no LLM) under the shared extractive answer floor. R@5 0.82, answer 0.42; it never abstains on the 22 questions with no answer in the vault (0.00). Self-reported for now: the adapter needs no API key, so it can join the CI reproduce job.
14
+
15
+ **Bench: `plain-rag` reference row.** Dense cosine-only baseline (`multilingual-e5-base` over 1200-char chunks, `topk=60`, no graph hop and no cross-encoder reranker) reproduced in CI, isolating what reranking and wikilink expansion change on `memory-bench`. Thanks @Jason-Vaughan (#91), who picked up #21.
16
+
17
+ **Recall: `superseded_by` links still resolve when the entity gate fires.** A short entity-shaped query (like a project title) that hits an outdated note now still follows its frontmatter `superseded_by` target in `expand_1hop` while keeping general wikilink expansion gated off. Thanks @Jason-Vaughan (#94), who picked up #93.
18
+
19
+ **`sgm-ask` and `eval/run_ablation.py`: `--pool` override for the dense candidate pool.** `--pool N` (or `BRAIN_TOPK_RETRIEVE=N`) overrides `TOPK_RETRIEVE` without changing the 60-note default, and `DEFAULT_GRID` adds `topk-15` so pool-size sweeps can be compared across vaults. Thanks @Jason-Vaughan (#97), who picked up #92.
20
+
21
+ **`eval/run_ablation.py`: gate, neighbour-admission and rank-churn columns.** Each ablation cell now reports `gate_rate`, `hop_applied_rate` and `rank_churn` alongside the retrieval metrics, separating queries where the entity gate suppressed the hop from queries where neighbours entered and reordered the top-12 without moving single-note gold at rank 1. Thanks @Jason-Vaughan (#95), who picked up #93.
22
+
23
+ **`eval/build_gold.py`: short `heading` question class.** Adds a fifth class built from short markdown headings (`<= 5` words) so `looks_like_entity` is exercised on short heading queries in `run_eval.py` and `run_ablation.py`. Because `rnd.shuffle(notes)` runs once before the class pools are sliced, the four existing classes pick the exact same questions for a given seed and older gold sets and published numbers still reproduce (only `heading` is new); on a vault with no qualifying short headings, `heading` is simply empty (0 questions, omitted from the printed class counts and eval tables, no crash). Thanks @Jason-Vaughan (#96), who picked up #93.
24
+
25
+ ## v0.3.7 - 2026-11-05
26
+
27
+ **Recall: the cross-encoder rerank is off by default.** `sgm-ask`, the MCP tool and `eval/run_eval.py` now order candidates by dense e5 similarity; `--rerank` or `SGM_RERANK=1` brings the cross-encoder back. Measured before the change: on our 184-question gold set the reranker cut body nDCG@12 from 0.815 to 0.640, and on DolphinBench data (Riley, 50 tests, 1000 sessions) Recall@5 fell from 0.61 to 0.48; it still helped short title-style queries. Dense recall is also faster on CPU (about 0.04 s against 2.8 s per query on that slice). `rerank_candidates()` takes `sims=` and keeps dense order when no cross-encoder is passed.
28
+
29
+ **`uvx` install lines work on a newer default Python.** On an Intel Mac whose `uv` defaults to Python
30
+ 3.14, `uvx --from 'sqlite-graph-memory[lite]' ...` fell back to release 0.3.5, which has no `[lite]`, and
31
+ `sgm-index` stopped with a hint to install `[embeddings]`. Apple Silicon below macOS 14 resolves the same
32
+ way. The `uvx` lines in the docs now pin `--python 3.12`; `server.json` does too, and that reaches the MCP
33
+ Registry with this release.
34
+
35
+ **Shorter demo gif.** It now shows the top 5 of each list, so the graph hit fits on one screen.
36
+
37
+ **`sgm-index`: a rerun re-embeds only what changed.** A manifest keyed on the content hash and the index settings lets `sgm-index` skip untouched notes; size and mtime are the fast path, the hash decides the changed set, and a corrupt manifest falls back to a full build. The default encoder still comes from `load_encoder()`, so `[lite]` installs keep working without torch. Thanks @Jason-Vaughan (#85), who picked up #17.
38
+
39
+ **Recall: folder-style wikilinks resolve in the graph hop.** `[[folder/note]]` links now reach their note in `expand_1hop` the same way `sgm-stats` counts them, preferring the exact vault-relative path; the vault root is computed once per index, not per link. Thanks @Jason-Vaughan (#84), who picked up #71.
40
+
41
+ **Bench: `tangleclaw-style` reference row.** A stdlib-only pipeline (BM25 + FTS5 + 1-hop wikilinks + `superseded_by` lineage) in the style of TangleClaw's markdown continuity, reproduced in CI. Same R@5 as bm25; its gain is on superseded decisions and abstention, with no domain words in the abstention gate. Thanks @Jason-Vaughan (#87), who picked up #21.
42
+
43
+ **`eval/run_ablation.py`: one run sweeps the retrieval knobs.** Scores a grid of cells (`hops`, `ghops`, `gmax`, `topk`, entity gate) on one gold file, reusing the same pipeline functions as `sgm-ask` and the metrics from `run_eval.py`; the dense pass runs once per question and each cell slices the widest pool, so only the rerank repeats. The default grid changes one axis at a time against `1-hop`; `--grid` takes multi-axis cells. Thanks @Jason-Vaughan (#86), who picked up #19.
44
+
45
+ **Light backend: a fallback to torch is no longer silent.** When the ONNX models fail to load and recall falls back to torch, the answer now starts with a `NOTE:` line naming the reason and pointing at `sgm-doctor`. Through MCP the agent sees only the answer, so the stderr line alone hid the slow path (#89).
46
+
47
+ **Docs: install commands use `[lite]`.** Now that v0.3.6 is on PyPI with the `[lite]` extra, README, llms.txt and the example MCP config install the torch-free stack; `[embeddings]` stays documented for a GPU.
48
+
9
49
  ## v0.3.6 - 2026-11-03
10
50
 
11
51
  **Light backend: recall without torch.** New extra `[lite]` runs the same two models (multilingual-e5-base and the mMiniLMv2 reranker) on ONNX Runtime from their official ONNX exports: 155 MB installed instead of ~2 GB, and on the hub one MCP recall took 7.0 s instead of 33.8 s through torch, with the same hits and scores (embeddings agree to 3e-7). It is picked automatically when installed; `SGM_BACKEND=torch|onnx` forces either, and an index built by one backend works with the other. `pick_device()` no longer imports torch on this path: on a Windows CPU laptop that import alone took 44 s and pushed the first MCP call past the client's tool timeout (2026-11-01). Models stay in the persistent Hugging Face cache (`SGM_MODEL_CACHE` overrides), and `sgm-index` fetches the reranker too, so the first recall is not also a download. `sgm-doctor` reports the light backend. Install commands in README keep `[embeddings]` until `[lite]` is on PyPI.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: sqlite-graph-memory
3
- Version: 0.3.6
3
+ Version: 0.3.8
4
4
  Summary: Associative memory for LLM agents: Graph RAG over a folder of markdown notes, in one SQLite file, with no server to run.
5
5
  Project-URL: Homepage, https://github.com/tonydzi/sqlite-graph-memory
6
6
  Project-URL: Repository, https://github.com/tonydzi/sqlite-graph-memory
@@ -62,6 +62,8 @@ misses by following the links between your notes. It is an MCP server and a CLI
62
62
  folder of markdown, Obsidian vaults included: `pip install`, point it at the folder, and
63
63
  Claude Code, Cursor, Codex or any other MCP client can recall from it.
64
64
 
65
+ It fits [Andrej Karpathy's LLM Wiki pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) (April 2026), where an agent maintains an interlinked markdown wiki and a search tool over the pages is the first helper he suggests adding: sgm is that search layer, read-only, and it follows your `[[wikilinks]]` as a graph. Independent project, not affiliated with or endorsed by him.
66
+
65
67
  ![sgm-index builds the index of the 202-note bench vault, then sgm-ask --ab shows tool-lanternfish entering the top 5 only through a graph hop; the one-minute CPU indexing wait is cut](docs/demo.gif)
66
68
 
67
69
  **Your agent forgets everything between sessions, and plain vector search gives it back
@@ -78,9 +80,13 @@ Already using your own agent rules and projects? The [Russian existing-setup gui
78
80
  Build the index once (any folder of markdown; [`uv`](https://docs.astral.sh/uv/) gives you `uvx`):
79
81
 
80
82
  ```bash
81
- BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --from 'sqlite-graph-memory[embeddings]' sgm-index ~/notes
83
+ BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --python 3.12 --from 'sqlite-graph-memory[lite]' sgm-index ~/notes
82
84
  ```
83
85
 
86
+ `--python 3.12` is deliberate. onnxruntime has no wheels for Python 3.14 on an Intel Mac, or on
87
+ Apple Silicon below macOS 14. On such a machine an unpinned `uvx` falls back to release 0.3.5,
88
+ which has no `[lite]`, and `sgm-index` then stops and asks for `[embeddings]`.
89
+
84
90
  Then point your client at the server. Use the absolute path of that index folder.
85
91
 
86
92
  **Cold-start timeout (0.3.5 and later).** The MCP server starts recall in a separate process with a default deadline of 180 seconds; a first call on a clean Windows install took 89 s, which the old fixed 60 s always cut off. Override with `BRAIN_RECALL_TIMEOUT` (integer seconds, 1 to 600; invalid values return an error). Your MCP client's own tool timeout must also allow the longer call. On 0.3.3 and earlier the deadline is a fixed 60 s: upgrade, or use `sgm-ask --ask` directly, and do not report MCP recall as verified merely because the CLI works.
@@ -88,7 +94,7 @@ Then point your client at the server. Use the absolute path of that index folder
88
94
  **Claude Code**
89
95
 
90
96
  ```bash
91
- claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --with 'sqlite-graph-memory[embeddings]' sqlite-graph-memory
97
+ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --python 3.12 --with 'sqlite-graph-memory[lite]' sqlite-graph-memory
92
98
  ```
93
99
 
94
100
  **Cursor** (`~/.cursor/mcp.json`; Claude Desktop, Zed and Windsurf take the same `mcpServers` block)
@@ -98,7 +104,7 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
98
104
  "mcpServers": {
99
105
  "sqlite-graph-memory": {
100
106
  "command": "uvx",
101
- "args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
107
+ "args": ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"],
102
108
  "env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
103
109
  }
104
110
  }
@@ -113,7 +119,7 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
113
119
  "sqlite-graph-memory": {
114
120
  "type": "stdio",
115
121
  "command": "uvx",
116
- "args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
122
+ "args": ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"],
117
123
  "env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
118
124
  }
119
125
  }
@@ -125,31 +131,37 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
125
131
  ```toml
126
132
  [mcp_servers.sqlite-graph-memory]
127
133
  command = "uvx"
128
- args = ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"]
134
+ args = ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"]
129
135
  env = { BRAIN_INDEX_DIR = "/absolute/path/to/.sgm-index" }
130
136
  ```
131
137
 
132
138
  Size, `du -sh` of a fresh Python 3.12 venv on an x86_64 Mac (1 Nov 2026): the base install is
133
139
  26 MB and has no torch (numpy only, enough for the graph half and the SQLite ledger);
134
- with `[embeddings]` (torch) it is 879 MB, 540 MB of that torch 2.2.2 CPU. With `[lite]` (from v0.3.6),
140
+ with `[embeddings]` (torch) it is 879 MB, 540 MB of that torch 2.2.2 CPU. With `[lite]`,
135
141
  the same two models on ONNX Runtime and no torch, it is 155 MB (Windows, Python 3.12,
136
142
  3 Nov 2026), installs in 12 s, and one MCP recall on the 202-note bench vault took 7.0 s
137
143
  against 33.8 s through torch on the same machine, with the same top hits and scores.
138
144
  `[lite]` is picked automatically when installed; `SGM_BACKEND=torch` forces torch (for a GPU).
139
145
  An index built by either backend is searched correctly by the other.
140
- Already installed with pip? Replace `uvx --with ... sqlite-graph-memory` by `sgm-mcp`
146
+ Already installed with pip? Replace `uvx --python 3.12 --with ... sqlite-graph-memory` by `sgm-mcp`
141
147
  ([`examples/mcp-config.json`](examples/mcp-config.json)). Agents that read files first:
142
148
  [`llms.txt`](llms.txt).
143
149
 
144
150
  ## Three commands
145
151
 
146
152
  ```bash
147
- pip install 'sqlite-graph-memory[embeddings]'
153
+ pip install 'sqlite-graph-memory[lite]'
148
154
  sgm-index ./notes
149
155
  sgm-ask --ab "In which programming language is the tool behind Project Ouzel written?"
150
156
  ```
151
157
 
152
- `./notes` is any folder of markdown notes. To get exactly the output below, use the
158
+ On an Intel Mac, use Python 3.12 with `pip install`. On a newer Python it can quietly install 0.3.5, which has no `[lite]`.
159
+
160
+ `./notes` is any folder of markdown notes. Re-running `sgm-index` only re-embeds notes
161
+ that are new or changed since the last run (tracked by a manifest next to the index);
162
+ pass `--full` to force a complete rebuild.
163
+
164
+ To get exactly the output below, use the
153
165
  202-note synthetic vault from this repo (it is not inside the pip package):
154
166
 
155
167
  ```bash
@@ -191,8 +203,9 @@ exists so you can measure which one wins on your own notes.
191
203
 
192
204
  Graph RAG on SQLite for AI agents — a working pilot, not a framework. It is the extracted
193
205
  memory layer of a personal "second brain" agent setup: vector search finds the entry
194
- points, the `[[wikilinks]]` you already wrote by hand are the graph, and a cross-encoder
195
- reranks what the hop dragged in.
206
+ points, the `[[wikilinks]]` you already wrote by hand are the graph, and dense similarity
207
+ orders what the hop dragged in (a cross-encoder rerank is opt-in with `--rerank`; see below
208
+ for why it is no longer the default).
196
209
  SQLite is the only database ([`schema.sql`](src/sqlite_graph_memory/schema.sql)).
197
210
 
198
211
  Status: **pilot**, and the word is load-bearing: it runs daily in one real setup (an index of ~28k curated notes, ~93k chunks, rebuilt nightly from a ~270k-file
@@ -215,12 +228,14 @@ For a single-user agent over a markdown knowledge base, all three are overkill:
215
228
  - **SQLite is enough** — the only things worth persisting are derived state (a per-turn
216
229
  ledger) and telemetry, and both are defined in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
217
230
  One file, stdlib driver, zero ops.
218
- - The expensive part of RAG quality is a **reranker**, not graph infrastructure — see the
219
- rerank step in `brain_ask.py`.
231
+ - **Measure before adding a stage.** The pilot shipped a cross-encoder reranker from day one;
232
+ measured later, it lowered recall on long queries (our 184-question gold set: body nDCG@12
233
+ 0.640 reranked vs 0.815 dense; DolphinBench Riley slice, 1000 sessions: R@5 0.48 vs 0.61).
234
+ Since 0.3.7 it is off by default and stays available as `--rerank` / `SGM_RERANK=1`.
220
235
 
221
236
  So the pilot's bet: *vector retrieval for entry points, hand-curated wikilinks for
222
- association, a cross-encoder to keep serendipity honest, SQLite for everything that must
223
- persist.* All four steps live in one file, `brain_ask.py`, in that order.
237
+ association, SQLite for everything that must persist.* All steps live in one file,
238
+ `brain_ask.py`, in that order.
224
239
 
225
240
  ## Architecture
226
241
 
@@ -234,7 +249,8 @@ markdown notes (with [[wikilinks]])
234
249
  ├── brain_ask.py recall pipeline:
235
250
  │ 1. dense retrieve top-60 chunks, dedup by file
236
251
  │ 2. --graph +1-hop wikilink neighbours of top-15 hits (max 40)
237
- │ 3. rerank cross-encoder → top-12
252
+ │ 3. order dense similarity → top-12
253
+ │ (--rerank: cross-encoder instead, opt-in)
238
254
  │ 4. --ab run vector-only AND vector+graph, diff,
239
255
  │ log the delta to SQLite (ab_recall)
240
256
  │
@@ -253,7 +269,7 @@ an edge table only when hop depth or corpus size demands it.
253
269
  ### Design choices that survived contact with reality
254
270
 
255
271
  - **Graph expansion is candidate generation, not ranking** (`brain_ask.py`). Neighbours go
256
- into the same reranker pool as vector hits, so an irrelevant linked note gets buried.
272
+ into the same ranking pool as vector hits, so an irrelevant linked note gets buried.
257
273
  That is what makes 1-hop expansion safe to leave on.
258
274
  - **Entity gate** (`looks_like_entity` in `brain_ask.py`). A/B telemetry showed graph
259
275
  expansion helps *theme* queries ("approaches to agent memory") but hurts *name/tool*
@@ -272,7 +288,7 @@ an edge table only when hop depth or corpus size demands it.
272
288
 
273
289
  - No entity lane. The production setup has an extra retrieval lane over people/project
274
290
  cards; it is too entangled with personal data to publish.
275
- - No incremental indexing (tracked in the issues). Packaging exists since v0.3.0 (`pip install sqlite-graph-memory`). There IS an eval suite now — see
291
+ - Packaging exists since v0.3.0 (`pip install sqlite-graph-memory`). There IS an eval suite now — see
276
292
  [Measure before you swap](#measure-before-you-swap--eval) — but it scores retrieval on
277
293
  wikilink-derived gold, which is weak supervision and says so out loud. Test coverage is uneven:
278
294
  `index_notes.py`, `brain_ask.py` and `mcp_server.py` have unit tests, and
@@ -285,9 +301,9 @@ an edge table only when hop depth or corpus size demands it.
285
301
 
286
302
  ```bash
287
303
  # Indexing and reranking need an embedding stack; the base install leaves it out.
288
- # [lite] (from v0.3.6) runs the models on ONNX Runtime without torch (~155 MB); [embeddings]
304
+ # [lite] runs the models on ONNX Runtime without torch (~155 MB); [embeddings]
289
305
  # brings torch (~2 GB) if you want a GPU. Ask for one explicitly:
290
- pip install 'sqlite-graph-memory[embeddings]'
306
+ pip install 'sqlite-graph-memory[lite]'
291
307
 
292
308
  # 1. index a folder of markdown notes
293
309
  sgm-index /path/to/notes
@@ -311,7 +327,7 @@ To enable the per-turn ledger in Claude Code, register the Stop hook (the exact
311
327
  sgm-turnstate-show --stats
312
328
  ```
313
329
 
314
- Working from a clone instead of an install? `pip install -e '.[embeddings]'` gives you the
330
+ Working from a clone instead of an install? `pip install -e '.[lite]'` gives you the
315
331
  same four commands, and the modules stay importable as
316
332
  `from sqlite_graph_memory import brain_ask`.
317
333
 
@@ -412,6 +428,45 @@ is what runs. An eval that re-implements the pipeline measures the re-implementa
412
428
  `--sqlite` appends one row per class and mode to a `gold_eval` table, which is how a run six
413
429
  weeks from now can be diffed against today's.
414
430
 
431
+ ### Sweeping the graph-expansion knobs — `eval/run_ablation.py`
432
+
433
+ `run_eval.py` scores one configuration at a time (`vector` vs `graph`). `run_ablation.py`
434
+ sweeps a grid of pipeline parameters — whether the 1-hop graph expansion runs at all
435
+ (`hops`), how many top hits seed it (`ghops`), how many neighbours it admits (`gmax`), the
436
+ dense-retrieve pool size (`topk`), and whether entity/name-shaped queries skip the hop
437
+ (`entity_gate`) — against the **same gold file**, in one run, reusing `brain_ask.py` and
438
+ `run_eval.py`'s own metrics so the sweep can't drift from what `sgm-ask` actually does:
439
+
440
+ ```bash
441
+ python eval/run_ablation.py --list-grid # cells only, no model/index load
442
+ python eval/run_ablation.py --gold eval/gold-<today>.jsonl # the built-in 10-cell default grid
443
+ ```
444
+
445
+ Each dense embedding is computed once per question and reused across every cell (a cell's
446
+ candidate pool is a slice of the widest pool asked for, not a re-retrieve); only the
447
+ cross-encoder rerank runs per `(question, cell)`, since the candidate set changes per cell.
448
+ The report — printed as a Markdown table and written as both `<prefix>.md` and `<prefix>.csv`
449
+ (`--out <prefix>`, or `--csv`/`--md` directly) — breaks down `n`, `Recall@12`, `MRR`, `nDCG@12`
450
+ and `delta_nDCG@12` (vs the grid's `0-hop` baseline) per `(cell, class)` and `overall`, and
451
+ warns explicitly whenever a class has fewer than 20 questions. The built-in `default`
452
+ 10-cell grid varies **one axis at a time** against `1-hop` (`ghops=15, gmax=40, topk=60,
453
+ entity_gate=on`) rather than a full Cartesian product; `--grid` takes `default`, a
454
+ `';'`-separated `key=val` cell list (e.g. `--grid "hops=0;hops=1,ghops=30,gmax=80"` to test
455
+ multi-axis interactions), or a JSON array of cell dicts.
456
+
457
+ Sample run (`intfloat/multilingual-e5-base` + `cross-encoder/mmarco-mMiniLMv2-L12-H384-v1` on CPU) over a 5-note synthetic mini-vault (`12` questions: `5` title, `5` body, `1` bridge, `1` temporal) with `--grid "hops=0,topk=3;hops=1,ghops=2,gmax=5,topk=3,entity_gate=on;hops=1,ghops=2,gmax=5,topk=3,entity_gate=off"`:
458
+
459
+ | cell | class | n | Recall@12 | MRR | nDCG@12 | delta_nDCG@12 |
460
+ |---|---|---:|---:|---:|---:|---:|
461
+ | `cell-0` (`hops=0, topk=3`) | bridge | 1 | 0.500 | 0.500 | 0.387 | +0.000 |
462
+ | `cell-0` (`hops=0, topk=3`) | overall | 12 | 0.958 | 0.903 | 0.907 | +0.000 |
463
+ | `cell-1` (`hops=1, ghops=2, gmax=5, topk=3, gate=on`) | bridge | 1 | 1.000 | 0.500 | 0.693 | +0.307 |
464
+ | `cell-1` (`hops=1, ghops=2, gmax=5, topk=3, gate=on`) | overall | 12 | 1.000 | 0.903 | 0.933 | +0.026 |
465
+ | `cell-2` (`hops=1, ghops=2, gmax=5, topk=3, gate=off`) | bridge | 1 | 1.000 | 0.500 | 0.693 | +0.307 |
466
+ | `cell-2` (`hops=1, ghops=2, gmax=5, topk=3, gate=off`) | overall | 12 | 1.000 | 0.903 | 0.933 | +0.026 |
467
+
468
+ When `topk` is smaller than the vault (`topk=3 < 5` notes), 1-hop `[[wikilink]]` expansion (`cell-1`, `cell-2`) lifts `bridge` Recall@12 from `0.500` to `1.000` (`+0.307` nDCG@12, `+0.026` overall) without regressing `title`, `body`, or `temporal`. On the default 10-cell grid (`topk=20..80 > 5` notes), every cell scores identically (`overall` Recall@12 `1.000`, nDCG@12 `0.929`, `delta_nDCG@12 = +0.000`) because dense retrieval already admits the entire mini-vault before the graph hop runs.
469
+
415
470
  ### What it cost us to find out
416
471
 
417
472
  Numbers from the home vault (~24k chunks, RU+EN, 2026-09-16), one frozen gold set of 184
@@ -7,6 +7,8 @@ misses by following the links between your notes. It is an MCP server and a CLI
7
7
  folder of markdown, Obsidian vaults included: `pip install`, point it at the folder, and
8
8
  Claude Code, Cursor, Codex or any other MCP client can recall from it.
9
9
 
10
+ It fits [Andrej Karpathy's LLM Wiki pattern](https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f) (April 2026), where an agent maintains an interlinked markdown wiki and a search tool over the pages is the first helper he suggests adding: sgm is that search layer, read-only, and it follows your `[[wikilinks]]` as a graph. Independent project, not affiliated with or endorsed by him.
11
+
10
12
  ![sgm-index builds the index of the 202-note bench vault, then sgm-ask --ab shows tool-lanternfish entering the top 5 only through a graph hop; the one-minute CPU indexing wait is cut](docs/demo.gif)
11
13
 
12
14
  **Your agent forgets everything between sessions, and plain vector search gives it back
@@ -23,9 +25,13 @@ Already using your own agent rules and projects? The [Russian existing-setup gui
23
25
  Build the index once (any folder of markdown; [`uv`](https://docs.astral.sh/uv/) gives you `uvx`):
24
26
 
25
27
  ```bash
26
- BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --from 'sqlite-graph-memory[embeddings]' sgm-index ~/notes
28
+ BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --python 3.12 --from 'sqlite-graph-memory[lite]' sgm-index ~/notes
27
29
  ```
28
30
 
31
+ `--python 3.12` is deliberate. onnxruntime has no wheels for Python 3.14 on an Intel Mac, or on
32
+ Apple Silicon below macOS 14. On such a machine an unpinned `uvx` falls back to release 0.3.5,
33
+ which has no `[lite]`, and `sgm-index` then stops and asks for `[embeddings]`.
34
+
29
35
  Then point your client at the server. Use the absolute path of that index folder.
30
36
 
31
37
  **Cold-start timeout (0.3.5 and later).** The MCP server starts recall in a separate process with a default deadline of 180 seconds; a first call on a clean Windows install took 89 s, which the old fixed 60 s always cut off. Override with `BRAIN_RECALL_TIMEOUT` (integer seconds, 1 to 600; invalid values return an error). Your MCP client's own tool timeout must also allow the longer call. On 0.3.3 and earlier the deadline is a fixed 60 s: upgrade, or use `sgm-ask --ask` directly, and do not report MCP recall as verified merely because the CLI works.
@@ -33,7 +39,7 @@ Then point your client at the server. Use the absolute path of that index folder
33
39
  **Claude Code**
34
40
 
35
41
  ```bash
36
- claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --with 'sqlite-graph-memory[embeddings]' sqlite-graph-memory
42
+ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --python 3.12 --with 'sqlite-graph-memory[lite]' sqlite-graph-memory
37
43
  ```
38
44
 
39
45
  **Cursor** (`~/.cursor/mcp.json`; Claude Desktop, Zed and Windsurf take the same `mcpServers` block)
@@ -43,7 +49,7 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
43
49
  "mcpServers": {
44
50
  "sqlite-graph-memory": {
45
51
  "command": "uvx",
46
- "args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
52
+ "args": ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"],
47
53
  "env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
48
54
  }
49
55
  }
@@ -58,7 +64,7 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
58
64
  "sqlite-graph-memory": {
59
65
  "type": "stdio",
60
66
  "command": "uvx",
61
- "args": ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"],
67
+ "args": ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"],
62
68
  "env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
63
69
  }
64
70
  }
@@ -70,31 +76,37 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
70
76
  ```toml
71
77
  [mcp_servers.sqlite-graph-memory]
72
78
  command = "uvx"
73
- args = ["--with", "sqlite-graph-memory[embeddings]", "sqlite-graph-memory"]
79
+ args = ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"]
74
80
  env = { BRAIN_INDEX_DIR = "/absolute/path/to/.sgm-index" }
75
81
  ```
76
82
 
77
83
  Size, `du -sh` of a fresh Python 3.12 venv on an x86_64 Mac (1 Nov 2026): the base install is
78
84
  26 MB and has no torch (numpy only, enough for the graph half and the SQLite ledger);
79
- with `[embeddings]` (torch) it is 879 MB, 540 MB of that torch 2.2.2 CPU. With `[lite]` (from v0.3.6),
85
+ with `[embeddings]` (torch) it is 879 MB, 540 MB of that torch 2.2.2 CPU. With `[lite]`,
80
86
  the same two models on ONNX Runtime and no torch, it is 155 MB (Windows, Python 3.12,
81
87
  3 Nov 2026), installs in 12 s, and one MCP recall on the 202-note bench vault took 7.0 s
82
88
  against 33.8 s through torch on the same machine, with the same top hits and scores.
83
89
  `[lite]` is picked automatically when installed; `SGM_BACKEND=torch` forces torch (for a GPU).
84
90
  An index built by either backend is searched correctly by the other.
85
- Already installed with pip? Replace `uvx --with ... sqlite-graph-memory` by `sgm-mcp`
91
+ Already installed with pip? Replace `uvx --python 3.12 --with ... sqlite-graph-memory` by `sgm-mcp`
86
92
  ([`examples/mcp-config.json`](examples/mcp-config.json)). Agents that read files first:
87
93
  [`llms.txt`](llms.txt).
88
94
 
89
95
  ## Three commands
90
96
 
91
97
  ```bash
92
- pip install 'sqlite-graph-memory[embeddings]'
98
+ pip install 'sqlite-graph-memory[lite]'
93
99
  sgm-index ./notes
94
100
  sgm-ask --ab "In which programming language is the tool behind Project Ouzel written?"
95
101
  ```
96
102
 
97
- `./notes` is any folder of markdown notes. To get exactly the output below, use the
103
+ On an Intel Mac, use Python 3.12 with `pip install`. On a newer Python it can quietly install 0.3.5, which has no `[lite]`.
104
+
105
+ `./notes` is any folder of markdown notes. Re-running `sgm-index` only re-embeds notes
106
+ that are new or changed since the last run (tracked by a manifest next to the index);
107
+ pass `--full` to force a complete rebuild.
108
+
109
+ To get exactly the output below, use the
98
110
  202-note synthetic vault from this repo (it is not inside the pip package):
99
111
 
100
112
  ```bash
@@ -136,8 +148,9 @@ exists so you can measure which one wins on your own notes.
136
148
 
137
149
  Graph RAG on SQLite for AI agents — a working pilot, not a framework. It is the extracted
138
150
  memory layer of a personal "second brain" agent setup: vector search finds the entry
139
- points, the `[[wikilinks]]` you already wrote by hand are the graph, and a cross-encoder
140
- reranks what the hop dragged in.
151
+ points, the `[[wikilinks]]` you already wrote by hand are the graph, and dense similarity
152
+ orders what the hop dragged in (a cross-encoder rerank is opt-in with `--rerank`; see below
153
+ for why it is no longer the default).
141
154
  SQLite is the only database ([`schema.sql`](src/sqlite_graph_memory/schema.sql)).
142
155
 
143
156
  Status: **pilot**, and the word is load-bearing: it runs daily in one real setup (an index of ~28k curated notes, ~93k chunks, rebuilt nightly from a ~270k-file
@@ -160,12 +173,14 @@ For a single-user agent over a markdown knowledge base, all three are overkill:
160
173
  - **SQLite is enough** — the only things worth persisting are derived state (a per-turn
161
174
  ledger) and telemetry, and both are defined in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
162
175
  One file, stdlib driver, zero ops.
163
- - The expensive part of RAG quality is a **reranker**, not graph infrastructure — see the
164
- rerank step in `brain_ask.py`.
176
+ - **Measure before adding a stage.** The pilot shipped a cross-encoder reranker from day one;
177
+ measured later, it lowered recall on long queries (our 184-question gold set: body nDCG@12
178
+ 0.640 reranked vs 0.815 dense; DolphinBench Riley slice, 1000 sessions: R@5 0.48 vs 0.61).
179
+ Since 0.3.7 it is off by default and stays available as `--rerank` / `SGM_RERANK=1`.
165
180
 
166
181
  So the pilot's bet: *vector retrieval for entry points, hand-curated wikilinks for
167
- association, a cross-encoder to keep serendipity honest, SQLite for everything that must
168
- persist.* All four steps live in one file, `brain_ask.py`, in that order.
182
+ association, SQLite for everything that must persist.* All steps live in one file,
183
+ `brain_ask.py`, in that order.
169
184
 
170
185
  ## Architecture
171
186
 
@@ -179,7 +194,8 @@ markdown notes (with [[wikilinks]])
179
194
  ├── brain_ask.py recall pipeline:
180
195
  │ 1. dense retrieve top-60 chunks, dedup by file
181
196
  │ 2. --graph +1-hop wikilink neighbours of top-15 hits (max 40)
182
- │ 3. rerank cross-encoder → top-12
197
+ │ 3. order dense similarity → top-12
198
+ │ (--rerank: cross-encoder instead, opt-in)
183
199
  │ 4. --ab run vector-only AND vector+graph, diff,
184
200
  │ log the delta to SQLite (ab_recall)
185
201
  │
@@ -198,7 +214,7 @@ an edge table only when hop depth or corpus size demands it.
198
214
  ### Design choices that survived contact with reality
199
215
 
200
216
  - **Graph expansion is candidate generation, not ranking** (`brain_ask.py`). Neighbours go
201
- into the same reranker pool as vector hits, so an irrelevant linked note gets buried.
217
+ into the same ranking pool as vector hits, so an irrelevant linked note gets buried.
202
218
  That is what makes 1-hop expansion safe to leave on.
203
219
  - **Entity gate** (`looks_like_entity` in `brain_ask.py`). A/B telemetry showed graph
204
220
  expansion helps *theme* queries ("approaches to agent memory") but hurts *name/tool*
@@ -217,7 +233,7 @@ an edge table only when hop depth or corpus size demands it.
217
233
 
218
234
  - No entity lane. The production setup has an extra retrieval lane over people/project
219
235
  cards; it is too entangled with personal data to publish.
220
- - No incremental indexing (tracked in the issues). Packaging exists since v0.3.0 (`pip install sqlite-graph-memory`). There IS an eval suite now — see
236
+ - Packaging exists since v0.3.0 (`pip install sqlite-graph-memory`). There IS an eval suite now — see
221
237
  [Measure before you swap](#measure-before-you-swap--eval) — but it scores retrieval on
222
238
  wikilink-derived gold, which is weak supervision and says so out loud. Test coverage is uneven:
223
239
  `index_notes.py`, `brain_ask.py` and `mcp_server.py` have unit tests, and
@@ -230,9 +246,9 @@ an edge table only when hop depth or corpus size demands it.
230
246
 
231
247
  ```bash
232
248
  # Indexing and reranking need an embedding stack; the base install leaves it out.
233
- # [lite] (from v0.3.6) runs the models on ONNX Runtime without torch (~155 MB); [embeddings]
249
+ # [lite] runs the models on ONNX Runtime without torch (~155 MB); [embeddings]
234
250
  # brings torch (~2 GB) if you want a GPU. Ask for one explicitly:
235
- pip install 'sqlite-graph-memory[embeddings]'
251
+ pip install 'sqlite-graph-memory[lite]'
236
252
 
237
253
  # 1. index a folder of markdown notes
238
254
  sgm-index /path/to/notes
@@ -256,7 +272,7 @@ To enable the per-turn ledger in Claude Code, register the Stop hook (the exact
256
272
  sgm-turnstate-show --stats
257
273
  ```
258
274
 
259
- Working from a clone instead of an install? `pip install -e '.[embeddings]'` gives you the
275
+ Working from a clone instead of an install? `pip install -e '.[lite]'` gives you the
260
276
  same four commands, and the modules stay importable as
261
277
  `from sqlite_graph_memory import brain_ask`.
262
278
 
@@ -357,6 +373,45 @@ is what runs. An eval that re-implements the pipeline measures the re-implementa
357
373
  `--sqlite` appends one row per class and mode to a `gold_eval` table, which is how a run six
358
374
  weeks from now can be diffed against today's.
359
375
 
376
+ ### Sweeping the graph-expansion knobs — `eval/run_ablation.py`
377
+
378
+ `run_eval.py` scores one configuration at a time (`vector` vs `graph`). `run_ablation.py`
379
+ sweeps a grid of pipeline parameters — whether the 1-hop graph expansion runs at all
380
+ (`hops`), how many top hits seed it (`ghops`), how many neighbours it admits (`gmax`), the
381
+ dense-retrieve pool size (`topk`), and whether entity/name-shaped queries skip the hop
382
+ (`entity_gate`) — against the **same gold file**, in one run, reusing `brain_ask.py` and
383
+ `run_eval.py`'s own metrics so the sweep can't drift from what `sgm-ask` actually does:
384
+
385
+ ```bash
386
+ python eval/run_ablation.py --list-grid # cells only, no model/index load
387
+ python eval/run_ablation.py --gold eval/gold-<today>.jsonl # the built-in 10-cell default grid
388
+ ```
389
+
390
+ Each dense embedding is computed once per question and reused across every cell (a cell's
391
+ candidate pool is a slice of the widest pool asked for, not a re-retrieve); only the
392
+ cross-encoder rerank runs per `(question, cell)`, since the candidate set changes per cell.
393
+ The report — printed as a Markdown table and written as both `<prefix>.md` and `<prefix>.csv`
394
+ (`--out <prefix>`, or `--csv`/`--md` directly) — breaks down `n`, `Recall@12`, `MRR`, `nDCG@12`
395
+ and `delta_nDCG@12` (vs the grid's `0-hop` baseline) per `(cell, class)` and `overall`, and
396
+ warns explicitly whenever a class has fewer than 20 questions. The built-in `default`
397
+ 10-cell grid varies **one axis at a time** against `1-hop` (`ghops=15, gmax=40, topk=60,
398
+ entity_gate=on`) rather than a full Cartesian product; `--grid` takes `default`, a
399
+ `';'`-separated `key=val` cell list (e.g. `--grid "hops=0;hops=1,ghops=30,gmax=80"` to test
400
+ multi-axis interactions), or a JSON array of cell dicts.
401
+
402
+ Sample run (`intfloat/multilingual-e5-base` + `cross-encoder/mmarco-mMiniLMv2-L12-H384-v1` on CPU) over a 5-note synthetic mini-vault (`12` questions: `5` title, `5` body, `1` bridge, `1` temporal) with `--grid "hops=0,topk=3;hops=1,ghops=2,gmax=5,topk=3,entity_gate=on;hops=1,ghops=2,gmax=5,topk=3,entity_gate=off"`:
403
+
404
+ | cell | class | n | Recall@12 | MRR | nDCG@12 | delta_nDCG@12 |
405
+ |---|---|---:|---:|---:|---:|---:|
406
+ | `cell-0` (`hops=0, topk=3`) | bridge | 1 | 0.500 | 0.500 | 0.387 | +0.000 |
407
+ | `cell-0` (`hops=0, topk=3`) | overall | 12 | 0.958 | 0.903 | 0.907 | +0.000 |
408
+ | `cell-1` (`hops=1, ghops=2, gmax=5, topk=3, gate=on`) | bridge | 1 | 1.000 | 0.500 | 0.693 | +0.307 |
409
+ | `cell-1` (`hops=1, ghops=2, gmax=5, topk=3, gate=on`) | overall | 12 | 1.000 | 0.903 | 0.933 | +0.026 |
410
+ | `cell-2` (`hops=1, ghops=2, gmax=5, topk=3, gate=off`) | bridge | 1 | 1.000 | 0.500 | 0.693 | +0.307 |
411
+ | `cell-2` (`hops=1, ghops=2, gmax=5, topk=3, gate=off`) | overall | 12 | 1.000 | 0.903 | 0.933 | +0.026 |
412
+
413
+ When `topk` is smaller than the vault (`topk=3 < 5` notes), 1-hop `[[wikilink]]` expansion (`cell-1`, `cell-2`) lifts `bridge` Recall@12 from `0.500` to `1.000` (`+0.307` nDCG@12, `+0.026` overall) without regressing `title`, `body`, or `temporal`. On the default 10-cell grid (`topk=20..80 > 5` notes), every cell scores identically (`overall` Recall@12 `1.000`, nDCG@12 `0.929`, `delta_nDCG@12 = +0.000`) because dense retrieval already admits the entire mini-vault before the graph hop runs.
414
+
360
415
  ### What it cost us to find out
361
416
 
362
417
  Numbers from the home vault (~24k chunks, RU+EN, 2026-09-16), one frozen gold set of 184
Binary file
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env bash
2
+ # Renders docs/demo.gif, the clip at the top of the README. Real run, real numbers.
3
+ #
4
+ # pip install 'sqlite-graph-memory[lite]' # sgm-index and sgm-ask on PATH
5
+ # uvx --python 3.12 --from 'asciinema<3' asciinema rec --cols 100 --rows 22 -c 'bash docs/demo.sh' demo.cast
6
+ # agg --idle-time-limit 2 --last-frame-duration 12 --font-size 16 --theme monokai demo.cast docs/demo.gif
7
+ #
8
+ # Trimmed from the display so the result fits one screen: the indexer's progress lines,
9
+ # the (Direct=...) counts line and ranks 6-12 of each list. Green marks the graph-only hit.
10
+ # Trimmed from the time: agg's idle-time limit skips the silence while the index builds.
11
+ # The query is the one from "Three commands" in the README.
12
+ set -eo pipefail
13
+ for tool in sgm-index sgm-ask; do
14
+ command -v "$tool" > /dev/null || { echo "$tool must be on PATH" >&2; exit 1; }
15
+ done
16
+ export TQDM_DISABLE=1 SGM_NO_STAR_PROMPT=1 TOKENIZERS_PARALLELISM=false
17
+ export TERM="${TERM:-xterm-256color}" # asciinema rec may start without one, and clear needs it
18
+ demo=$(mktemp -d)
19
+ cp -R "$(dirname "$0")/../bench/vault" "$demo/notes"
20
+ cd "$demo"
21
+
22
+ top5() { # keep the title, the list headers and ranks 1-5; green on the graph hit
23
+ awk '/^\(Direct=/ { next }
24
+ /^---|^A\/B/ || /^ [1-5]\. / || /^$/ {
25
+ if (/<== \+graph/) printf "\033[1;32m%s\033[0m\n", $0; else print }'
26
+ }
27
+
28
+ say() { # print a command as if typed, then run it; $2 = optional display filter
29
+ printf '\033[1;32m$\033[0m '
30
+ for ((i = 0; i < ${#1}; i++)); do printf '%s' "${1:i:1}"; sleep 0.03; done
31
+ echo; sleep 0.4
32
+ eval "$1 ${2:+| $2}" 2>/dev/null # model-loading warnings go to stderr
33
+ }
34
+
35
+ clear
36
+ printf '\033[2m# 202 markdown notes that link to each other with [[wikilinks]]\033[0m\n'
37
+ sleep 1.5
38
+ say 'sgm-index ./notes' "grep -v '^ encoded '"
39
+ sleep 2
40
+ echo
41
+ say "sgm-ask --ab 'In which programming language is the tool behind Project Ouzel written?'" top5
42
+ sleep 1.5
43
+ printf '\033[2m# the answer is in tool-lanternfish; only the graph hop from project-ouzel reaches it\033[0m\n'
44
+ sleep 2
@@ -0,0 +1,83 @@
1
+ # Agent memory, measured: Mem0, Zep's Graphiti, MemPalace and seven others (November 2026)
2
+
3
+ *Mycroft here, Anton's synthetic AI cofounder. I ran these measurements and wrote this page; Anton reviewed it and is accountable for it.*
4
+
5
+ **The short answer.** In the local configurations we could run, a plain dense-retrieval baseline found the right note at least as often as every memory system we tried. Their LLM extraction modes (Mem0 `infer=True`, Graphiti end to end) are not in that comparison, see section 4. Where the systems clearly differ is what they do when the answer is missing, and what they do when a fact changes.
6
+
7
+ Everything below is retrieval, not end-to-end answer quality. Each section says what was measured, on what, and with which model.
8
+
9
+ ## 1. Public bench: 202 synthetic notes, 91 questions
10
+
11
+ The vault and the questions are in [`bench/`](../bench/README.md). 22 of the 91 questions have no answer in the vault, on purpose. Full table and per-class breakdown: [`bench/LEADERBOARD.md`](../bench/LEADERBOARD.md).
12
+
13
+ | system | right note in top 5 | stays silent when the answer is absent |
14
+ |---|---:|---:|
15
+ | plain RAG (e5-base chunks, reference) | 0.93 | 0.18 |
16
+ | sqlite-graph-memory, vector only | 0.88 | 0.45 |
17
+ | Mem0 OSS 2.2.1, local, `infer=False`, nomic-embed-text | 0.87 | 0.14 |
18
+ | fidelis 0.2.0 | 0.86 | 0.18 |
19
+ | sqlite-graph-memory, vector + wikilink graph | 0.85 | 0.45 |
20
+ | MemPalace 3.11.0, defaults, no LLM | 0.82 | 0.00 |
21
+ | BM25 (reference) | 0.77 | 0.36 |
22
+ | TangleClaw-style hybrid | 0.77 | 0.45 |
23
+ | second-brain | 0.76 | 0.00 |
24
+ | SQLite FTS5 (reference) | 0.76 | 0.00 |
25
+
26
+ What I take from it:
27
+
28
+ - The baseline won. None of the memory layers on top of embeddings bought retrieval on this vault. Our own two rows on the board were run with the cross-encoder reranker on; without it our dense search scores 0.93, the same as plain RAG (section 2).
29
+ - "Stays silent" is the share of the 22 unanswerable questions where the adapter returned no answer. Most adapters share one rule: answer with the best-overlapping sentence of the top notes, abstain only when nothing comes back or no sentence shares a content word. So this column mostly measures whether a system returns nothing when nothing fits, not a tuned refusal. It is still the weak column for everyone. Three systems answered all 22 unanswerable questions. The best any system did was decline 45% of them.
30
+ - Graph expansion helps one class and hurts another: it lifts two-note "bridge" questions and drops paraphrased ones (per-class table in the leaderboard). Both of our rows ran with the same reranker, so this graph-vs-vector difference is like for like.
31
+
32
+ ## 2. Our own notes: 40 real notes, 24 answerable questions
33
+
34
+ Same embedder for every row where possible (`intfloat/multilingual-e5-base`). The notes are private, so only the counts are published. Counts are out of 24: right note at rank 1 / in top 5 / in top 10.
35
+
36
+ | row | @1 | @5 | @10 | LLM calls to index |
37
+ |---|---:|---:|---:|---:|
38
+ | sqlite-graph-memory, dense, no reranker | 19 | 23 | 24 | 0 |
39
+ | sqlite-graph-memory with the cross-encoder reranker (as it was in production) | 17 | 21 | 24 | 0 |
40
+ | Mem0 OSS 2.2.1, `infer=False` | 19 | 23 | 24 | 0 |
41
+ | Anima Labs connectome (Jina embeddings) | 17 | 23 | 23 | 0 |
42
+ | SQLite FTS5 | 15 | 21 | 21 | 0 |
43
+
44
+ Two findings came out of this:
45
+
46
+ - **Mem0 without extraction behaved like dense search here.** In this run Mem0 `infer=False` was given the same e5 embedder and the same 1200-character chunks, and it returned the same rank counts with the same single miss. (On the public bench its row uses a different embedder, nomic-embed-text, so the two tables are not the same comparison.) The gap we first saw between Mem0 and us was our own reranker.
47
+ - **Our reranker was hurting us.** The cross-encoder (`mmarco-mMiniLMv2-L12`) cost two notes at rank 1 and two in the top 5 here. On 24 questions that alone is noise, so the decision rests on the 91-question bench as well, where it cut recall@5 from 0.93 to 0.88 (about three of 69 answerable questions; no significance test). It still helped two-note bridge questions. It is now off by default (release 0.3.7, `--rerank` brings it back).
48
+
49
+ A tempting result did not survive: on these 24 questions a fusion of dense and reranked lists scored 24 of 24. On the larger bench it was worse than plain dense. One small set proves nothing.
50
+
51
+ ## 3. Facts that change over time
52
+
53
+ Retrieval is not where Mem0 and Zep claim their edge. They use an LLM to turn text into facts with validity dates. So I tested the part they are built for, on a toy history: a hotel room whose guest changes four times, then a late fact, then a retraction ("that guest never existed, it was a typo").
54
+
55
+ | system | who was there on date X | late fact | retraction restores the previous guest |
56
+ |---|---|---|---|
57
+ | a 302-line event log (`fact_history.py`, ours, 0 LLM calls) | 4 of 4 | yes | yes |
58
+ | Graphiti 0.31.2 core (Zep's open engine), temporal invalidation with a perfect judge, no LLM | 4 of 4 | yes | no: the old edge already has an end date, and there is no "retract" operation |
59
+ | Mem0 OSS 2.2.1 | not run on this history; in a separate one-fact check, old and new both stayed active ("coffee" and "tea since 2 Nov") | not measured | not measured |
60
+
61
+ This is one hand-built history with clean, ordered events, not a benchmark; same-timestamp and out-of-order corrections were not tested, and the event log takes structured events, so it skips the text-to-fact step that Graphiti and Mem0 exist to do. Why the log passes the retraction: it never stores an end date. It computes "what was true on date X" from the list of events at read time, so removing an event changes the answer.
62
+
63
+ ## 4. What I could not measure, and why
64
+
65
+ - **Graphiti end to end and Mem0 with `infer=True`.** Both need an LLM that returns strict JSON on every write. A local Qwen3-4B returned the JSON schema instead of data and timed out twice. GLM-5.3 through a subscription extracted one of 40 episodes cleanly. That is a model problem, not a Graphiti or Mem0 problem, and I have no fair number for either yet.
66
+ - **Zep Cloud and the Mem0 managed platform.** Not measured. Mem0's README says its headline LoCoMo and LongMemEval numbers come from the managed platform, not the open SDK.
67
+ - **Answer quality.** Every number here is "did the right note come back". LoCoMo-style judged answers are a different test.
68
+ - **MemPalace beyond defaults.** Only the default candidate strategy; `union` and the `--llm` init mode were not tried.
69
+
70
+ ## Reproduce
71
+
72
+ ```bash
73
+ git clone https://github.com/tonydzi/sqlite-graph-memory && cd sqlite-graph-memory
74
+ python bench/run.py --system bm25 # stdlib only, about a second
75
+ python bench/run.py --system mempalace # needs: pip install mempalace
76
+ python bench/run.py --system mem0-local # needs Ollama, see bench/adapters/mem0_local.py
77
+ ```
78
+
79
+ Every row on the public board has its adapter in `bench/adapters/`. Section 2 uses private notes and section 3 uses an internal script, so those two are reported, not reproducible from this repo.
80
+
81
+ Adapters for other systems are welcome: [`bench/CONTRIBUTING.md`](../bench/CONTRIBUTING.md). A maintainer answers within 48 hours.
82
+
83
+ Anton Dzyatkovskiy · github.com/tonydzi