On the Statistical Mechanics of Attention
Organizations: Center for Foundation Models and Generative AI, Northwestern University Department of Computer Science, Northwestern University · Department of Computer Science, College of Connected Computing, Vanderbilt University · Department of Physics, National Taiwan University · Department of Statistics and Data Science, Northwestern University
Abstract
We revisit the statistical mechanics of Transformer attention via modern Hopfield models. We present a free-energy formalism to characterize parameter regimes and critical thresholds for robust attention inference. The resulting free-energy landscape incorporates randomness in query states and attention weights. Attention then emerges as the equation of motion of the corresponding statistical-mechanical system (i.e., modern Hopfield model) through the standard free-energy minimization principle. This allows us to identify first-order phase transitions in attention between glassy and robust-inference phases. We further extend to attentions with stochastic queries and keys. Together, our results provide a rigorous statistical-mechanics framework for characterizing phase structure and inference reliability across a family of Transformer attention mechanisms.
Figures & tables
| Concept | Meaning for Attention | Dictionary |
| Fenchel Conjugate | It transforms a microscopic quantity into a macroscopic one, and constructs the free-energy objective. | Definitions C.6 , 2.1 and 2.1 |
| Tsallis Entropy | Attention Family: softmax , entmax , and sparsemax . | Sections C.3 , 2.1 and 3.3 |
| Query-Key Similarity (Overlap ) | It measures the alignment between queries and memories. A larger overpal indicates a stronger retrieval preference for that memory. | Definition 3.2 |
| Free-energy | It defines free-energy landscape and enables assigning energy value for each local minimum. It encodes equation of motion as attention rule. | Definition 2.1 , Propositions 3.2 and 3.3 |
| Coexistence (Energy Crossing) | It occurs when two distinct stable retrieval states have the same free energy simultaneously. | Definitions 4.2 and 4.1 |
| Spinodal | It occurs when the energy barrier of a local mimimum disappers. This drives a retrieval state to the other. | Definitions 4.3 and 4.2 |
Appendix figures & tables12 assets
Supplementary material from the paper’s appendix.