Memory Decay and Forgetting Curves: The Math Behind Remembering
Memory Decay and Forgetting Curves
Hermann Ebbinghaus ran memory experiments on himself in the 1880s. His findings still guide how we build AI memory systems.
The Ebbinghaus Forgetting Curve
Ebbinghaus memorized nonsense syllables and tested recall over time. His results:
The pattern: rapid initial decay, then a long tail.
Exponential vs Power-Law Decay
Two mathematical models fit forgetting:
**Exponential decay**: R(t) = e^(-t/τ)
**Power-law decay**: R(t) = (1 + t)^(-β)
Research shows human memory uses BOTH. Recent memories decay exponentially; older memories follow power-law.
Our Hybrid Implementation
fn calculate_retention(hours: f32, initial_strength: f32) -> f32 {
// Exponential component (half-life of 24 hours)
let exp_decay = (-hours / 24.0).exp();
// Power-law component (β = 0.5)
let power_decay = (1.0 + hours).powf(-0.5);
// Blend: more exponential early, more power-law later
let blend = (hours / 168.0).min(1.0); // 1 week transition
let retention = exp_decay * (1.0 - blend) + power_decay * blend;
initial_strength * retention
}
Spacing Effect
Ebbinghaus also discovered the spacing effect: memories reviewed at increasing intervals are retained longer. We implement this:
fn on_access(memory: &mut Memory) {
let interval = memory.last_access - memory.previous_access;
if interval > memory.optimal_interval {
// Spaced retrieval strengthens more
memory.strength += BOOST * 1.5;
memory.optimal_interval *= 2.0; // Increase next interval
} else {
memory.strength += BOOST;
}
}
Consolidation During Idle
The brain consolidates memories during sleep. Shodh-memory runs a consolidation loop during idle periods:
async fn consolidation_loop() {
loop {
sleep(Duration::from_secs(300)).await;
apply_decay_to_all_memories();
replay_important_memories(); // Like dreaming
prune_weak_connections();
}
}
This ensures memory quality degrades gracefully without active maintenance.
Results
With hybrid decay, our memory quality over time:
Without decay, noise accumulates until retrieval quality collapses.