Repository navigation
Memory loop 1–7 and the integration experiment: extraction, guard, retrieval, drift, binding check - #10
Merged
Conversation
…cts (was 22-25%) bench/facts_natural.json (40 dev + 40 held-out facts as people say them) and bench/chatter.json (40 lines that state no fact) measure extraction coverage and false memories; build/bench_extract scores the Pascal extractor. 28 rules from the dev misses (memlib.EXTRA_RULES, generated into memagent/Mem.ExtractRules.inc so the Pascal and Python extractors share one table), "my son Leo ..." relation + name, "my birthday's on", "I've been working at". Value checks keep chat out: no pronoun/filler-led values, and a proper noun where the rule is about a name or place. dev 0.225 -> 1.000, held-out 0.250 -> 0.650, chatter false positives 0/40. Parity 698/698. Also /weights <question> (answer from the adapters alone) and bench/bench_stream.py (the continual-memory benchmark). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…; no redundant deep sleep
bench/results/stream-tiny-baseline.json: 30 facts over 3 sessions. The full
agent scored below the weights alone, mostly because the guard withheld
right answers whose question and fact use different words ("my employer" /
"where I work", "my boss" / "my manager", "my girl" / "my daughter").
Mem.Guard: groups of words that name the same thing. Re-scored offline on
the recorded answers: dev correct answers withheld 3-4 -> 0, confabulation
with the guard unchanged (0.25 dev and held-out).
A deep sleep is skipped when the deep LoRA already holds every fact (the
baseline spent 341 s rebuilding the same 10 facts).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…r test) Profile (memory loop 3): training is 89-94% of a run, ~0.64 s per example pass on tiny; a fast run over 10 new facts cost twice a deep sleep over 10 because its 10 replayed facts got full example sets. Replayed facts are already in the frozen deep LoRA, so they now get max(2, per_fact div 3). Verification on bench_stream is running. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…ws with facts (next) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…nder test) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
… default stays Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…, in both trainers Taking the held-out prompts right after the training anchors made drift measured with 16 anchors not comparable to 8 (other and more prompts). Loop 4b results so far: max_windows=16 rejected (drift 1.49 -> 1.83). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…ed held-out set, accuracy unchanged Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…ay" is not "my birthday"); held-out drift confirmation for 24 anchors Widening the guard to every question was measured and rejected: 12/60 correct dev answers blocked; neither bge scores nor retrieval rank separate paraphrases from near-neighbour confabulation. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…hit@3 with 2,000 look-alike facts 0.833 -> 0.967 bench_retrieval gains BENCH_FILLER=personal (look-alike facts about other people), BENCH_POOL and BENCH_DEBUG. Both ranked lists are searched 4x deeper, foreign-owner facts demoted per list before fusion, so fusion is unchanged when nothing is foreign. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…s 1.01->1.12 over 10-30 facts Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…); bench_stream --set overrides train settings Default unchanged (1). Also untangles the Mem.Train constants block. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…on benchmark set and runner The rule extractor stored only first-person facts, so facts that answer a question only together (my sister -> Ana -> Lisbon) could not be told at all. New rule in memlib and Mem.Extract, parity cases regenerated (710/710); facts_natural coverage and chatter false positives unchanged. bench/gen_integration.py builds 176 facts and 96 questions (direct, bridge, inverse, verify); bench/bench_integration.py compares retrieval only, retrieval + deep LoRA, and weights only, split by retrieval coverage. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…ep fits on 4 CPU cores; --set for the runner Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
The subject merge (TAgent.SameSubject) let the ms-marco cross-encoder decide
alone whether a new fact restates a stored subject. On the integration set it
merged 14 of 112 distinct subjects ("Tomas's job" over "Tomas's city",
"my grandpa's name" over "my grandma's name", "Mia's pet" over "Ana's
pet"), and a merge supersedes the older fact: silent memory loss.
Mem.Guard.DistinctSubjects vetoes the merge when both subjects read
"<owner>'s <attribute>" and the owners or the attributes differ (synonym
groups still match: mom/mother). Corrections of the same subject still merge.
Now 112/112 stored. bench_integration runs arm by arm (--arms, --keep).
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
The small profile downloads qwen2.5-1.5b-instruct-q8_0.gguf; the llama trainer makes its f32 copy with llama_model_quantize, which refuses quantized inputs unless allow_requantize is set, so training on the small profile failed with "could not convert ... to f32". Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
… person
Integration set, small profile, retrieval only: 15 of 24 two-step questions
("Which city does my sister live in?") were answered with another person's
stored value ("Hana lives in Bologna", Bologna being Sofia's city). The
guard passed them: one licensed value (the sister's name) licensed the whole
answer, and nothing checked whose value the rest was.
Mem.Guard.Unbound: a value stored about named people may be used only for
the question's person (resolved through "my sister's name"), or, when the
question names no one, for the user's people the answer names, plus anyone
the question names. Offline on the retrieval arm's answers (bench_guard):
wrong stored-value answers 17 -> 8, no correct answer blocked; the 8 left
invent unstored values or name a stranger. bench/facts.json and held-out
results identical. bench_guard now reports wrong stored-value answers.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
Retrieval + deep LoRA finished 53 of 96 questions before the task limit: no integration gain (bridge 3 -> 1 of 24), and the drift (ppl 2.07) shows as answers that run on with invented turns. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…and a plan for a learned memory reader trainer/edit_facts.py writes facts into the down_proj of layers 4-8 in one closed-form step per layer and exports the change as a LoRA the agent loads like a deep-sleep adapter. bench_integration.py --memory DIR --name NAME runs retrieval + that LoRA and weights only as two more arms. The plan follows Memorilla (arXiv 2610.21375): two-hop retrieval baseline, a learned reader as retriever on CPU, then soft-token injection as a tiny-profile pilot. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
…yer at the solve (the first check ran out of memory at 14 GB) Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01NPVFJHeBeotAKkU7EPbTgn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR has the memory benchmark loop (iterations 1–7) and the small-profile integration experiment. Each change was measured with the
bench/scripts, and every iteration is written up inbench/README.md.Changes
Extraction
trainer/memlib.pyandmemagent/Mem.Extract.pas. The extract cases pass 710/710.Guard
UnboundinMem.Guard): a value stored about a named person only supports answers about that person. On the retrieval-only answers from the integration run, wrong stored values dropped from 17 to 8. It blocked 9 answers, none of them correct.Memory store
DistinctSubjects). Before, 14 of 112 facts were overwritten ("Tomas's job" replaced "Tomas's city"); now all 112 are kept.Retrieval
Training drift
Trainer
train.max_windowscaps optimizer steps per epoch.train.replaysets how many deep facts a fast run replays. Replaying all of them made no difference (loop 7), so the default stays at 1.allow_requantize).Benchmarks
bench/gen_integration.py,bench/bench_integration.py.--setoverrides profile settings for one run inbench_stream.pyandbench_integration.py.Integration experiment (Qwen2.5-1.5B, 112 facts, CPU)
The question: does a deep sleep teach the model to combine facts that retrieval alone can't?
Verdict: on CPU, the 1.5B model's trained memory is a backup for facts retrieval misses, not a way to reason across facts. The useful gains came from the memory store and the guard.
Not done yet
build/memagenthas not been rebuilt with the binding check and the merge fix, so no live benchmark run uses them yet. The guard numbers above come from re-checking saved answers offline.allow_requantizepatch passesgit apply --check, but llama.cpp has not been rebuilt to confirm the q8_0 → f32 conversion.Generated by Claude Code