How LLMs Learn, Remember, and Improve During “Sleep”

Image for The sleep framework: A new way for LLMs to retain knowledge in continual learning

After studying this material, you should be able to:

  1. Explain the core limitations of static LLMs (knowledge cutoffs, catastrophic forgetting)
  2. Describe the sleep framework's two primary states and their biological inspiration
  3. Distinguish between memory consolidation and dreaming as technical mechanisms
  4. Understand why this approach theoretically prevents catastrophic forgetting
  5. Evaluate the framework's performance against baseline approaches

Step-by-Step Teaching

Step 1: Understanding the Problem First

Before learning the solution, you need to clearly understand what problem exists.

Problem A: Static Knowledge Cutoff

LLM is trained → Deployed → World changes → LLM knows nothing new
                                              ↑
                                         This gap grows forever

Think of it like hiring an expert who stopped reading anything new on their first day of work.

Problem B: Catastrophic Forgetting

When you try to update the model with new information:

Model learns Task B
        ↓
Performance on Task A DEGRADES severely
        ↓
Like learning Spanish and forgetting English

Problem C: Context Window Limitation

  • In-Context Learning (ICL) = giving the model information inside a single conversation
  • Once the conversation ends → information is gone
  • It is purely short-term memory with no persistence

Key Insight: These three problems together mean current LLMs cannot truly learn continuously after deployment.


Step 2: The Biological Inspiration

The researchers looked at how human brains solve a similar problem.

Human Memory Consolidation During Sleep

Sleep StageBrain ActivityMemory Function
NREM (Deep Sleep)Slow-wave activityTransfers fragile short-term memories → stable long-term storage
REM SleepActive simulationExplores connections, practices scenarios, strengthens patterns

The key observation:

  • Humans do not learn everything in one continuous session
  • We alternate between active experience and offline rest
  • Rest is not passive — it is when consolidation actually happens

Analogy: Studying for an exam works better with sleep between sessions than cramming continuously. Sleep is doing work on your memories.


Step 3: The Sleep Framework — Core Architecture

The framework gives LLMs a two-state lifecycle:

┌─────────────────────────────────────────────────────┐
│                                                     │
│   WAKE STATE (Active)          SLEEP STATE          │
│   ─────────────────            ───────────          │
│   • Interact with users   →    • Memory             │
│   • Answer questions           Consolidation        │
│   • Accumulate new info   →    • Dreaming           │
│   • Store in short-term        • Update parameters  │
│     context memory             • No user interaction│
│                                                     │
└─────────────────────────────────────────────────────┘
              ↑_____________cycle repeats______________↑

Critical distinction from traditional ML:

Traditional MLSleep Framework
Training phase is separate from inferenceTraining and inference alternate continuously
Static after deploymentPeriodically updates itself
Fixed knowledgeGrows knowledge over time

Step 4: Memory Consolidation — The NREM Equivalent

This is the first stage of sleep in the framework.

What happens technically:

Step 4a: Short-term traces are collected

  • During the wake phase, new information accumulates in the context window
  • This is fragile — it will disappear when context ends

Step 4b: Knowledge Seeding (Low-Rank Compression)

Short-term context tokens
        ↓
Identify compact set of KEY DIRECTIONS
(not copying everything — finding what matters most)
        ↓
Two signals guide what to keep:
  1. On-policy distillation → aligns with how model actually behaves
  2. Semantic reward → prioritizes meaning over token matching
        ↓
Write compressed knowledge into parameters

Why low-rank? Instead of storing every detail, the model finds the most important directions of information — like summarizing a book into its core themes rather than memorizing every sentence.

Step 4c: Parameter Expansion via MoE (Mixture of Experts)

Standard Model Parameters
        +
Pre-allocated MoE Memory Blocks (unlocked during sleep)
        ↓
New knowledge written into EXPANDED capacity
        ↓
Old knowledge NOT overwritten → catastrophic forgetting prevented

Key Insight: By expanding capacity rather than overwriting, the model gains new knowledge without losing old knowledge. This is the primary mechanism against catastrophic forgetting.

Why Two Signals Matter

SignalPurposeProblem it solves
On-policy distillationAligns consolidation with model's actual inference behaviorPrevents mismatch between training distribution and real use
Semantic rewardPrioritizes meaningful, task-relevant retentionPrevents wasting capacity on low-value token patterns

Step 5: Dreaming — The REM Equivalent

This is the second stage of sleep — autonomous self-improvement.

The Dreaming Loop:

