한국어

KNOWLEDGE

Does AI need to sleep too?

In a small model, sleep (stop training and run noise so each connection updates by looking only at the two neurons it joins) was confirmed to improve performance. But no evidence was found that the same holds in large models.

Sleep is still a strange territory. Why we need it, and what happens to memory during it, are questions scientists have not yet agreed on. A 2022 paper put a neural network to sleep, and an old task it had forgotten came back.

Put it to sleep yourself

This network already knows old pictures A·B; it is knowledge learned earlier. Let’s teach it new pictures.

One line is the sum of the connections from the lit cells in that group. Orange (+) votes for, blue (−) votes against, and thicker is stronger. The two lines add up to the output’s score, and the output with the highest score is the answer. Shared cells are the ones all four pictures turn on; A cells are lit only by picture A. Press an output to see the sum.

Why it came back: press and watch, one at a time

Look only at the two lines into C for picture A, starting right after the new pictures were learned.

The moment C sends a signal, each cell before it follows just one rule.

Predict the result

For specialists: per-cell values, running code, parameters

This is the same network as in the story above. The code below is what actually runs on this page, and every cell in the pictures is a value from that code.

Input at night
Sleep speed

Structure: 100 input neurons → 4 output neurons, 400 connections

100 input neurons. By day the chosen picture is the input.

When picture A is shown, the connections of the lit cells cast votes

A output

spikes 0

B output

spikes 0

C output

spikes 0

D output

spikes 0

One cell is the connection from one input neuron to that output. Only the cells the chosen picture turns on are drawn strong. Orange (+) votes for, blue (−) votes against, and a stronger color is a stronger vote. The votes add up to that output’s score, and the output with the highest score is the answer. The bar is the membrane potential; when it fills, the neuron fires.

Rule: a connection sees only the two neurons it joins

Before (input)After (output)ConnectionThis stepAll night
firesfiresstronger00
silentfiresweaker00
anysilentno change00
pre[i] = rng() < input[i] * rateScale ? 1 : 0;
mem[k] = decay * mem[k] + alpha * sum(w[k][i] * pre[i]);
if (mem[k] >= beta) {
  w[k][i] += pre[i] ? inc * g(w[k][i]) : -dec * g(w[k][i]);
  mem[k] = 0;
}

g(w) is a gatekeeper found in the authors’ code. It is nearly 0 on clearly positive connections and close to 2 on negative ones, so what actually moves is mostly the negative connections. The paper’s pseudocode has no such term. The values inc 0.0035, dec 0.0002, decay 0.999, and beta 1.045 come from the authors’ code.

The paper’s pseudocode as written did not bring it back. Without the gatekeeper g(w) and the decay, the new outputs’ connections grow without end and accuracy stays at 50% for 11 to 14 cells. The same held across the range tried, with inc and dec scaled down together as far as 1/1,000. That is why this page uses the rule in the authors’ code.

Scores: when shown picture A

Score of the A output Higher score of the C and D outputs. The network answers A only when the blue line is on top.

Plain words and terms

Word used aboveTerm
shouts new answers at old picturescatastrophic forgetting
sends a signalspike (fire)
built-up signalmembrane potential
strength of a connectionweight
old pictures, new picturesold task, new task
one turn of the nightstep, 30,000 of them

It looks like reflection, so why call it sleep?

  1. On the outside it resembles reflection. Picture someone writing a diary at the end of the day. They stop what they were doing and sort through what they knew along with what came in today. The night stage likewise stops new learning and runs an input shaped like the average of the four pictures.
  2. What happens inside is closer to sleep. Reflection weighs old and new knowledge against each other and reaches a conclusion. This sleep does no reasoning. Like biological neurons, it only updates the weights of its nodes, a rather naive process. A connection sees only whether the neurons before and after it just fired.
ReflectionNeural network sleep
Stops what it was doingYesYes
Handles old and new togetherYesYes (average input)
Reasons over old and new knowledgeYesNo
What it doesWeighs things and concludesUpdates the weights of nodes

