Mamba model recall improves by learning simple hashing rules
On the Recall Scaling Laws in Mamba: A Theoretical and Mechanistic Study via Hashing
Machine LearningComputation and Language
Summary
Remembering links between things is important for language models like Mamba. The authors studied how Mamba internally recalls information and found it works by learning simple hashing functions, which are ways to quickly find data. They created a math framework to predict how well Mamba can remember information based on how big its memory and vocabulary are. Their tests showed the predictions matched real results and explained how different model parts affect memory. This helps understand and improve how these models remember context.
Associative RecallMemory capacityMamba modelHash functionsJohnson-Lindenstrauss lemmaEmbedding dimensionsState dimensionsSimilarity-preserving hashingMechanistic interpretabilityMulti-head architectures
Authors
Yuval Koren, Assaf Ben-Kish, Raja Giryes, Lior Wolf, Itamar Zimerman
Abstract
Associative Recall (AR) is the cognitive ability to learn and retrieve links between items in memory. In NLP, AR is used as a benchmark for evaluating the in-context memory capacity of architectures such as Mamba, and has been found to strongly correlate with language modeling performance. This paper explores AR from the perspective of mechanistic interpretability, aiming to reverse-engineer the exact internal algorithm used by Mamba to perform recall. Our key insight is that Mamba performs recall by implicitly learning linear hash functions, and we identify the low-level circuit that enables this behavior. Building on these findings and inspired by theoretical tools in similarity-preserving hashing, such as the Johnson-Lindenstrauss lemma, we develop a theoretical framework for analyzing AR, which we term Recall Scaling Laws. Given the vocabulary size and the number of facts in context, this framework allows us to (1) predict the embedding and state dimensions required for Mamba to achieve perfect recall, (2) predict recall success probability given the model dimensions, and (3) analyze multi-layer models and multi-head SSM patterns. Empirical results show that our theoretical findings are accurate and predictive, offering insights into how AR capacity scales with vocabulary, state, embedding size, and architecture.