The Capacity of Modern Hopfield Networks under the Data Manifold Hypothesis

Beatrice Achilli, Luca Ambrogioni, Carlo Lucibello, Marc Mezard, Enrico Ventura

TL;DR

This paper extends the theoretical capacity analysis of Modern (exponential) Hopfield Networks beyond simple rotationally invariant distributions to structured data. By framing pattern retrieval via an auxiliary Random Energy Model (REM) and replica calculation, the authors compute exact retrieval thresholds for binary patterns and data living on a lower-dimensional latent manifold (the Hidden Manifold Model). They find that a smaller latent dimension significantly degrades memory capacity, and in the infinite-data limit, the network naturally transitions from storing isolated patterns to projecting onto the entire underlying manifold.

What Problem Does This Paper Address?

Classical Hopfield networks store a number of memories linear in the system dimension ($P \propto N$). Modern Hopfield Networks (MHNs)—which underpin transformer self-attention mechanisms and share close ties with diffusion models—exponentially increase storage capacity ($P = e^{\alpha N}$) using exponential interaction functions.

However, recent statistical physics calculations of this exponential capacity (such as Lucibello & Mézard, 2024) relied on simplistic, rotationally invariant pattern distributions (e.g., spherical or isotropic Gaussian patterns). Real-world data violates this assumption: it is discrete (e.g., binary) or concentrated on low-dimensional sub-manifolds (the data manifold hypothesis). The authors investigate how structured data and intrinsic latent dimensionality affect the critical load $\alpha_1(\lambda)$ at which memories can still be retrieved.

Methods

The authors build on a signal-to-noise framework and statistical mechanics:

  • Signal-to-Noise & REM Equivalence: To determine if a target pattern $\boldsymbol{\xi}^1$ remains a stable local minimum, the energy is split into a signal term and an interfering noise term. Evaluating this noise term is mathematically identical to computing the free energy of a Derrida Random Energy Model (REM).
  • Replica Formalism for the Hidden Manifold Model (HMM): Patterns are modeled as $\boldsymbol{\xi}^\mu = \sigma(\frac{1}{\sqrt{D}}\boldsymbol{F}\boldsymbol{z}^\mu)$, where $\boldsymbol{z}^\mu \sim \mathcal{N}(0, \boldsymbol{I}_D)$ are $D$-dimensional latent vectors, $\boldsymbol{F} \in \mathbb{R}^{N \times D}$ is a random feature matrix, and $\sigma$ is an activation function. The authors apply the replica method with a Replica Symmetric (RS) ansatz to evaluate the REM cumulant generating function $\zeta_{\text{HMM}}(\lambda)$ and derive the saddle-point equations over overlap order parameters ($q_d, q_0, m$ and their conjugates).
  • Generalization Limit Dynamics: In the limit of an infinite number of patterns sampled from a linear manifold, the authors evaluate the gradient descent dynamics on the MHN energy function.

Datasets

The work is purely theoretical and uses synthetic generative distributions rather than empirical benchmarks:

  • Binary Patterns: $\boldsymbol{\xi}^\mu \sim \text{Unif}(\{-1, +1\}^N)$.
  • Hidden Manifold Model (HMM): Latent Gaussian vectors $\boldsymbol{z} \in \mathbb{R}^D$ mapped through a random matrix $\boldsymbol{F} \in \mathbb{R}^{N \times D}$ and non-linearities: linear, $\text{ReLU}$, and $\tanh$, evaluated across various aspect ratios $\alpha_D = D/N$.

Key Insights and Ideas

  • Latent Dimension Directly Governs Capacity: Even though the expected Euclidean distance between patterns does not depend on the latent dimension $D$, the retrieval threshold $\alpha_1(\lambda)$ decreases as $D$ shrinks (smaller $\alpha_D = D/N$). Intrinsic structure crowds memories together in the latent space, generating stronger interference noise.
  • Capacity Saturation via Extreme Norms: For unbounded patterns (or non-saturating activations), unbounded fluctuations can produce rare patterns with large norms that overwhelm the retrieval signal. Consequently, the retrieval threshold $\alpha_1(\lambda)$ saturates at large inverse temperatures $\lambda$. In contrast, bounded activations like $\tanh$ saturate at much higher $\lambda$.
  • From Retrieval to Manifold Generalization: When the number of stored patterns from a linear manifold grows infinitely large, individual local minima merge. Choosing $\lambda = 1$ yields a one-step projection operator $\boldsymbol{x}^{(t+1)} = \boldsymbol{F}\boldsymbol{F}^\top \boldsymbol{x}^{(t)}$, making the entire underlying data manifold the global attractor rather than isolated discrete points.

Key Results

  • Binary Patterns: The authors derive the exact analytic rate function $s_{\text{bin}}(\epsilon) = \frac{1+\epsilon}{2}\log(1+\epsilon) + \frac{1-\epsilon}{2}\log(1-\epsilon)$, mapping out the phase diagram showing the retrieval boundary $\alpha_1(\lambda)$ alongside the REM condensation line $\alpha_*(\lambda)$.
  • Hidden Manifold Capacities:
  • For ReLU, linear, and tanh activations, the single-pattern retrieval threshold curves $\alpha_1(\lambda)$ systematically shift downward as the ratio $\alpha_D = D/N$ drops from $1.0$ to $0.1$.
  • The capacity curves for ReLU and linear activations plateau early due to pattern norm fluctuations, while $\tanh$ sustains higher retrieval capacity before saturating at significantly larger coupling $\lambda$.

Limitations and Future Work

  • Beyond Single-Pattern Stability: The analysis focuses strictly on the stability of a single target pattern against random noise (signal-to-noise threshold). It does not analyze the global landscape, spurious minima, or the stability of mixtures of patterns.
  • Replica Symmetry Assumption: The calculation assumes replica symmetry (RS); potential replica symmetry breaking (RSB) effects near the spin-glass / condensation transitions were not investigated.
  • Idealized Manifolds: The generative model is restricted to random linear projections followed by element-wise activations, which is more tractable than real-world complex image or text manifolds.
  • Connection to Diffusion Models: The authors point out a direct mapping between MHNs with spherical patterns and score-based Diffusion Models (identifying $1/\lambda$ with diffusion time $t$), highlighting theoretical analysis of diffusion memory regimes as an important avenue for future work.

Summary updated

BibTeX
@inproceedings{achilli2025capacity,
  author = {Beatrice Achilli and Luca Ambrogioni and Carlo Lucibello and Marc Mezard and Enrico Ventura},
  title = {{The Capacity of Modern Hopfield Networks under the Data Manifold Hypothesis}},
  booktitle = {NFAM @ ICLR},
  year = {2025},
  url = {https://openreview.net/forum?id=OBQwZaO4pt},
}
Figure