sqlite-graph-memory 0.3.6__tar.gz → 0.3.7__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.
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/CHANGELOG.md +24 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/PKG-INFO +75 -22
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/README.md +74 -21
- sqlite_graph_memory-0.3.7/docs/demo.gif +0 -0
- sqlite_graph_memory-0.3.7/docs/demo.sh +44 -0
- sqlite_graph_memory-0.3.7/eval/run_ablation.py +267 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/eval/run_eval.py +9 -5
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/examples/README.md +1 -1
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/examples/mcp-config.json +1 -1
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/pyproject.toml +1 -1
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/__init__.py +1 -1
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/brain_ask.py +117 -18
- sqlite_graph_memory-0.3.7/src/sqlite_graph_memory/index_notes.py +280 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/mcp_server.py +1 -1
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/vault_stats.py +17 -3
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_bench.py +44 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_brain_ask.py +78 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_eval.py +169 -1
- sqlite_graph_memory-0.3.7/tests/test_incremental_index.py +307 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_onnx_backend.py +19 -0
- sqlite_graph_memory-0.3.7/tests/test_rerank_default.py +53 -0
- sqlite_graph_memory-0.3.7/tests/test_rerank_flag_eval.py +22 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_star_prompt.py +1 -1
- sqlite_graph_memory-0.3.7/tests/test_uvx_python_pin.py +75 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_vault_stats.py +35 -0
- sqlite_graph_memory-0.3.6/docs/demo.gif +0 -0
- sqlite_graph_memory-0.3.6/docs/demo.sh +0 -33
- sqlite_graph_memory-0.3.6/src/sqlite_graph_memory/index_notes.py +0 -160
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/.gitignore +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/CITATION.cff +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/LICENSE +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/bench/README.md +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/bench/requirements.txt +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/docs/RELEASING.md +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/docs/bitemporal.md +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/eval/build_gold.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/examples/claude-code-stop-hook.json +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/requirements.txt +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/doctor.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/onnx_backend.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/ppr.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/schema.sql +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/turnstate_hook.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/src/sqlite_graph_memory/turnstate_show.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_changelog_released.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_doctor.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_feedback_link.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_index_notes.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_index_notes_dotfiles.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_llms_txt.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_mcp_script_mode.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_mcp_server.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_optional_extra.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_ppr.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_turnstate_hook.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_turnstate_show.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_version_consistent.py +0 -0
- {sqlite_graph_memory-0.3.6 → sqlite_graph_memory-0.3.7}/tests/test_version_flag.py +0 -0
|
@@ -6,6 +6,30 @@ recorded after the fact rather than backdated to look contemporaneous.
|
|
|
6
6
|
|
|
7
7
|
## Unreleased
|
|
8
8
|
|
|
9
|
+
## v0.3.7 - 2026-11-05
|
|
10
|
+
|
|
11
|
+
**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.
|
|
12
|
+
|
|
13
|
+
**`uvx` install lines work on a newer default Python.** On an Intel Mac whose `uv` defaults to Python
|
|
14
|
+
3.14, `uvx --from 'sqlite-graph-memory[lite]' ...` fell back to release 0.3.5, which has no `[lite]`, and
|
|
15
|
+
`sgm-index` stopped with a hint to install `[embeddings]`. Apple Silicon below macOS 14 resolves the same
|
|
16
|
+
way. The `uvx` lines in the docs now pin `--python 3.12`; `server.json` does too, and that reaches the MCP
|
|
17
|
+
Registry with this release.
|
|
18
|
+
|
|
19
|
+
**Shorter demo gif.** It now shows the top 5 of each list, so the graph hit fits on one screen.
|
|
20
|
+
|
|
21
|
+
**`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.
|
|
22
|
+
|
|
23
|
+
**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.
|
|
24
|
+
|
|
25
|
+
**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.
|
|
26
|
+
|
|
27
|
+
**`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.
|
|
28
|
+
|
|
29
|
+
**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).
|
|
30
|
+
|
|
31
|
+
**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.
|
|
32
|
+
|
|
9
33
|
## v0.3.6 - 2026-11-03
|
|
10
34
|
|
|
11
35
|
**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.
|
|
3
|
+
Version: 0.3.7
|
|
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
|
|
@@ -78,9 +78,13 @@ Already using your own agent rules and projects? The [Russian existing-setup gui
|
|
|
78
78
|
Build the index once (any folder of markdown; [`uv`](https://docs.astral.sh/uv/) gives you `uvx`):
|
|
79
79
|
|
|
80
80
|
```bash
|
|
81
|
-
BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --from 'sqlite-graph-memory[
|
|
81
|
+
BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --python 3.12 --from 'sqlite-graph-memory[lite]' sgm-index ~/notes
|
|
82
82
|
```
|
|
83
83
|
|
|
84
|
+
`--python 3.12` is deliberate. onnxruntime has no wheels for Python 3.14 on an Intel Mac, or on
|
|
85
|
+
Apple Silicon below macOS 14. On such a machine an unpinned `uvx` falls back to release 0.3.5,
|
|
86
|
+
which has no `[lite]`, and `sgm-index` then stops and asks for `[embeddings]`.
|
|
87
|
+
|
|
84
88
|
Then point your client at the server. Use the absolute path of that index folder.
|
|
85
89
|
|
|
86
90
|
**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 +92,7 @@ Then point your client at the server. Use the absolute path of that index folder
|
|
|
88
92
|
**Claude Code**
|
|
89
93
|
|
|
90
94
|
```bash
|
|
91
|
-
claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --with 'sqlite-graph-memory[
|
|
95
|
+
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
96
|
```
|
|
93
97
|
|
|
94
98
|
**Cursor** (`~/.cursor/mcp.json`; Claude Desktop, Zed and Windsurf take the same `mcpServers` block)
|
|
@@ -98,7 +102,7 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
|
|
|
98
102
|
"mcpServers": {
|
|
99
103
|
"sqlite-graph-memory": {
|
|
100
104
|
"command": "uvx",
|
|
101
|
-
"args": ["--with", "sqlite-graph-memory[
|
|
105
|
+
"args": ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"],
|
|
102
106
|
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
|
|
103
107
|
}
|
|
104
108
|
}
|
|
@@ -113,7 +117,7 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
|
|
|
113
117
|
"sqlite-graph-memory": {
|
|
114
118
|
"type": "stdio",
|
|
115
119
|
"command": "uvx",
|
|
116
|
-
"args": ["--with", "sqlite-graph-memory[
|
|
120
|
+
"args": ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"],
|
|
117
121
|
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
|
|
118
122
|
}
|
|
119
123
|
}
|
|
@@ -125,31 +129,37 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
|
|
|
125
129
|
```toml
|
|
126
130
|
[mcp_servers.sqlite-graph-memory]
|
|
127
131
|
command = "uvx"
|
|
128
|
-
args = ["--with", "sqlite-graph-memory[
|
|
132
|
+
args = ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"]
|
|
129
133
|
env = { BRAIN_INDEX_DIR = "/absolute/path/to/.sgm-index" }
|
|
130
134
|
```
|
|
131
135
|
|
|
132
136
|
Size, `du -sh` of a fresh Python 3.12 venv on an x86_64 Mac (1 Nov 2026): the base install is
|
|
133
137
|
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]
|
|
138
|
+
with `[embeddings]` (torch) it is 879 MB, 540 MB of that torch 2.2.2 CPU. With `[lite]`,
|
|
135
139
|
the same two models on ONNX Runtime and no torch, it is 155 MB (Windows, Python 3.12,
|
|
136
140
|
3 Nov 2026), installs in 12 s, and one MCP recall on the 202-note bench vault took 7.0 s
|
|
137
141
|
against 33.8 s through torch on the same machine, with the same top hits and scores.
|
|
138
142
|
`[lite]` is picked automatically when installed; `SGM_BACKEND=torch` forces torch (for a GPU).
|
|
139
143
|
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`
|
|
144
|
+
Already installed with pip? Replace `uvx --python 3.12 --with ... sqlite-graph-memory` by `sgm-mcp`
|
|
141
145
|
([`examples/mcp-config.json`](examples/mcp-config.json)). Agents that read files first:
|
|
142
146
|
[`llms.txt`](llms.txt).
|
|
143
147
|
|
|
144
148
|
## Three commands
|
|
145
149
|
|
|
146
150
|
```bash
|
|
147
|
-
pip install 'sqlite-graph-memory[
|
|
151
|
+
pip install 'sqlite-graph-memory[lite]'
|
|
148
152
|
sgm-index ./notes
|
|
149
153
|
sgm-ask --ab "In which programming language is the tool behind Project Ouzel written?"
|
|
150
154
|
```
|
|
151
155
|
|
|
152
|
-
|
|
156
|
+
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]`.
|
|
157
|
+
|
|
158
|
+
`./notes` is any folder of markdown notes. Re-running `sgm-index` only re-embeds notes
|
|
159
|
+
that are new or changed since the last run (tracked by a manifest next to the index);
|
|
160
|
+
pass `--full` to force a complete rebuild.
|
|
161
|
+
|
|
162
|
+
To get exactly the output below, use the
|
|
153
163
|
202-note synthetic vault from this repo (it is not inside the pip package):
|
|
154
164
|
|
|
155
165
|
```bash
|
|
@@ -191,8 +201,9 @@ exists so you can measure which one wins on your own notes.
|
|
|
191
201
|
|
|
192
202
|
Graph RAG on SQLite for AI agents — a working pilot, not a framework. It is the extracted
|
|
193
203
|
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
|
|
195
|
-
|
|
204
|
+
points, the `[[wikilinks]]` you already wrote by hand are the graph, and dense similarity
|
|
205
|
+
orders what the hop dragged in (a cross-encoder rerank is opt-in with `--rerank`; see below
|
|
206
|
+
for why it is no longer the default).
|
|
196
207
|
SQLite is the only database ([`schema.sql`](src/sqlite_graph_memory/schema.sql)).
|
|
197
208
|
|
|
198
209
|
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 +226,14 @@ For a single-user agent over a markdown knowledge base, all three are overkill:
|
|
|
215
226
|
- **SQLite is enough** — the only things worth persisting are derived state (a per-turn
|
|
216
227
|
ledger) and telemetry, and both are defined in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
217
228
|
One file, stdlib driver, zero ops.
|
|
218
|
-
-
|
|
219
|
-
|
|
229
|
+
- **Measure before adding a stage.** The pilot shipped a cross-encoder reranker from day one;
|
|
230
|
+
measured later, it lowered recall on long queries (our 184-question gold set: body nDCG@12
|
|
231
|
+
0.640 reranked vs 0.815 dense; DolphinBench Riley slice, 1000 sessions: R@5 0.48 vs 0.61).
|
|
232
|
+
Since 0.3.7 it is off by default and stays available as `--rerank` / `SGM_RERANK=1`.
|
|
220
233
|
|
|
221
234
|
So the pilot's bet: *vector retrieval for entry points, hand-curated wikilinks for
|
|
222
|
-
association,
|
|
223
|
-
|
|
235
|
+
association, SQLite for everything that must persist.* All steps live in one file,
|
|
236
|
+
`brain_ask.py`, in that order.
|
|
224
237
|
|
|
225
238
|
## Architecture
|
|
226
239
|
|
|
@@ -234,7 +247,8 @@ markdown notes (with [[wikilinks]])
|
|
|
234
247
|
├── brain_ask.py recall pipeline:
|
|
235
248
|
│ 1. dense retrieve top-60 chunks, dedup by file
|
|
236
249
|
│ 2. --graph +1-hop wikilink neighbours of top-15 hits (max 40)
|
|
237
|
-
│ 3.
|
|
250
|
+
│ 3. order dense similarity → top-12
|
|
251
|
+
│ (--rerank: cross-encoder instead, opt-in)
|
|
238
252
|
│ 4. --ab run vector-only AND vector+graph, diff,
|
|
239
253
|
│ log the delta to SQLite (ab_recall)
|
|
240
254
|
│
|
|
@@ -253,7 +267,7 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
253
267
|
### Design choices that survived contact with reality
|
|
254
268
|
|
|
255
269
|
- **Graph expansion is candidate generation, not ranking** (`brain_ask.py`). Neighbours go
|
|
256
|
-
into the same
|
|
270
|
+
into the same ranking pool as vector hits, so an irrelevant linked note gets buried.
|
|
257
271
|
That is what makes 1-hop expansion safe to leave on.
|
|
258
272
|
- **Entity gate** (`looks_like_entity` in `brain_ask.py`). A/B telemetry showed graph
|
|
259
273
|
expansion helps *theme* queries ("approaches to agent memory") but hurts *name/tool*
|
|
@@ -272,7 +286,7 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
272
286
|
|
|
273
287
|
- No entity lane. The production setup has an extra retrieval lane over people/project
|
|
274
288
|
cards; it is too entangled with personal data to publish.
|
|
275
|
-
-
|
|
289
|
+
- Packaging exists since v0.3.0 (`pip install sqlite-graph-memory`). There IS an eval suite now — see
|
|
276
290
|
[Measure before you swap](#measure-before-you-swap--eval) — but it scores retrieval on
|
|
277
291
|
wikilink-derived gold, which is weak supervision and says so out loud. Test coverage is uneven:
|
|
278
292
|
`index_notes.py`, `brain_ask.py` and `mcp_server.py` have unit tests, and
|
|
@@ -285,9 +299,9 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
285
299
|
|
|
286
300
|
```bash
|
|
287
301
|
# Indexing and reranking need an embedding stack; the base install leaves it out.
|
|
288
|
-
# [lite]
|
|
302
|
+
# [lite] runs the models on ONNX Runtime without torch (~155 MB); [embeddings]
|
|
289
303
|
# brings torch (~2 GB) if you want a GPU. Ask for one explicitly:
|
|
290
|
-
pip install 'sqlite-graph-memory[
|
|
304
|
+
pip install 'sqlite-graph-memory[lite]'
|
|
291
305
|
|
|
292
306
|
# 1. index a folder of markdown notes
|
|
293
307
|
sgm-index /path/to/notes
|
|
@@ -311,7 +325,7 @@ To enable the per-turn ledger in Claude Code, register the Stop hook (the exact
|
|
|
311
325
|
sgm-turnstate-show --stats
|
|
312
326
|
```
|
|
313
327
|
|
|
314
|
-
Working from a clone instead of an install? `pip install -e '.[
|
|
328
|
+
Working from a clone instead of an install? `pip install -e '.[lite]'` gives you the
|
|
315
329
|
same four commands, and the modules stay importable as
|
|
316
330
|
`from sqlite_graph_memory import brain_ask`.
|
|
317
331
|
|
|
@@ -412,6 +426,45 @@ is what runs. An eval that re-implements the pipeline measures the re-implementa
|
|
|
412
426
|
`--sqlite` appends one row per class and mode to a `gold_eval` table, which is how a run six
|
|
413
427
|
weeks from now can be diffed against today's.
|
|
414
428
|
|
|
429
|
+
### Sweeping the graph-expansion knobs — `eval/run_ablation.py`
|
|
430
|
+
|
|
431
|
+
`run_eval.py` scores one configuration at a time (`vector` vs `graph`). `run_ablation.py`
|
|
432
|
+
sweeps a grid of pipeline parameters — whether the 1-hop graph expansion runs at all
|
|
433
|
+
(`hops`), how many top hits seed it (`ghops`), how many neighbours it admits (`gmax`), the
|
|
434
|
+
dense-retrieve pool size (`topk`), and whether entity/name-shaped queries skip the hop
|
|
435
|
+
(`entity_gate`) — against the **same gold file**, in one run, reusing `brain_ask.py` and
|
|
436
|
+
`run_eval.py`'s own metrics so the sweep can't drift from what `sgm-ask` actually does:
|
|
437
|
+
|
|
438
|
+
```bash
|
|
439
|
+
python eval/run_ablation.py --list-grid # cells only, no model/index load
|
|
440
|
+
python eval/run_ablation.py --gold eval/gold-<today>.jsonl # the built-in 10-cell default grid
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
Each dense embedding is computed once per question and reused across every cell (a cell's
|
|
444
|
+
candidate pool is a slice of the widest pool asked for, not a re-retrieve); only the
|
|
445
|
+
cross-encoder rerank runs per `(question, cell)`, since the candidate set changes per cell.
|
|
446
|
+
The report — printed as a Markdown table and written as both `<prefix>.md` and `<prefix>.csv`
|
|
447
|
+
(`--out <prefix>`, or `--csv`/`--md` directly) — breaks down `n`, `Recall@12`, `MRR`, `nDCG@12`
|
|
448
|
+
and `delta_nDCG@12` (vs the grid's `0-hop` baseline) per `(cell, class)` and `overall`, and
|
|
449
|
+
warns explicitly whenever a class has fewer than 20 questions. The built-in `default`
|
|
450
|
+
10-cell grid varies **one axis at a time** against `1-hop` (`ghops=15, gmax=40, topk=60,
|
|
451
|
+
entity_gate=on`) rather than a full Cartesian product; `--grid` takes `default`, a
|
|
452
|
+
`';'`-separated `key=val` cell list (e.g. `--grid "hops=0;hops=1,ghops=30,gmax=80"` to test
|
|
453
|
+
multi-axis interactions), or a JSON array of cell dicts.
|
|
454
|
+
|
|
455
|
+
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"`:
|
|
456
|
+
|
|
457
|
+
| cell | class | n | Recall@12 | MRR | nDCG@12 | delta_nDCG@12 |
|
|
458
|
+
|---|---|---:|---:|---:|---:|---:|
|
|
459
|
+
| `cell-0` (`hops=0, topk=3`) | bridge | 1 | 0.500 | 0.500 | 0.387 | +0.000 |
|
|
460
|
+
| `cell-0` (`hops=0, topk=3`) | overall | 12 | 0.958 | 0.903 | 0.907 | +0.000 |
|
|
461
|
+
| `cell-1` (`hops=1, ghops=2, gmax=5, topk=3, gate=on`) | bridge | 1 | 1.000 | 0.500 | 0.693 | +0.307 |
|
|
462
|
+
| `cell-1` (`hops=1, ghops=2, gmax=5, topk=3, gate=on`) | overall | 12 | 1.000 | 0.903 | 0.933 | +0.026 |
|
|
463
|
+
| `cell-2` (`hops=1, ghops=2, gmax=5, topk=3, gate=off`) | bridge | 1 | 1.000 | 0.500 | 0.693 | +0.307 |
|
|
464
|
+
| `cell-2` (`hops=1, ghops=2, gmax=5, topk=3, gate=off`) | overall | 12 | 1.000 | 0.903 | 0.933 | +0.026 |
|
|
465
|
+
|
|
466
|
+
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.
|
|
467
|
+
|
|
415
468
|
### What it cost us to find out
|
|
416
469
|
|
|
417
470
|
Numbers from the home vault (~24k chunks, RU+EN, 2026-09-16), one frozen gold set of 184
|
|
@@ -23,9 +23,13 @@ Already using your own agent rules and projects? The [Russian existing-setup gui
|
|
|
23
23
|
Build the index once (any folder of markdown; [`uv`](https://docs.astral.sh/uv/) gives you `uvx`):
|
|
24
24
|
|
|
25
25
|
```bash
|
|
26
|
-
BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --from 'sqlite-graph-memory[
|
|
26
|
+
BRAIN_INDEX_DIR=$HOME/.sgm-index uvx --python 3.12 --from 'sqlite-graph-memory[lite]' sgm-index ~/notes
|
|
27
27
|
```
|
|
28
28
|
|
|
29
|
+
`--python 3.12` is deliberate. onnxruntime has no wheels for Python 3.14 on an Intel Mac, or on
|
|
30
|
+
Apple Silicon below macOS 14. On such a machine an unpinned `uvx` falls back to release 0.3.5,
|
|
31
|
+
which has no `[lite]`, and `sgm-index` then stops and asks for `[embeddings]`.
|
|
32
|
+
|
|
29
33
|
Then point your client at the server. Use the absolute path of that index folder.
|
|
30
34
|
|
|
31
35
|
**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 +37,7 @@ Then point your client at the server. Use the absolute path of that index folder
|
|
|
33
37
|
**Claude Code**
|
|
34
38
|
|
|
35
39
|
```bash
|
|
36
|
-
claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --with 'sqlite-graph-memory[
|
|
40
|
+
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
41
|
```
|
|
38
42
|
|
|
39
43
|
**Cursor** (`~/.cursor/mcp.json`; Claude Desktop, Zed and Windsurf take the same `mcpServers` block)
|
|
@@ -43,7 +47,7 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
|
|
|
43
47
|
"mcpServers": {
|
|
44
48
|
"sqlite-graph-memory": {
|
|
45
49
|
"command": "uvx",
|
|
46
|
-
"args": ["--with", "sqlite-graph-memory[
|
|
50
|
+
"args": ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"],
|
|
47
51
|
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
|
|
48
52
|
}
|
|
49
53
|
}
|
|
@@ -58,7 +62,7 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
|
|
|
58
62
|
"sqlite-graph-memory": {
|
|
59
63
|
"type": "stdio",
|
|
60
64
|
"command": "uvx",
|
|
61
|
-
"args": ["--with", "sqlite-graph-memory[
|
|
65
|
+
"args": ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"],
|
|
62
66
|
"env": { "BRAIN_INDEX_DIR": "/absolute/path/to/.sgm-index" }
|
|
63
67
|
}
|
|
64
68
|
}
|
|
@@ -70,31 +74,37 @@ claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=$HOME/.sgm-index -- uvx --
|
|
|
70
74
|
```toml
|
|
71
75
|
[mcp_servers.sqlite-graph-memory]
|
|
72
76
|
command = "uvx"
|
|
73
|
-
args = ["--with", "sqlite-graph-memory[
|
|
77
|
+
args = ["--python", "3.12", "--with", "sqlite-graph-memory[lite]", "sqlite-graph-memory"]
|
|
74
78
|
env = { BRAIN_INDEX_DIR = "/absolute/path/to/.sgm-index" }
|
|
75
79
|
```
|
|
76
80
|
|
|
77
81
|
Size, `du -sh` of a fresh Python 3.12 venv on an x86_64 Mac (1 Nov 2026): the base install is
|
|
78
82
|
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]
|
|
83
|
+
with `[embeddings]` (torch) it is 879 MB, 540 MB of that torch 2.2.2 CPU. With `[lite]`,
|
|
80
84
|
the same two models on ONNX Runtime and no torch, it is 155 MB (Windows, Python 3.12,
|
|
81
85
|
3 Nov 2026), installs in 12 s, and one MCP recall on the 202-note bench vault took 7.0 s
|
|
82
86
|
against 33.8 s through torch on the same machine, with the same top hits and scores.
|
|
83
87
|
`[lite]` is picked automatically when installed; `SGM_BACKEND=torch` forces torch (for a GPU).
|
|
84
88
|
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`
|
|
89
|
+
Already installed with pip? Replace `uvx --python 3.12 --with ... sqlite-graph-memory` by `sgm-mcp`
|
|
86
90
|
([`examples/mcp-config.json`](examples/mcp-config.json)). Agents that read files first:
|
|
87
91
|
[`llms.txt`](llms.txt).
|
|
88
92
|
|
|
89
93
|
## Three commands
|
|
90
94
|
|
|
91
95
|
```bash
|
|
92
|
-
pip install 'sqlite-graph-memory[
|
|
96
|
+
pip install 'sqlite-graph-memory[lite]'
|
|
93
97
|
sgm-index ./notes
|
|
94
98
|
sgm-ask --ab "In which programming language is the tool behind Project Ouzel written?"
|
|
95
99
|
```
|
|
96
100
|
|
|
97
|
-
|
|
101
|
+
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]`.
|
|
102
|
+
|
|
103
|
+
`./notes` is any folder of markdown notes. Re-running `sgm-index` only re-embeds notes
|
|
104
|
+
that are new or changed since the last run (tracked by a manifest next to the index);
|
|
105
|
+
pass `--full` to force a complete rebuild.
|
|
106
|
+
|
|
107
|
+
To get exactly the output below, use the
|
|
98
108
|
202-note synthetic vault from this repo (it is not inside the pip package):
|
|
99
109
|
|
|
100
110
|
```bash
|
|
@@ -136,8 +146,9 @@ exists so you can measure which one wins on your own notes.
|
|
|
136
146
|
|
|
137
147
|
Graph RAG on SQLite for AI agents — a working pilot, not a framework. It is the extracted
|
|
138
148
|
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
|
|
140
|
-
|
|
149
|
+
points, the `[[wikilinks]]` you already wrote by hand are the graph, and dense similarity
|
|
150
|
+
orders what the hop dragged in (a cross-encoder rerank is opt-in with `--rerank`; see below
|
|
151
|
+
for why it is no longer the default).
|
|
141
152
|
SQLite is the only database ([`schema.sql`](src/sqlite_graph_memory/schema.sql)).
|
|
142
153
|
|
|
143
154
|
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 +171,14 @@ For a single-user agent over a markdown knowledge base, all three are overkill:
|
|
|
160
171
|
- **SQLite is enough** — the only things worth persisting are derived state (a per-turn
|
|
161
172
|
ledger) and telemetry, and both are defined in [`schema.sql`](src/sqlite_graph_memory/schema.sql).
|
|
162
173
|
One file, stdlib driver, zero ops.
|
|
163
|
-
-
|
|
164
|
-
|
|
174
|
+
- **Measure before adding a stage.** The pilot shipped a cross-encoder reranker from day one;
|
|
175
|
+
measured later, it lowered recall on long queries (our 184-question gold set: body nDCG@12
|
|
176
|
+
0.640 reranked vs 0.815 dense; DolphinBench Riley slice, 1000 sessions: R@5 0.48 vs 0.61).
|
|
177
|
+
Since 0.3.7 it is off by default and stays available as `--rerank` / `SGM_RERANK=1`.
|
|
165
178
|
|
|
166
179
|
So the pilot's bet: *vector retrieval for entry points, hand-curated wikilinks for
|
|
167
|
-
association,
|
|
168
|
-
|
|
180
|
+
association, SQLite for everything that must persist.* All steps live in one file,
|
|
181
|
+
`brain_ask.py`, in that order.
|
|
169
182
|
|
|
170
183
|
## Architecture
|
|
171
184
|
|
|
@@ -179,7 +192,8 @@ markdown notes (with [[wikilinks]])
|
|
|
179
192
|
├── brain_ask.py recall pipeline:
|
|
180
193
|
│ 1. dense retrieve top-60 chunks, dedup by file
|
|
181
194
|
│ 2. --graph +1-hop wikilink neighbours of top-15 hits (max 40)
|
|
182
|
-
│ 3.
|
|
195
|
+
│ 3. order dense similarity → top-12
|
|
196
|
+
│ (--rerank: cross-encoder instead, opt-in)
|
|
183
197
|
│ 4. --ab run vector-only AND vector+graph, diff,
|
|
184
198
|
│ log the delta to SQLite (ab_recall)
|
|
185
199
|
│
|
|
@@ -198,7 +212,7 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
198
212
|
### Design choices that survived contact with reality
|
|
199
213
|
|
|
200
214
|
- **Graph expansion is candidate generation, not ranking** (`brain_ask.py`). Neighbours go
|
|
201
|
-
into the same
|
|
215
|
+
into the same ranking pool as vector hits, so an irrelevant linked note gets buried.
|
|
202
216
|
That is what makes 1-hop expansion safe to leave on.
|
|
203
217
|
- **Entity gate** (`looks_like_entity` in `brain_ask.py`). A/B telemetry showed graph
|
|
204
218
|
expansion helps *theme* queries ("approaches to agent memory") but hurts *name/tool*
|
|
@@ -217,7 +231,7 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
217
231
|
|
|
218
232
|
- No entity lane. The production setup has an extra retrieval lane over people/project
|
|
219
233
|
cards; it is too entangled with personal data to publish.
|
|
220
|
-
-
|
|
234
|
+
- Packaging exists since v0.3.0 (`pip install sqlite-graph-memory`). There IS an eval suite now — see
|
|
221
235
|
[Measure before you swap](#measure-before-you-swap--eval) — but it scores retrieval on
|
|
222
236
|
wikilink-derived gold, which is weak supervision and says so out loud. Test coverage is uneven:
|
|
223
237
|
`index_notes.py`, `brain_ask.py` and `mcp_server.py` have unit tests, and
|
|
@@ -230,9 +244,9 @@ an edge table only when hop depth or corpus size demands it.
|
|
|
230
244
|
|
|
231
245
|
```bash
|
|
232
246
|
# Indexing and reranking need an embedding stack; the base install leaves it out.
|
|
233
|
-
# [lite]
|
|
247
|
+
# [lite] runs the models on ONNX Runtime without torch (~155 MB); [embeddings]
|
|
234
248
|
# brings torch (~2 GB) if you want a GPU. Ask for one explicitly:
|
|
235
|
-
pip install 'sqlite-graph-memory[
|
|
249
|
+
pip install 'sqlite-graph-memory[lite]'
|
|
236
250
|
|
|
237
251
|
# 1. index a folder of markdown notes
|
|
238
252
|
sgm-index /path/to/notes
|
|
@@ -256,7 +270,7 @@ To enable the per-turn ledger in Claude Code, register the Stop hook (the exact
|
|
|
256
270
|
sgm-turnstate-show --stats
|
|
257
271
|
```
|
|
258
272
|
|
|
259
|
-
Working from a clone instead of an install? `pip install -e '.[
|
|
273
|
+
Working from a clone instead of an install? `pip install -e '.[lite]'` gives you the
|
|
260
274
|
same four commands, and the modules stay importable as
|
|
261
275
|
`from sqlite_graph_memory import brain_ask`.
|
|
262
276
|
|
|
@@ -357,6 +371,45 @@ is what runs. An eval that re-implements the pipeline measures the re-implementa
|
|
|
357
371
|
`--sqlite` appends one row per class and mode to a `gold_eval` table, which is how a run six
|
|
358
372
|
weeks from now can be diffed against today's.
|
|
359
373
|
|
|
374
|
+
### Sweeping the graph-expansion knobs — `eval/run_ablation.py`
|
|
375
|
+
|
|
376
|
+
`run_eval.py` scores one configuration at a time (`vector` vs `graph`). `run_ablation.py`
|
|
377
|
+
sweeps a grid of pipeline parameters — whether the 1-hop graph expansion runs at all
|
|
378
|
+
(`hops`), how many top hits seed it (`ghops`), how many neighbours it admits (`gmax`), the
|
|
379
|
+
dense-retrieve pool size (`topk`), and whether entity/name-shaped queries skip the hop
|
|
380
|
+
(`entity_gate`) — against the **same gold file**, in one run, reusing `brain_ask.py` and
|
|
381
|
+
`run_eval.py`'s own metrics so the sweep can't drift from what `sgm-ask` actually does:
|
|
382
|
+
|
|
383
|
+
```bash
|
|
384
|
+
python eval/run_ablation.py --list-grid # cells only, no model/index load
|
|
385
|
+
python eval/run_ablation.py --gold eval/gold-<today>.jsonl # the built-in 10-cell default grid
|
|
386
|
+
```
|
|
387
|
+
|
|
388
|
+
Each dense embedding is computed once per question and reused across every cell (a cell's
|
|
389
|
+
candidate pool is a slice of the widest pool asked for, not a re-retrieve); only the
|
|
390
|
+
cross-encoder rerank runs per `(question, cell)`, since the candidate set changes per cell.
|
|
391
|
+
The report — printed as a Markdown table and written as both `<prefix>.md` and `<prefix>.csv`
|
|
392
|
+
(`--out <prefix>`, or `--csv`/`--md` directly) — breaks down `n`, `Recall@12`, `MRR`, `nDCG@12`
|
|
393
|
+
and `delta_nDCG@12` (vs the grid's `0-hop` baseline) per `(cell, class)` and `overall`, and
|
|
394
|
+
warns explicitly whenever a class has fewer than 20 questions. The built-in `default`
|
|
395
|
+
10-cell grid varies **one axis at a time** against `1-hop` (`ghops=15, gmax=40, topk=60,
|
|
396
|
+
entity_gate=on`) rather than a full Cartesian product; `--grid` takes `default`, a
|
|
397
|
+
`';'`-separated `key=val` cell list (e.g. `--grid "hops=0;hops=1,ghops=30,gmax=80"` to test
|
|
398
|
+
multi-axis interactions), or a JSON array of cell dicts.
|
|
399
|
+
|
|
400
|
+
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"`:
|
|
401
|
+
|
|
402
|
+
| cell | class | n | Recall@12 | MRR | nDCG@12 | delta_nDCG@12 |
|
|
403
|
+
|---|---|---:|---:|---:|---:|---:|
|
|
404
|
+
| `cell-0` (`hops=0, topk=3`) | bridge | 1 | 0.500 | 0.500 | 0.387 | +0.000 |
|
|
405
|
+
| `cell-0` (`hops=0, topk=3`) | overall | 12 | 0.958 | 0.903 | 0.907 | +0.000 |
|
|
406
|
+
| `cell-1` (`hops=1, ghops=2, gmax=5, topk=3, gate=on`) | bridge | 1 | 1.000 | 0.500 | 0.693 | +0.307 |
|
|
407
|
+
| `cell-1` (`hops=1, ghops=2, gmax=5, topk=3, gate=on`) | overall | 12 | 1.000 | 0.903 | 0.933 | +0.026 |
|
|
408
|
+
| `cell-2` (`hops=1, ghops=2, gmax=5, topk=3, gate=off`) | bridge | 1 | 1.000 | 0.500 | 0.693 | +0.307 |
|
|
409
|
+
| `cell-2` (`hops=1, ghops=2, gmax=5, topk=3, gate=off`) | overall | 12 | 1.000 | 0.903 | 0.933 | +0.026 |
|
|
410
|
+
|
|
411
|
+
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.
|
|
412
|
+
|
|
360
413
|
### What it cost us to find out
|
|
361
414
|
|
|
362
415
|
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
|