Repository navigation
Expand file tree
/
Copy pathllms.txt
More file actions
88 lines (57 loc) · 5.06 KB
/
Copy pathllms.txt
File metadata and controls
88 lines (57 loc) · 5.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# sqlite-graph-memory
> Persistent memory for Claude Code, Cursor, Codex and any MCP client, built over a folder of markdown notes you already keep (Obsidian vaults included). Vector search finds entry points, the [[wikilinks]] in the notes are the graph, a cross-encoder reranks. One SQLite file for telemetry and the per-turn ledger (recall never reads the ledger), no graph database, no extraction pass. MIT, Python >= 3.9, version 0.3.1 on PyPI. Status: pilot.
Relation to Karpathy's LLM Wiki (https://gist.github.com/karpathy/442a6bf555914893e9891c11519de94f, April 2026): in that pattern an agent writes and maintains an interlinked markdown wiki; sgm is the search tool over such a wiki (MCP + CLI), read-only, with wikilinks as the graph. It does not write notes. Independent, no affiliation or endorsement.
Who it is for: one person or one agent setup with a markdown knowledge base that wants associative recall without running a graph database. Not a framework, not multi-tenant.
## Three commands
```bash
pip install 'sqlite-graph-memory[lite]'
sgm-index ./notes
sgm-ask --ab "In which programming language is the tool behind Project Ouzel written?"
```
On an Intel Mac use Python 3.12: on a newer Python, pip can quietly install release 0.3.5, which has no `[lite]`.
`--ab` runs vector-only and vector+graph side by side and logs the difference to SQLite (`ab_recall` table). Other modes: `sgm-ask "q"` (vector only), `sgm-ask --graph "q"`, `sgm-ask --ask "q"` (context bundle to paste into an agent). The base install without `[embeddings]` explains the missing extra instead of failing with a traceback.
## MCP server
Command: `sgm-mcp` (also installed as `sqlite-graph-memory`, so `uvx --python 3.12 --with 'sqlite-graph-memory[lite]' sqlite-graph-memory` works). Registry name: `io.github.tonydzi/sqlite-graph-memory`. One tool: `memory_recall`.
JSON clients (Claude Desktop, Cursor, Zed, Windsurf):
```json
{"mcpServers": {"sqlite-graph-memory": {"command": "sgm-mcp",
"env": {"BRAIN_INDEX_DIR": "/path/to/your/index", "TURNSTATE_DB": "/path/to/your/turnstate.db"}}}}
```
Claude Code: `claude mcp add sqlite-graph-memory -e BRAIN_INDEX_DIR=/path/to/index -- sgm-mcp`
Codex (`~/.codex/config.toml`):
```toml
[mcp_servers.sqlite-graph-memory]
command = "sgm-mcp"
env = { BRAIN_INDEX_DIR = "/path/to/your/index" }
```
## Health check (no model, no index)
```bash
sgm-stats ./notes # add --json for machines, --today YYYY-MM-DD to pin staleness
```
Four numbers about the wikilink graph recall walks, each ok/warn/fail: orphan rate (ok <5%, fail >15%), links per page (ok 3-8, fail <2 or >10), share of pages in the main connected component (ok >=80%), share of concept pages with `updated` older than 90 days (warn >50%). Exit code 0 ok, 1 warn, 2 fail, so it can run in cron. Every threshold is a `--threshold-*` flag. On the bench vault: 26.2% orphans (fail), 4.65 links per page, 100% in one component.
## Turn ledger (Stop hook)
`sgm-turnstate-hook` appends one SQLite row per assistant turn (zero tokens, stdlib); wire it as a Claude Code Stop hook from `examples/claude-code-stop-hook.json`. `sgm-turnstate-show --stats` reads the ledger.
Install or first run gone wrong: run `sgm-doctor` first. It checks Python, numpy, torch, the models and your index in plain words and prints the fix for each.
## Benchmark (memory-bench v0.1, bench/)
Synthetic 202-note vault, 91 questions (69 answerable, 22 with no answer in the vault). Every number is recomputed by CI from per-question outputs.
- sqlite-graph-memory, vector only (0.3.0): R@5 0.88, R@10 0.92
- sqlite-graph-memory, vector+graph (0.3.0): R@5 0.85, R@10 0.91
- bm25 reference: R@5 0.77, R@10 0.79
On this vault vector-only ranks ahead of graph mode overall. Run it: `python bench/run.py --system bm25` (stdlib only).
## Eval on your own notes (eval/)
The wikilinks you wrote are the relevance labels: no labelling budget, no LLM calls. Four question classes: title, body, bridge, temporal. Each scored in vector-only and vector+graph mode.
```bash
python eval/run_eval.py --selftest
python eval/build_gold.py /path/to/notes --n-per-class 60
python eval/run_eval.py --gold eval/gold-<date>.jsonl --sqlite
```
## Configuration (env only)
BRAIN_INDEX_DIR (index folder, default ./index), TURNSTATE_DB (default ./turnstate.db), BRAIN_ANSWER_OUT, BRAIN_AB_JSON (structured A/B output), AB_SOURCE, SGM_NO_STAR_PROMPT=1 (silence the one-time star line after --ab), SGM_CONFIG_DIR, SGM_PPR=1 (PageRank lane in the ordering, off by default). Full list: .env.example.
## Links
- README: https://github.com/tonydzi/sqlite-graph-memory/blob/main/README.md
- Benchmark and leaderboard: https://github.com/tonydzi/sqlite-graph-memory/blob/main/bench/LEADERBOARD.md
- Bi-temporal memory spec to paste into CLAUDE.md or AGENTS.md: https://github.com/tonydzi/sqlite-graph-memory/blob/main/BITEMPORAL.md
- Design note: https://github.com/tonydzi/sqlite-graph-memory/blob/main/docs/bitemporal.md
- Paper: https://doi.org/10.5281/zenodo.22639718
- PyPI: https://pypi.org/project/sqlite-graph-memory/
- Changelog: https://github.com/tonydzi/sqlite-graph-memory/blob/main/CHANGELOG.md