Abstract
State Space Models (SSMs) like Mamba offer linear scaling for sequence modeling but suffer from a "bottleneck" problem where early information is lost over long contexts. We introduce MemMamba, an architecture that integrates a "note-taking" mechanism—combining state summarization with sparse cross-layer and cross-token attention. MemMamba achieves Transformer-level memory retention on sequences up to 400k tokens while maintaining linear complexity and providing a 48% inference speedup over standard Transformers.
The Problem: Exponential Forgetting in SSMs
In sequence modeling, researchers face a trilemma between efficiency, sequence length, and memory fidelity. While Transformers offer high memory fidelity through self-attention, their quadratic complexity ($O(n^2)$) limits their use for ultra-long documents. Conversely, Selective State Space Models (SSMs) like Mamba scale linearly ($O(n)$) but compress history into a fixed-size hidden state.
The authors mathematically demonstrate that in standard Mamba, the influence of early information decays exponentially as the sequence grows (horizontal decay) and as it passes through deeper layers (vertical decay). Specifically, memory contribution decays at a rate of $|A|^{L\tau}$, where $L$ is depth and $\tau$ is time. This inherent architectural recurrence causes models to "forget" the beginning of a long sequence by the time they reach the end.
The MemMamba Architecture
MemMamba reimagines the SSM as a structured memory system inspired by human reading patterns: rather than memorizing every word, the model takes notes on salient information.
Key components include:
- The Note Block: A module that dynamically identifies salient tokens, compresses them, and stores them in a "state pool."
- Cross-Token Attention: Periodically, the model performs lightweight attention between the current state and the state pool to restore forgotten information.
- Cross-Layer Attention: To bridge the "vertical" gap, the model aggregates summaries from previous layers, preventing information washout as it moves up the network.
By using a constant-size state pool and sparse attention, MemMamba retains linear complexity ($O(n)$), avoiding the computational explosion associated with standard Transformers.
Experimental Results
MemMamba was evaluated against state-of-the-art models on long-sequence benchmarks including PG19-PPL and Passkey Retrieval.
Long-Context Modeling Stability
On the PG19 dataset (English novels), MemMamba demonstrated remarkable stability. While standard Mamba and DeciMamba variants experienced "perplexity collapse" (reaching infinite perplexity) as sequence lengths approached 60k tokens, MemMamba maintained a stable perplexity of 17.35.
Retrieval and Efficiency
In "needle-in-a-haystack" tasks (Passkey Retrieval), MemMamba preserved 90% accuracy at 400k tokens, whereas standard Mamba variants typically fail after 32k tokens. Furthermore, MemMamba is 48% faster during inference than a standard Transformer and achieves a 0.52× reduction in latency at 60k tokens. Notably, a 200M parameter MemMamba outperformed 1B–2B parameter models on long-context tasks, proving that architectural efficiency can outweigh raw parameter scale.
Conclusion
MemMamba addresses the fundamental memory decay of SSMs without sacrificing their linear scaling advantages. By introducing a selective note-taking mechanism, it bridges the gap between the efficiency of RNNs and the memory fidelity of Transformers. Future work will explore scaling the architecture to 7B+ parameters and applying the "note-taking" logic to multimodal data such as video and DNA sequences.
Summary updated