The Forgetting Curve: Modeling Ebbinghaus Curves in Software
In 1885, German psychologist Hermann Ebbinghaus conducted a series of self-experiments, measuring his ability to retain nonsense syllables over time. His research yielded the first mathematical formulation of the Forgetting Curve—a curve demonstrating that human memory retention declines exponentially or power-law style after learning new information, unless reinforced.
In software engineering, databases are static: they remember everything with 100% fidelity until a delete command is issued. However, in cognitive AI, keeping all historical data forever leads to noise, high inference latency, and context window overflow. To replicate human pruning efficiency, Spector models Ebbinghaus's forgetting curve directly into its retrieval scoring.
The Mathematics of Forgetting
Spector models temporal decay using a power-law formulation, which empirical cognitive science shows is more realistic for long-term memory than a simple exponential decay:
\[S_{decay} = S_{similarity} \times (t - t_{last})^{-\lambda}\]
Where:
- \(S_{decay}\) is the decayed memory score used for retrieval ranking.
- \(S_{similarity}\) is the initial vector cosine similarity computed by the embedding model.
- \(t\) is the current epoch timestamp.
- \(t_{last}\) is the timestamp when this specific memory was last recalled or updated.
- \(\lambda\) is the decay exponent, representing the forgetting rate configured in the active Cognitive Profile.
Unlike exponential decay, which drops off too sharply and makes long-term recovery impossible, power-law decay simulates a rapid initial drop followed by a very flat, stable tail. This tail ensures that while details fade quickly, a trace remains for possible reinforcement.
Synaptic Reinforcement via Long-Term Potentiation (LTP)
Every time an agent recalls a memory, the connection strengthens. In biological terms, this is Long-Term Potentiation. In Spector, each recall event resets the decay timer \(t_{last}\) and increments a recall frequency counter \(f\), which dynamically alters the decay rate:
\[\lambda_{effective} = \frac{\lambda_{base}}{1 + \alpha \ln(f + 1)}\]
As \(f\) increases, the decay rate \(\lambda_{effective}\) drops. A memory accessed frequently eventually hits a permastore floor \(P_f\), rendering it immune to further decay:
\[S_{final} = \max(S_{decay}, P_f)\]
This ensures that critical facts (like user API keys or core business rules) remain instantly accessible, while transient remarks fade into silence.
Practical Example: Adjusting base decay rate in Java
Developers can configure base decay rates dynamically using cognitive profiles in Java:
// Configure Spector memory engine with low base decay for critical tasks
SpectorMemory memory = DefaultSpectorMemory.builder()
.cognitiveProfile(CognitiveProfile.builder()
.decayRate(0.05f) // Slow base decay
.permastoreFloor(0.40f) // Keep important memories active
.build())
.build();
By leveraging this biological framework, Spector balances short-term plasticity (rapid learning) with long-term stability (retaining core facts), avoiding context window bloat and eliminating noise.