Hopfield Networks is All You Need
Hubert RamsauerBSBernhard SchäflJLJohannes LehnerPSPhilipp SeidlMichael WidrichTAThomas AdlerLGLukas GruberMHMarkus HolzleitnerMilena Pavlović
Geir Kjetil SandveVictor GreiffDavid Kreil +4
Hubert Ramsauer
BSBernhard Schäfl
JLJohannes Lehner
PSPhilipp Seidl
Michael Widrich
TAThomas Adler
LGLukas Gruber
MHMarkus Holzleitner
Milena Pavlović

Geir Kjetil Sandve
Victor Greiff
David Kreil
+16
We introduce a continuous-state modern Hopfield network whose update rule is equivalent to the transformer attention mechanism. The network can store exponentially many patterns (in the dimension of the associative space), retrieve a pattern with a single update, and incur an exponentially small retrieval error. Its update rule has three types of fixed points: global averaging over all patterns, metastable states averaging over a subset, and single-pattern fixed points. This equivalence characterizes transformer heads: early layers perform global averaging, while higher layers do partial averaging via metastable states. The Hopfield layers can be integrated into deep learning architectures, providing pooling, memory, association, and attention, and achieve state-of-the-art on multiple instance learning, immune repertoire classification, small UCI classification tasks, and drug design datasets.

arXiv ·
· July 16, 2020