Sam Zoloth

Live architecture

72 tok/turn (-97.5%) · 2 verified LoRAs · losers pruned

Essay

Two-Speed Personal AI Memory

Volatile personal notes belong in a fast local retrieval store; stable repo rules and visual critique habits compile into free LoRAs overnight—if they beat the base model.

Sam Zoloth

Prepending an 82 KB markdown file of personal writing rules to every prompt made my reading app, Margin, slow and overly literal. The same problem showed up in the coding agents (Claude Code and Codex) that help me build Margin: stuffing repository conventions into every prompt burned thousands of tokens on every turn. I replaced those static prompt dumps with a two-speed memory system: a local Rust retrieval store (ee, the Eidetic Engine) for live, mutable notes, alongside free LoRA adapters trained on Inkling 2 Mini (a 26.4B open-weight multimodal model hosted free on Thinking Machines' Tinker platform) for stable repository knowledge and visual critique.

Two adapters beat the base model on held-out evaluations and shipped into daily use. A nightly memory compiler (eidetic-compiler) distilled 14 repository rules from Margin's codebase into a LoRA adapter (memory:margin-public). On 14 unseen repository questions, accuracy rose from 2/14 (14.3%) to 13/14 (92.9%), average prompt size dropped from 2,898 to 72 tokens (-97.5%), and all 8 general coding regression checks passed. A second adapter (ui-critic-rest-em-v1) trained on local macOS app screenshots against a deterministic 0-to-1 rubric verifier. Held-out defect detection rose from 0.6000 to 0.8333 (+0.2333) with 100% valid JSON output.

A third adapter (margin-voice-v1) trained on my writing edits, but lost to the base model on a 10-case held-out rewriting benchmark (0.9257 versus 0.9390 on a 0-to-1 prose quality score). A graduation gate (an automated rule that blocks or archives any adapter whose held-out score falls below the base model) removed it from active routing. I also cut a 5-rule self-hosted store that lacked a held-out benchmark, and I turned off a cross-agent startup hook after measuring that it added 1.05 seconds to every Claude Code session just to inject two rules already written in my global agent instructions.

The 82 KB prompt bottleneck in Margin

Margin captures the highlights and prose corrections I leave while editing drafts. Earlier versions exported those notes into an 82 KB markdown file and attached it to every frontier model call. On a 10-case held-out rewriting benchmark (giving a model an annotated passage and asking it to apply my margin notes cleanly), Claude Opus with high thinking effort and that 82 KB file averaged 10.69 seconds per passage, and Gemini 4 Neon averaged 78.05 seconds.

Latency was only half the problem. Frontier models often pasted my margin-note wording verbatim into the draft instead of fixing the underlying structural issue. A flat markdown file also has no memory decay: a rule I wrote six months ago and later ignored carries the same weight as a rule I reinforced yesterday.

A two-speed hierarchy modeled on JIT compilers

I split personal context into two speeds, borrowing the architecture from tiered JIT compilers like V8 Maglev and LSM-tree storage engines like RocksDB. Volatile personal notes stay in a fast local retrieval store by day. Stable repository conventions compile into lightweight LoRA weights overnight.

For Margin's writing memory, I wired the Eidetic Engine (ee) into Margin's Go CLI, its Tauri desktop UI (a "Thinking Pack" tab that compiles a relevant subset of rules for a given topic), and a 6-hour background sync. Instead of loading 82 KB of static rules, Margin assembles a token-budgeted pack (1,091 of 2,000 tokens, roughly 18x smaller) using hybrid keyword and local neural retrieval. Whenever I archive or reinforce a rule in Margin, the app logs a helpful or harmful outcome that adjusts the rule's confidence score automatically. In a separate test of a cross-agent coding store, three harmful outcomes dropped a flawed git worktree rule from 0.500 to 0.059 confidence and lowered its trust tier twice, while seven rapid noisy failure signals from a single source triggered automatic quarantine so one buggy agent could not poison shared memory.

For Margin's repository rules (commands, build constraints, and testing conventions), paying 2,898 prompt tokens on every agent query wastes context. eidetic-compiler runs at 3:15 AM via macOS launchd and distills the repository's ee pack into an Inkling 2 Mini LoRA using On-Policy Context Distillation (OPCD). During training, the student model generates its own answers without the rules in its prompt, while a teacher copy conditioned on the full pack scores those tokens using reverse KL divergence.

To prevent sequential fine-tuning drift, each compiled LoRA records a deterministic SHA-256 hash of its source rules. Unchanged workspaces hit a 0-second cache. When a rule changes during the day, the local MCP server that Claude Code and Codex query (eidetic_ask) appends only the newly changed rules to the system prompt. Overnight, the compiler discards the stale adapter and recompiles cleanly from base weights. It weights mutated rules 3x during warm-start training so updates stick. On 14 unseen questions about Margin's codebase plus 8 general coding regression checks, base Inkling 2 Mini scored 2/14 (14.3%) at 72.4 tokens, base plus the full ee pack scored 14/14 (100%) at 2,898.4 tokens, and the compiled OPCD LoRA scored 13/14 (92.9%) at 72.4 tokens while keeping 8/8 regression checks intact. After mutating one QA rule and recompiling cleanly from base weights, the updated adapter answered the changed rule accurately at 79.0 tokens and still passed 8/8 general checks.

Behavioral post-training for visual UI critique

Context distillation fits repository facts, while visual UI critique requires habits that a short rule list cannot encode. I pointed Inkling 2 Mini's multimodal weights at local macOS app screenshot archives (6 training screenshots and 3 held-out screenshots from my own desktop apps) and scored each critique with a programmatic JSON verifier. Because the verifier has no ground-truth bounding boxes, it scores structural rigor directly: valid JSON without markdown wrappers, exact hex color codes, pixel or contrast measurements, verbatim UI text quotes, and calibrated P0, P1, or P2 severities.

Standard clipped PPO reinforcement learning (lr=5e-5) regressed on its validation split, so the graduation gate blocked it. Switching to On-Policy ReST-EM (an iterative self-training loop that samples 4 rollouts per screenshot, filters to only the top verified winners, and runs 2 masked supervised fine-tuning epochs at lr=3e-5) reversed that instability. On the held-out screenshots, scores rose from 0.6000 to 0.8333 (+0.2333) with 100% valid JSON, flagging clipped footer bars, low-contrast empty states, and overlapping markers on live app screens.

Four stores consolidated, three weak pieces cut

Building these three layers in parallel across three separate repositories (eidetic-lab, eidetic-compiler, and inkling-forge) shipped working prototypes fast, but left operational fragmentation. Four local ee stores sat isolated from one another (Margin writing rules, cross-agent fleet heuristics, Margin's codebase conventions, and eidetic-compiler's own 5-rule store). Meanwhile, the two Tinker training harnesses enforced mismatched privacy filters: inkling-forge blocked employer names, personal names, and phone numbers before touching Tinker's free tier, while eidetic-compiler only redacted API keys and emails.

Before calling the system done, I unified the stack. Both training harnesses now enforce the same privacy redaction boundary, and personal stores (margin-writing and fleet-memory) stay strictly local-only via non-parametric ee pack. Claude Code and Codex now query both local-only stores and compiled repository LoRAs through one MCP server (eidetic_stores, eidetic_pack, and eidetic_ask), and both harnesses mirror verified adapters into a single shared registry.

I then pruned everything that failed to beat the base model on held-out evaluations. On the 10-case rewriting benchmark, deterministic prose linters (which count common AI-writing clichés alongside verbatim note pasting) already saturated near 0.94 on base Inkling 2 Mini (0.9390 base versus 0.9257 for margin-voice-v1, with 0.20 mean cliché hits on both). Without blind human preference data, automated training cannot separate good voice from great voice. I archived margin-voice-v1 out of active routing, removed the unverified 5-rule store from nightly launchd compilation, and stopped the redundant fleet-memory background daemon and startup hook, leaving only the two verified winners (ui-critic-rest-em-v1 and memory:margin-public) active.

Design rules for two-speed AI memory

Split mutable facts from stable skills. Putting volatile personal notes into model weights creates privacy risk and stale caches. Keeping them in a local retrieval store while compiling only stable, redacted repository knowledge gives you the speed win without the drift.

Measure against the base model rather than your last training loss. Without a held-out graduation gate, both PPO on UI critique and the writing-voice LoRA would have shipped regressions.

Start post-training on verifiable tasks. Repository conventions (14.3% to 92.9%) and structured UI audits (0.60 to 0.83) carry sharp, objective signals, while open-ended prose hits a verifier ceiling quickly and requires human blind review.