What running it showed

The code above was run with 100 seeds to measure the share of the four pictures it gets right. This is an own implementation of the small experiment in the paper’s Figure 1.

Overlapping cellsAfter new taskAfter sleepOld task (after sleep)
10 cells100%100%100%
11 cells50%100%100%
13 cells50%99%99%
14 cells50%80%59%
15 cells50%50%0%
16 cells (all four identical)25%25%0%

The larger experiments the paper reports are below. The numbers are test accuracy (%) after learning five tasks in turn (paper Table 1). Sleep rises well above the lower bound but does not recover everything.

DataNo sleepSleep0.75% of images storedAll learned at once
MNIST19.4948.4779.9198.02
CIFAR-1019.0144.5539.3972.43

How far this was checked

ConfirmedThe paper’s sleep procedure (Algorithm 1) and the numbers in Table 1; the sleep rule and parameters in the authors’ code (the repository files were read). The results under “What running it showed” (this page’s code was run with node). The authors’ MATLAB code itself was not run.

HypothesisThe reading that sleep rebalances a tilted network rather than reviving old memories. It fits this small experiment, but a network with two hidden layers is reported to show increased input for the old task in its second hidden layer (paper Fig. 5), and no experiment was found that separates the two explanations.

UnknownWhether it works when large networks are trained end to end, and whether an independent team has reproduced it (none was found). Whether overlap resolves this way in the brain.

Differences from the paperThis implementation starts forgetting at 11 cells and reaches 50% at 15. The paper’s Figure 1B starts forgetting at 13 and reaches about 75% at 15 (values read from the figure). The 16 lit cells per picture were counted in the paper’s Figure 1A; the learning rate of 0.1 and 4 updates follow the authors’ script, and no momentum follows the paper’s text.

Common misconceptions

MythSleep makes old memories strong again.

In factIn this experiment the connections into A barely change. The new outputs shout less at old pictures, so A wins again. The paper’s Figure 1C points the same way.

MythThe brain sleeps this way too.

In factThe idea comes from sleep research, but there is no hippocampus, no sleep stage, and no sequence replay. The authors also acknowledge the simplification. This result is not evidence for a brain mechanism.

MythNothing is stored.

In factOld pictures are not stored, but the average of the inputs is. The paper says inputs unrelated to the average still bring back part of it, but the average input does better (Methods, SI §4). The paper’s thresholds and scales were also searched using training set performance, and the paper does not say whether old task data was used for that.

Frequently asked questions

What is catastrophic forgetting?

When a neural network learns tasks in turn, it does well on the latest task while performance on earlier tasks falls sharply. In the paper’s MNIST experiment, learning five tasks in turn gave an overall accuracy of 19.49%.

What does sleep do in a neural network?

It replaces the activation function with a threshold and runs noise built from the average strength of past inputs. When a later neuron fires, the connection is strengthened if the earlier neuron also fired and weakened if it stayed silent; then the network returns to its original form. The paper calls this procedure Sleep Replay Consolidation (SRC).

Does sleep need labeled data?

The sleep stage uses no labels, no errors, and no stored pictures, only the average of the inputs. However, the paper searched its parameters using training set performance, and deciding when to sleep requires knowing when the task changes.

How much does sleep improve performance?

In the paper’s Table 1, MNIST rose from 19.49% to 48.47% and CIFAR-10 from 19.01% to 44.55%. The upper bounds from learning everything at once are 98.02% and 72.43%. On MNIST it is below storing 0.75% of the images (79.91%); on CIFAR-10 it is above that method (39.39%).

Is this used in large language models like ChatGPT?

No application of this method to large language models or products was found. Most follow-up work also comes from the authors’ group, and no large-scale forgetting test was found.

Does human sleep protect memory too?

There is evidence that sleep benefits memory, but the key finding that it protects memory from interference by new learning has failed in a direct replication (Bailes et al. 2020). This paper’s result cannot explain human sleep.

Further reading