The Mathematics of AI Memory Retrieval: Fused Multi-Signal Scoring for Agent Recall

When an AI agent recalls long-term context, it faces a fundamental retrieval challenge. If it filters memories purely by semantic similarity (as standard semantic search systems do), it falls into the truncation trap—losing older, highly important memories simply because they are slightly less similar than a trivial event that occurred five minutes ago.
To prevent this, Spector Memory fuses semantic similarity, temporal decay, emotional sentiment, and historical importance directly into a single, integrated scoring engine. Inspired by human sensory gating, Spector filters out irrelevant candidates in early, low-cost phases, reserving heavy semantic evaluations for only the most promising memories.
Here, we break down the individual mathematical components of Spector's retrieval pipeline and present the Grand Unified Scoring Equation.
1. The Individual Components of Recall
Scoring a candidate memory requires fusing multiple cognitive dimensions. The final retrieval score determines which memories are returned to the agent.
1.1 Thalamic Sensory Gating Filter
To scan millions of memories in milliseconds, Spector applies a series of cheap gate filters before computing vector similarity:
$$G_i = \mathbb{I}(F_i == 0) \cdot \mathbb{I}\left((T_i \land M_q) == M_q\right) \cdot \mathbb{I}\left(V_{\text{min}} \le V_i \le V_{\text{max}}\right)$$
- Gating Variables: $F_i$ represents the deletion flag (1 if deleted); $T_i$ is the memory's topic tag filter; $M_q$ is the query tag filter; $V_i$ is the emotional valence value.
- Selectivity: Skipping tag-mismatched or valence-out-of-range records instantly saves massive computational overhead.
1.2 Strictness-Modulated Similarity
Once a memory passes the gates, its calibrated semantic distance is converted to standard similarity:
$$\text{sim}_i = \frac{1}{1.0 + \|\vec{q} - \vec{x}_i\|_2 \cdot s}$$
Where $s$ is the strictness coefficient. Increasing strictness transforms the standard similarity curve into a steep threshold, allowing only near-exact matches to rank highly.
1.3 Lateral Retrieval (Parabolic Search)
For creative tasks, the agent can trigger lateral mode. Instead of nearest neighbors, Spector uses a parabolic Radial Basis Function (RBF) that peaks at orthogonality:
$$\text{sim}_{\text{lateral}, i} = \max\left( 0.0, \, 1.0 - 0.25 \cdot \left(\|\vec{q} - \vec{x}_i\|_2^2 - 2.0\right)^2 \right)$$
This surfaces memories that share tags but are semantically distant, enabling creative leaps.
1.5 Bucketed Power-Law Decay
Forgetting in human memory follows a power law ($R = a \cdot t^{-d}$). Computing continuous exponents is computationally heavy. Spector maps age into 12 discrete buckets and multiplies by a precomputed decay coefficient:
$$\text{decay}(B_i) = \text{DECAY\_BUCKETS}[B_i]$$
- Reconsolidation (LTP): Each recall shifts the decay bucket right (halving perceived age): $B_{\text{adjusted}, i} = B_{\text{raw}, i} \gg R_{\text{agent}, i}$.
- Auto-Recall Shift: System-level auto-recalls shift the index down gentler: $B_{\text{final}, i} = B_{\text{adjusted}, i} - \min(\lfloor R_{\text{spector}, i} / 3 \rfloor, 2)$.
- Arousal Resistance: High-arousal memories scale the decay toward 1.0: $\text{decay}_i = \min(1.0, \, \text{decay}_i \cdot \text{arousalModifier}(A_i))$.
- Zeigarnik Effect: Unresolved task memories are locked at bucket
0($\text{decay} = 1.0$).
1.6 ACT-R Ring-Buffered Spaced Repetition
When the full ACT-R model is active, the decay multiplier computes the spacing effect using a log of relative recall timestamps. Let $S_{a, i} = \sum_{j=1}^{N_r} (t - t_{ij})^{-d} + (t - t_{\text{creation}})^{-d}$ represent the base-level activation sum. The normalized decay is then:
$$\text{decay}_{\text{ACT-R}, i} = \sigma(\ln(S_{a, i})) = \frac{S_{a, i}}{1.0 + S_{a, i}}$$
This models the biological principle that spaced recalls produce stronger, more durable memory activation than massed recall, while bypassing expensive runtime computations.
1.7 Bjork's Two-Factor Storage Boost
Bjork's New Theory of Disuse dictates that a memory's accessibility is boosted by its consolidated storage strength ($S_i \in [1.0, 5.0]$):
$$\text{storageBoost}_i = S_i^{E_s}$$
Where $E_s$ is the configuration exponent (default: $0.3$).
2. The Grand Unified Recall Equation
Combining all filters, weights, and modulations, the retrieval score $FS_i$ of memory $i$ before graph traversal is computed in two steps.
First, the base fused score is calculated: $$FS_{\text{base}, i} = G_i \cdot \text{sim}_i \cdot \left( 1.0 + \beta \cdot \frac{I_i}{10.0} \cdot \text{decay}_i \cdot \text{storageBoost}_i \right)$$
Then, the final score incorporates valence alignment, tag overlaps, and hyperfocus boosts: $$FS_i = FS_{\text{base}, i} \cdot \left( 1.0 - \frac{|V_q - V_i|}{255.0} \right) \cdot (1.0 + \text{overlapRatio}_i \cdot R_{\text{tag\_boost}}) \cdot \delta_{\text{hyperfocus}}$$
Post-Scoring Habituation Penalty
To break repetitive recall cycles (filter bubbles), the score decays exponentially with each presentation in the active session:
$$FS_{\text{hab}, i} = FS_i \cdot \text{rate}^{(n_i - 1)}$$
Spreading Activation Graph Traversal
Finally, the top seed candidates discover adjacent context via Hebbian matrices ($H$), temporal chains ($T_{\text{fwd}}, T_{\text{bwd}}$), and entity graphs ($E$). Activated neighbor nodes receive a propagation score:
$$ \begin{aligned} FS'_j = \max \Big( & FS_{\text{hab}, j}, \, \max_{s \in H} 0.3 \cdot FS'_s, \, \max_{s \in T_{\text{fwd}}} 0.8 \cdot FS'_s, \\ & \max_{s \in T_{\text{bwd}}} 0.7 \cdot FS'_s, \, \max_{s \in E} \left[ 0.25^{\text{hop}} \cdot \text{fanFactor} \cdot FS'_s \right] \Big) \end{aligned} $$
Where the entity graph traversal is attenuated by a normalized degree weight: $$\text{fanFactor} = \frac{1}{\sqrt{\text{refCount}}}$$
3. Recall Scoring Flow
By fusing these calculations into a single memory lookup, Spector achieves sub-millisecond retrieval speeds while avoiding the semantic drop-offs that plague traditional vector databases:
Skip deleted items, mismatch tags, and wrong valence"] B --> C{"🔍 Mode Check"} C -->|"Standard"| D["📐 Phase 5: Standard Similarity
Semantic distance with strictness"] C -->|"Lateral"| E["📐 Phase 5: Lateral Similarity
Orthogonal Parabolic search"] D --> F["📉 Phase 6: Fused Scoring
Incorporate Ebbinghaus decay & Bjork boost"] E --> F F --> G["☯️ Valence Alignment & Tag Overlaps
Proportional boosts & mood-congruent multipliers"] G --> H["🚨 Session Habituation Penalty
Exponential attenuation for repeats"] H --> I["🌐 Graph Spreading Activation
BFS traversal: Hebbian, Temporal, Entity Graph"] I --> J["🏆 Sorting & Return
Extract Global Top-K candidates"]