Mamba recall capacity improves with hashing and model size

On the Recall Scaling Laws in Mamba: A Theoretical and Mechanistic Study via Hashing

Machine LearningComputation and Language

Summary

Remembering connections between things is important for both humans and AI models. This paper studies how the AI model Mamba remembers facts by discovering it uses a kind of mathematical shortcut called linear hashing. The researchers created a theory that predicts how well Mamba can recall information based on its size and design. Their predictions matched experiments, which helps us understand how memory in AI could get better as models grow.

What this means in practice

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.