Source: https://oliviercouthaud.com/sleepmemory · Status: In progress · 2026 · Tags: Python, PyTorch, LoRA, Evaluation design # Sleep memory Can a small language model learn from a day's conversation by training on it overnight, instead of having the conversation pasted back in? I have run over twenty experiments on this. Plain recall stalls near 77%. A fix for facts that change works at two model sizes; a test at a third is queued. ## Setup Base model Qwen3-1.7B-Base, and Qwen3-4B-Base for the size test. One LoRA adapter for all nights: rank 64 at 1.7B, rank 16 at 4B because 64 does not fit under the 11.9 GB memory cap I run with. A night is 250 optimiser steps at a learning rate of 2e-4. The previous night's model, with the day's own lines in its prompt, writes practice exchanges, one of my lines at a time; in the recipe I call B that is about 720 a night. The previous night's model without the chat writes 480 replay exchanges from 40 life-topic prompts so that older claims keep being practised, and a KL term keeps the new adapter close to it on those. The test is 20 claim types (a pet, a city, a job, a car and so on), each with one invented value, four new claims a night over five nights, inserted into windows of private chat logs that I do not publish. After night 5 each claim is asked closed-book, greedy, and counted right if the gold string appears in the answer. The untrained base model scored 0% in every run. Early rounds leaked test values through the few-shot examples; I fixed that before the runs reported here. ## Plain recall Figure: Mean recall of all claims taught so far, after each night, over fresh seeds 100 to 105. A writes about 240 practice exchanges a night, B about 720. Recall does not level off; it falls every night after the second. The gate I wrote before the confirmation runs: mean recall of at least 80% after night 5, older-claim recall of at least 75%, and a fall of no more than 5 points a night. Recipe B on eight fresh seeds: 76.9% (bootstrap 95% interval 68.8 to 84.4), older claims 76.6%, slope −5.3 a night. By my own rule that is inconclusive rather than a fail, because the interval still contains 80. My judgement, kept separate from the rule, is that it is not ready, since the curve keeps falling. **What I changed, and the paired change in recall after night 5. Unless noted, four development seeds, so differences under about 10 points cannot be told from noise.** | Change | Difference (95% interval) | Read as | |---|---|---| | 3× practice per claim (B against A), six fresh seeds | +10.8 (−0.8 to +21.7) | Helps a little; the interval touches zero | | Values for different claim types kept apart | 0.0 (−12.5 to +13.8) | Confusion between lookalike claims is not the limit | | Train on the model's own answers, scored by the context-aware earlier model | −25 and −22.5 (two seeds each) | Worse; dropped | | Adapter rank 16 against 64 | −1.2 (−20.0 to +16.2) | A quarter of the size does as well | | Adapter rank 128 against 64 | −17.5 (−36.2 to 0.0) | Bigger is worse and fades faster | | Learning rate 1e-4, then 5e-5, against 2e-4 | −2.5, then 0.0 | Trades new-claim recall for old; the total stays near 78% | | Added loss matching the earlier model's hidden states | +1.2 (−12.5 to +12.5) | No gain, and runs 56 to 75% slower | | Edit weights directly (AlphaEdit, WISE) with questions the model wrote itself | −18.8 and −6.2 against sleep | Worse; AlphaEdit also raised perplexity on ordinary chat by 20.7 | With the exact test question as the edit key, AlphaEdit reached 90.0% against sleep's 76.2% and wrote in seconds instead of minutes. That hands the editor the wording of the test, so I count it as an upper bound and not a result. The learning-rate runs are the clearest picture of the limit: lowering the rate cut recall of tonight's claims (87.5, 75.0, 68.8) and raised recall of older ones (76.6, 76.6, 81.2), with the sum unchanged. That is exploratory, not something I set out to test. I also ran a released external memory module (MEMORILLA, from Stanford SNAP) on the same claims, with no training of my own. It retrieved the exact value 1.2% of the time, against 86.2% for plain top-5 text retrieval and 97.5% for the whole chat in the prompt. It was built for user-and-assistant conversations, not peer chat, I ran its 8B decoder in 4-bit and I rewrote the questions in the third person, so this says little about the method. I checked the pipeline reproduces the module's own README example before trusting the numbers. ## Facts that change The script has five families, each with an old value A and a new value B: a dog (A dies, B arrives), a city, a job, a car and a game. Six unchanging claims are controls. After nights 4 and 5 the model is asked the current value, the earlier value, and a combined yes-or-no question ("do you have a dog right now?", "do you still live in A?"). "Stale" means giving A as the current answer. Five families over four seeds is 20 items an arm, so the intervals are wide throughout. **Mean of the three questions (current, earlier, yes-or-no) after night 5, change against plain practice.** | Change | Difference (95% interval) | Read as | |---|---|---| | A 4B model instead of 1.7B | 0.0 (corrected scorer) | Scale does not fix it | | Day tag on every practice line | −3.3 (−13.3 to +6.7) | Ignored; and static recall fell 8.3 | | Penalty for the wrong version, or dropping replay that re-teaches the old value | −3.3 and −3.3 | Stale answers fell but earlier-value answers fell more | | Ask the earlier model what it believed, to build the "before" line | Gate failed | Dropped (see below) | | "Before" line supplied by my harness, eight development seeds | +15.0 (+0.8 to +28.3) | Real, but the harness knows which lines changed | | Same, six fresh seeds | +15.6 (+3.3 to +27.8) | Replicated, 6 of 6 positive | | "Before" block = the model's own lines of the last three nights, six fresh seeds | +22.2 (+4.4 to +40.0) | Works with no oracle, but costs 5.6 points of static recall against a limit of 5 | | Same, keeping identical earlier lines in the block | +28.9 (+13.3 to +46.7) | Static cost gone (0.0). The final recipe at 1.7B | | The final recipe at 4B, six seeds | +18.9 (+4.4 to +33.3) | Transfers; static recall −2.8 | Two of these deserve a sentence. First, a replay filter combined with the supplied before-line looked best on the four development seeds I had used to choose it, and on fresh seeds it matched the before-line alone (−1.1). I read that as a winner's curse and did not adopt it. Second, I tried to get the before-line from the model itself, by asking the previous night's model what it believed about the topic. On the test seed, two of the six changed lines got a before-line holding the old value (33%), and 41% of unchanged lines got a false one; at 4B it was 33% and 30%. My bar was 50% coverage and no more than 15% false, so I dropped it. **The final recipe against plain practice at 1.7B, fresh seeds 100 to 105, 30 items an arm.** | Question | Plain | Final recipe | |---|---|---| | Current value correct | 40.0% | 63.3% | | Earlier value correct | 60.0% | 80.0% | | Yes-or-no question correct (always answering yes scores 20%) | 20.0% | 63.3% | | Old value given as the current one | 43.3% | 33.3% | | Unchanging claims recalled | 88.9% | 88.9% | At 4B the gain is carried almost entirely by the yes-or-no question (+50, interval +20 to +73); the current and earlier questions are flat. Even the best arm at 1.7B still gives the old value as the current one a third of the time. It is also not only a problem of storing things in weights: in a separate probe, an 8B model with all five nights pasted into its prompt gave the old value as current 55% of the time. ## How the experiments were run Every experiment gets a protocol in a log before it runs: one question, one variable per arm, the number I expect, and what I will do for each outcome. Development seeds are for tuning and are spent. Confirmation seeds (100 and up) run once with a frozen configuration and are never used to tune. Arms are paired by seed and the uncertainty is a bootstrap over seeds and items. Each run keeps its command, a copy of its code, its seeds and every raw prediction. I apply the rule as written even when it is inconvenient: a result of +15 whose interval touched zero was not called a pass, and a confirmation that missed the static-recall limit by 0.6 points was not adopted until the next experiment fixed the cause. ## What went wrong **My yes-or-no scorer was wrong.** It matched the exact words "yes" or "no", so "yeah", "yep" and "nope" counted as wrong, and 80 to 100% of the model's answers begin that way. I found it, rescored the earlier update runs from their logged answers and used the corrected scorer after that. No decision changed, but the "combined question improved at 4B" lead I had noted was smaller than it looked, and the question turned out to be essentially unlearned by plain practice. **A queue script did not enforce a smoke test I had written into the protocol.** Two full runs of the self-quiz arm ran, about two and a half hours, that the failed smoke test should have stopped. A planned rank-256 arm ran out of memory in all three runs; I replaced it with rank 128 and declared that before running, which weakens the test of whether more capacity helps. And the final confirmation reused seeds 100 to 105, on which I had already seen the earlier arm's static cost, so it is a weaker confirmation than a set I had never looked at. ## Where it stands Done: plain recall, which stalls near 77%; and the update recipe at 1.7B (six fresh seeds) and 4B (six seeds, interval excluding zero). Queued with no result: the same test on an 8B base loaded in 4-bit, as a stand-in for the 9B model I would actually use, which needs its own loading code. Not tested: real conversations, facts longer than one line, more than five nights, or anything except the invented claims described above. - **Mine**: The experiment code, the written protocols and the analysis - **Stack**: Python, PyTorch, LoRA adapters, Qwen3 base models (1.7B and 4B), one 16 GB GPU - **Stage**: Experiments run to 4B; an 8B test is queued; invented facts only - **Status**: In progress - **Code**: Not public