Memory is usually described in three phases. Encoding is the initial acquisition of information while you are awake. Consolidation is the post-encoding process that stabilizes and reorganizes a memory so it survives. Retrieval is the later recall of that stored information. Sleep acts mainly on consolidation, and it does so differently depending on the stage.
During slow-wave sleep (N3), the hippocampus — a structure that rapidly captures new episodes — replays the day's activity in compressed bursts. These replays coincide with cortical slow oscillations and sleep spindles, and the coordinated timing appears to transfer hippocampal traces into neocortical networks, where they become less dependent on the hippocampus. This route favors declarative memory: facts, vocabulary, and events that can be consciously stated.
REM sleep, with its vivid dreaming and wake-like cortical activity, is more strongly associated with procedural memory — motor skills and habits — and with emotional memory. The distinction is a matter of emphasis, not a strict partition: both stages contribute to most memory types, and the balance shifts with the material.
The synaptic homeostasis hypothesis adds a complementary account. Waking learning strengthens many synapses broadly, which raises overall synaptic weight and reduces the contrast between important and trivial signals. Slow-wave sleep is proposed to downscale synapses proportionally, restoring the signal-to-noise ratio and making the day's relevant traces stand out again. Consolidation and downscaling are not competing stories; they describe selection and renormalization happening in the same stage.