superlocalmemory icon indicating copy to clipboard operation
superlocalmemory copied to clipboard

Mode B: ~6 LLM calls per stored fact (context sentence + up to 5 contradiction checks) dominate enrichment cost; please add config switches and a bulk action for the 17k "proposed" correction cases

Open raorthopro-cpu opened this issue 3 weeks ago • 4 comments

Environment

  • 4.2.13, macOS (Apple M5 Max, 128 GB), Mode B with Ollama gemma3:4b, SLM_DATA_DIR custom, daemon via launchd. Store: ~55,000 facts, 6,600 entities, 9,500 memories.
  • Enrichment runs at full power at night (no throttling) for a one-week measurement; store history in #308.

Measurement (four nights, from daemon.log / Ollama server.log / ingestion_operations)

night model ops completed new facts Ollama /api/chat calls calls per op calls per fact
1 gemma3:4b 599 7,258 45,142 75 6.2
2 gemma3:27b 413 4,935 28,212 68 5.7
4 gemma3:27b 142 3,973 23,796 168 6.0

Reading core/store_pipeline.py this matches: per stored fact the pipeline calls context_generator.generate() (1 LLM call, encoding/context_generator.py) and temporal_validator.validate_and_invalidate() (up to max_llm_checks = 5 calls, encoding/temporal_validator.py). The extraction itself is ~1 call per operation. So roughly 98 % of model time goes into the per-fact steps, not into extracting facts.

Side effects on this store:

  • correction_cases now holds 17,423 rows in status proposed (reason codes: temporal_contradiction 10,956+, consolidation_update, consolidation_supersede), growing by 1,000–3,600 per night. Nobody reviews them, and they are what makes DELETE /api/memories/{id} answer 409 ("fact is protected by correction history"). The 4.1.19 store-repair docstring says about the automatic marks: "on a real store 0 of 22 sampled marks were genuine".
  • A larger model does not help (27b: slower, more withheld derived facts).

Neither step is user-configurable: TemporalValidatorConfig comes from the mode preset (TemporalValidatorConfig(mode="b")) and is not read from config.json; _init_context_generator always passes the LLM. I patched core/engine_wiring.py locally (pass llm=None to both when a flag file exists), which falls back to the existing Mode A paths (rules-based context, sheaf contradiction check). Tonight is the first night with that; I will report the numbers here.

Requests

  1. Config keys (read from config.json, settable via slm config set) for Mode B/C, e.g. encoding.context_generation_llm (bool) and temporal_validator.llm_checks (int, 0 = sheaf only), so users can trade enrichment depth for throughput without patching.
  2. A bulk action for proposed correction cases, e.g. slm corrections reject --proposed --reason temporal_contradiction --before <date> (or via slm ops resolve), with a dry run. 17k single review_correction calls are not practical.
  3. Optional: a note in the docs that each stored fact costs ~6 model calls in Mode B, so people can size their backlog.

Happy to run anything you want against this store.

raorthopro-cpu avatar Nov 06 '26 08:11 raorthopro-cpu

Correction to the table above: the "model" column for nights 2 and 4 is wrong. The daemon process had been running since Nov 1 outside launchd's view (launchctl print said "not running" while the process lived on with PPID 1), so launchctl kickstart -k never restarted it and the config change to gemma3:27b never took effect. Ollama's server.log confirms 27b was never loaded. All measured nights ran gemma3:4b; nights 2/4 were slow because of a second consumer (entity recompile) sharing the model, not because of the model size. The per-fact ratio (~6 calls per stored fact) is unaffected and was reproduced again last night: 194 ops, 4,559 facts, 26,460 calls (5.8 per fact).

The daemon is now properly restarted with the local patch (context + contradiction without LLM); I will post the numbers from the first real night tomorrow. Requests 1–3 stand.

raorthopro-cpu avatar Nov 07 '26 06:11 raorthopro-cpu

Thank you for the measurements. Four nights of data, with the code paths traced, made the cost obvious and the fix easy to scope. 4.2.14, released today (pip install -U superlocalmemory or npm install -g [email protected]), adds what you asked for, with one change to request 2.

1. Two settings, defaults unchanged (they equal the earlier behaviour, so nothing moves until you choose):

slm config set temporal_validator.max_llm_checks 0     # embedding check only (default 5)
slm config set encoding.context_generation_llm false   # rule-based context sentences (default true)
slm restart

0 takes the same path your local patch took. Each mode keeps its own values, like its model choice.

2. slm corrections dismiss instead of a bulk reject:

slm corrections dismiss --reason temporal_contradiction --older-than 7          # dry run
slm corrections dismiss --reason temporal_contradiction --older-than 7 --apply  # backs up first

We did not add a bulk reject on purpose. A rejected case counts as decided, and a decided case keeps both of its facts from ever being deleted, so 17k rejections would have locked about 34k facts. Dismiss closes only proposals SLM made by itself that nobody reviewed, and keeps an audit row. Any case can be put back with slm corrections restore-overtaken <case id>, and a dismissed proposal is not filed again when the same save is re-processed. Profile erasure and snapshot restore now cover dismissed cases too.

3. The docs (configuration, Mode B) now state the cost per fact: about one call per save for extraction, then one for the context sentence and up to five for contradiction checks per stored fact.

On the 409s: since 4.2.x, a proposal SLM made by itself no longer blocks a delete. The 409 message names the cases that do block. Could you paste one (ids only)? They will be cases a person proposed or that were already decided, and we would like to see which.

varun369 avatar Nov 09 '26 10:11 varun369

Reopening: the fix shipped in 4.2.14, and this stays open until we hear back on the question above. Thank you.

varun369 avatar Nov 09 '26 10:11 varun369

Thanks for the follow-up. I can no longer reproduce the 409 on delete: we installed 4.2.14 on 13 Nov and retired this SuperLocalMemory instance the same day in favour of a simpler local index. The three facts that returned 409 were 8383e7adf793462f, d4c830faa66a4a22 and e516f9654d255fa8; the correction-case IDs were not logged at the time. Before retiring the instance, slm corrections dismiss --apply cleared 15,670 old proposals without problems. Feel free to close this issue, and thank you for the quick fixes in 4.2.12–4.2.14.

raorthopro-cpu avatar Nov 13 '26 13:11 raorthopro-cpu