HackerPapers

arXiv:2008.02217cs.NE

Hopfield Networks is All You Need

Hubert Ramsauer, Bernhard Schäfl, Johannes Lehner, Philipp Seidl, Michael Widrich, Thomas Adler, Lukas Gruber, Markus Holzleitner, Milena Pavlović, Geir Kjetil Sandve, Victor Greiff, David Kreil, Michael Kopp, Günter Klambauer, Johannes Brandstetter, Sepp Hochreiter

Abstract

We introduce a modern Hopfield network with continuous states and a corresponding update rule. The new Hopfield network can store exponentially (with the dimension of the associative space) many patterns, retrieves the pattern with one update, and has exponentially small retrieval errors. It has three types of energy minima (fixed points of the update): (1) global fixed point averaging over all patterns, (2) metastable states averaging over a subset of patterns, and (3) fixed points which store a single pattern. The new update rule is equivalent to the attention mechanism used in transformers. This equivalence enables a characterization of the heads of transformer models. These heads perform in the first layers preferably global averaging and in higher layers partial averaging via metastable states. The new modern Hopfield network can be integrated into deep learning architectures as layers to allow the storage of and access to raw input data, intermediate results, or learned prototypes. These Hopfield layers enable new ways of deep learning, beyond fully-connected, convolutional, or recurrent networks, and provide pooling, memory, association, and attention mechanisms. We demonstrate the broad applicability of the Hopfield layers across various domains. Hopfield layers improved state-of-the-art on three out of four considered multiple instance learning problems as well as on immune repertoire classification with several hundreds of thousands of instances. On the UCI benchmark collections of small classification tasks, where deep learning methods typically struggle, Hopfield layers yielded a new state-of-the-art when compared to different machine learning methods. Finally, Hopfield layers achieved state-of-the-art on two drug design datasets. The implementation is available at: https://github.com/ml-jku/hopfield-layers

arXiv comments
10 pages (+ appendix); 12 figures; Blog: https://ml-jku.github.io/hopfield-layers/; GitHub: https://github.com/ml-jku/hopfield-layers
Journal reference
DOI
Subjects
cs.NENeural and Evolutionary Computing cs.CLComputation and Language cs.LGMachine Learning stat.MLMachine Learning (Statistics)

On Hacker News

Linked by 10 identifiable commenters in 10 comments across 9 threads, from Dec 2020 to Jan 2026. Found in 6 HN submissions from Aug 2020 to Aug 2025. Open submission discussions.

Comments linking this paper, per year.

Discussed in comments9 threads

  1. The Q, K, V Matrices 1 comment
    • There is a LOT of effort in the research community currently: 1. Improving the Self-Attention in the Transformer as is, keeping the quadratic complexity, which has some theoretical advantage in principle[1]: The most hyped one probably DeepSeek's Multi-Latent Attention[15]…

      korbipView on HNParent context

  2. LM2: Large Memory Models 1 comment
    • This immediately makes my mind bring up Hopfield networks https://arxiv.org/abs/2008.02217 when I worked with them circa 2012 they were practically toys. Maybe we are in a better place now?

      igleriaView on HNParent context

    • This is not surprising considering the paper "Hopfield Networks is All You Need" https://arxiv.org/abs/2008.02217. Hopfield networks learn via Hebbian learning.

      adamnemecekView on HNParent context

    • I only spent a few minutes skimming thr paper, but: 1) there are a lot of papers claiming to be the successor to the Transformer, and not all of them are cited; e.g., the MetaFormer is missing https://arxiv.org/abs/2111.11418. Another candidate that wasn't compares against (or…

      sfriedrView on HNParent context

    • > 1) there are a lot of papers claiming to be the successor to the Transformer, and not all of them are cited; e.g., the MetaFormer is missing https://arxiv.org/abs/2111.11418. Another candidate that wasn't compares against (or at least argued why it wouldn't make sense to…

      whimsicalismView on HNParent context

    • More accessible references: https://mcbal.github.io/post/an-energy-based-perspective-on-... (Modern continuous Hopfield networks section) https://arxiv.org/abs/2008.02217 Note that the connection to Hebbian learning hinges on the softmax function, in particular its exponential!

      macrolocalView on HNParent context

    • It's definitely in a gray area because the AI models are essentially compression engines that encode the code samples/data into the weights of the matrices that represent the ML model and then "uncompress" it to serve queries. I think it would be easy to argue that a compressed…

      flowtheoristView on HNParent context

    • > If I recall correctly, it was a Hopfield thingie, so I'm pretty off topic here. Actually, you’re spot on. Hopfield networks were once popular, and are now popular again: https://arxiv.org/abs/2008.02217 (Hopularity leads to popularity, as they say.) I wish there was some way…

      sillysaurusxView on HNParent context

    • Discovering Symbolic Models from Deep Learning with Inductive Biases [1] trains graph neural nets on astrophysical phenomena and then performs symbolic regression to generate algebraic formulae to elegantly model the phenomena in a classical physics framework. It's largely gone…

      KhoomeiKView on HNParent context

Submitted to Hacker News

Connected through shared HN threads, not inferred similarity or a recommendation.