Stage 1: Random Expert Activation
─────────────────────────────────
Activate different MoE experts randomly
→ Generates DIVERSE synthetic practice examples
→ Explores gradient directions not seen in normal wake data

Stage 2: Synthetic Data Generation
───────────────────────────────────
Model generates its own practice problems
→ Like a student making up practice questions for themselves

Stage 3: Reward-Based Filtering (RL Refinement)
────────────────────────────────────────────────
Not all synthetic examples are equally useful
→ Gradient-based filtering selects HIGH-VALUE examples
→ Discards low-signal synthetic data

Stage 4: Parameter Update
──────────────────────────
Model updates itself using only the best synthetic examples
→ Reasoning improves without any human-provided new data

Why Random Expert Activation Matters

Normal wake-time learning:
Gradients cluster in NARROW directions
→ Model improves only along familiar paths

With random expert activation:
Gradients spread across BROADER directions
→ Model explores more of its capability space
→ Better-conditioned optimization landscape

Analogy: A chess player who only practices their favorite openings vs. one who randomly practices unfamiliar positions. The second player develops more robust overall skill.


Step 6: The Theoretical Foundation

Why does this actually work mathematically?

For Memory Consolidation:

Goal: Minimize forgetting while maximizing new knowledge retention

Solution: Low-rank compression finds directions that satisfy BOTH:
  • Preserve on-policy behavior (what model already does well)
  • Satisfy semantic reward (what is worth knowing)

Result: Balanced optimization — not simply trading old for new

For Dreaming:

Problem with standard self-improvement:
  Model generates data → trains on it → generates similar data
  → Narrow feedback loop → limited improvement

Sleep framework solution:
  Random experts → diverse gradients → broader exploration
  Gradient filtering → emphasizes informative updates
  
Result: More balanced optimization landscape
        Better-conditioned gradients
        More stable learning progress

Key Theoretical Claim: Dreaming is not just data augmentation. It is a deliberate process for diversifying and selecting which updates the model learns from.


Step 7: Performance Results — Does It Actually Work?

Summary of Benchmarks:

TaskWhat Was TestedSleep Framework Resultvs. Baselines
Continual Translation (Manchu, Kalamang)Sequential language learningNear-zero performance dropICL, SFT suffered severe forgetting
Long-Context (BABILong)Understanding up to 10M tokensNear-perfect scalingOutperformed GPT-4, Titans
Factual Knowledge (SQuAD)Incorporating new facts48.9% accuracyBeat SFT, SEAL, base model
Math Reasoning (AIME 24/25)Complex problem solving79.2% accuracyBeat SFT, GRPO, OPSD

Reading the Results:

Most significant finding: 10M token long-context performance

Traditional ICL: Limited by context window size
Sleep Framework: Compresses long context INTO parameters
→ Effectively unlimited long-term memory

Second most significant: Near-zero forgetting in translation

This directly validates the core claim:
New language learned → Old languages NOT degraded

Step 8: Putting It All Together

The Complete Picture:

DEPLOYMENT LIFECYCLE OF A SLEEP-ENABLED LLM:

Week 1: Wake Phase
→ Model interacts, accumulates new facts in context

Week 1: Sleep Phase  
→ Consolidation: New facts compressed into MoE parameters
→ Dreaming: Synthetic reasoning practice, RL refinement
→ Model wakes up smarter, with new knowledge retained

Week 2: Wake Phase
→ Model uses both old AND newly consolidated knowledge
→ Accumulates more new information

Week 2: Sleep Phase
→ Cycle repeats...

Result: Continuously improving model with no knowledge cutoff

Comparison to Alternatives:

ApproachNew KnowledgeRetains Old KnowledgeLong-term Retention
Static LLM✗✓N/A
ICL only✓ (temporary)✓✗
Continuous Fine-tuning✓✗ (catastrophic forgetting)Partial
Sleep Framework✓✓✓

Summary: Core Concepts to Remember

  1. The fundamental tension in continual learning is between acquiring new knowledge and retaining old knowledge — the sleep framework resolves this tension through capacity expansion rather than overwriting

  2. Memory consolidation = compress short-term context into long-term parameters using low-rank structures + MoE blocks

  3. Dreaming = autonomous self-improvement through diverse synthetic data generation + gradient-based filtering

  4. The biological analogy is functional, not just metaphorical — NREM consolidation and REM simulation map directly to distinct technical mechanisms

  5. The key innovation is treating the training/inference boundary as artificial and replacing it with a continuous wake/sleep cycle

More to study