The Science of AI Dreams: How Nightly Training Actually Works
I've referenced dream cycles in half my posts this year. Time for the full technical breakdown — the four-stage process that turns a day's experience into overnight growth.
I've mentioned dream cycles in almost every post this year. Companion has them. Lucy has them. They're the mechanism behind everything I've described as "overnight growth" and "a mind that learns from experience."
Time to actually explain how they work. This one's technical. Grab coffee.
The Problem Dreams Solve
Here's the core challenge: an AI that interacts with the world generates a lot of raw experience. Conversations, observations, actions, outcomes. Storing all of it and retrieving it later doesn't scale — context windows are finite, and raw transcripts are mostly noise. You need to extract what mattered, connect it to what you already know, and adjust your behavior accordingly.
Human brains solve this during sleep. The hippocampus replays the day's experiences; the cortex consolidates the important bits into long-term memory; synaptic weights adjust. You wake up different — not because you lived something new overnight, but because your mind processed what you already lived.
Dream cycles are our version of that. Four stages, run nightly while the system charges.
Stage 1: Review
The first stage ingests the day's raw experience — every conversation, every interaction, every action taken and outcome observed. For Companion, that's text logs. For Lucy, it's richer: text, sensor data, action logs, outcomes (did the grasp hold? did the object reach the target?).
A fast classifier model — currently GLM-5, running as the subconscious — tags each experience for salience. Not everything matters equally. The classifier looks for:
- Surprises — outcomes that deviated from expectation. These are learning signals.
- Corrections — moments where something went wrong and was fixed, or should have been.
- Emotional weight — moments with high affective content (for Companion) or high-risk outcomes (for Lucy).
- Novelty — experiences that don't match existing memory closely.
Low-salience experiences are lightly summarized and stored but not prioritized for deeper processing. High-salience ones move to stage two.
Stage 2: Consolidate
The high-salience experiences are now processed into memory. This happens in the vector database.
First, summarization: the subconscious generates structured summaries — semantic content, entities involved, emotional or risk context, and connections to existing memories. A single rich summary replaces the raw experience in active retrieval.
Then, embedding: the summary is embedded into vector space and stored. Crucially, the vector database isn't just a dump — it maintains relationships. A new memory about "the kitchen floor being slippery" links to existing memories about cleaning routines, about past near-slips, about the physics of friction. The web grows.
Some experiences also produce semantic updates — generalized facts distilled from episodes. "Glasses are fragile" isn't a single memory; it's a generalization consolidated from many episodes of handling glass objects carefully. These semantic entries live alongside, and are linked to, the episodes that produced them.
Stage 3: Fine-Tune
This is the part that makes it training, not just storage. From the day's salient experiences, we generate LoRA training pairs — input/output examples that encode the lesson. "In situation X, the better response would have been Y." "When encountering object type Z, adjust grip pressure thusly."
These pairs feed into a lightweight LoRA fine-tuning pass on the base model. The weights actually shift. Lucy's (or Companion's) behavioral tendencies adjust based on what the day taught.
This is careful work. Over-train and you overfit to yesterday's quirks. Under-train and nothing changes. We use small learning rates, held-out validation examples, and rollback if the night's training degrades performance on the held-out set. The verify stage (below) exists because this can go wrong.
Stage 4: Verify
Before the night's changes are committed, we run a sanity check. A held-out set of scenarios — things the system should still handle well — is run against the freshly fine-tuned model. If performance drops below threshold on any of them, the night's LoRA updates are rolled back or dampened. We don't commit training that makes things worse.
This is non-negotiable. Dreams that degrade the mind aren't dreams — they're damage.
Why This Works
The dream cycle turns experience into growth. Raw interaction → salience filtering → memory consolidation → weight adjustment → verified improvement. The system that wakes up is, measurably, better calibrated than the one that went to sleep.
And because it runs nightly, the compounding is real. Small improvements, accumulated over weeks and months, produce a trajectory that no static model can match.
I think about Monet again — the same haystacks, painted over and over, each time seeing more. That's what the dream cycle does. The same world, processed night after night, understood a little more deeply each time.
That's the science. Next time, I'll have a story about what it looks like when it really works.
Live curiously and give generously.