Olivier Couthaud

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.

What I wanted

A language model forgets everything between conversations unless the conversation is pasted back in. I wanted one that could carry what it learned from a day's chat into the next day without that. People seem to do something like this in sleep, so I copied the shape of it. Each "night" the model practises the day's conversation, and what it learns goes into a small add-on layer on top of the original model. The next day I ask it questions with no chat in front of it.

The test

I used a small model, Qwen3-1.7B-Base, on one 16 GB graphics card. Each night's "day" is a stretch of ordinary chat logs I keep private, with four invented facts about a person slipped in, such as a pet's name or a job. After five nights there are twenty facts. Then I ask twenty questions with no chat available and count how many answers contain the right value. The original model, which has never seen the facts, gets none.

100%90%80%70%60%50% bar set in advance: 80% 3× practice75.8% 1× practice65.0% night 1night 2night 3night 4night 5
Share of all facts taught so far that the model answers correctly after each night, averaged over six runs. Plain practice against three times as much of it. The model before any training scores 0%.

What worked, partly

The basic version remembers about three quarters of the facts after five nights: 76.9% on eight fresh runs, against the 80% bar I set before looking. It also fades, by about five points a night after the second night. I tried most of the ordinary fixes: a bigger or smaller add-on layer, a lower learning rate, a different way of teaching, editing the model's weights directly, and a loss on its internal state. None clearly lifted it, and several made it worse. Practising each fact three times as much helped a little, by 10.8 points on six runs, which is not clearly more than chance. So I stopped trying to push plain recall past 77% and moved to a harder question.

Facts that change

A memory that only adds facts is not much use. People get a new dog, move house, change jobs. So the second test has five facts that change partway through, such as a dog that dies and a new dog that arrives. After five nights I ask three things: what is it now, what was it before, and a yes-or-no question such as "do you still live in Boston?". With plain practice the model gave the old value as the current one 35 to 50 percent of the time, and on the yes-or-no question it did no better than always answering yes. A bigger model did not fix that, and neither did putting the date on every practice line.

What helped was giving the model, while it practises a line, the lines it had said over the previous three nights. It then sees "before" next to "now". On six fresh runs the average over the three questions went from 40.0% to 68.9%, with no loss on the facts that never change. On a 4B model, the same change took it from 46.7% to 65.6%. Most of that gain is on the yes-or-no question. The plain "what is it now" and "what was it before" questions improve clearly at the small model and hardly at all at the larger one.

Where it stands

It works on invented one-line facts at two sizes of model. I have not tried real conversations. The model I would actually use is bigger, a 9B, and needs its own code to load; a test on an 8B stand-in is queued and has no result yet. This is the memory part only, and nothing about it is finished.

Each experiment has a written plan before it runs, with the number I expect and what I will do for each outcome. Tuning uses one set of random runs, and the claims above come from a second set I did not tune on. Where a result missed the bar I had set, I say that it missed.

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

100%90%80%70%60%50% bar set in advance: 80% B, 3×75.8% A, 1×65.0% night 1night 2night 3night 4night 5
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.
ChangeDifference (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 apart0.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.0Trades 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 sleepWorse; 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.
ChangeDifference (95% interval)Read as
A 4B model instead of 1.7B0.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.3Stale answers fell but earlier-value answers fell more
Ask the earlier model what it believed, to build the "before" lineGate failedDropped (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.
QuestionPlainFinal recipe
Current value correct40.0%63.3%
Earlier value correct60.0%80.0%
Yes-or-no question correct (always answering yes scores 20%)20.0%63.3%
Old value given as the current one43.3%33.3%
Unchanging claims recalled88.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

← All work