Skip to main content
QUICK REVIEW

[Paper Review] Attention Approximates Sparse Distributed Memory

Trenton Bricken, Cengiz Pehlevan|arXiv (Cornell University)|Nov 10, 2021
Ferroelectric and Negative Capacitance DevicesEngineering64 references6 citations
TL;DR

This paper demonstrates that self-attention in Transformers mathematically approximates Kanerva's Sparse Distributed Memory (SDM), a biologically plausible associative memory model. Under specific data conditions—particularly in pre-trained GPT-2 models—attention's softmax operation closely mirrors SDM’s hypersphere intersection mechanism, providing a novel mechanistic and biological interpretation of attention as a form of distributed memory retrieval.

ABSTRACT

While Attention has come to be an important mechanism in deep learning, there remains limited intuition for why it works so well. Here, we show that Transformer Attention can be closely related under certain data conditions to Kanerva's Sparse Distributed Memory (SDM), a biologically plausible associative memory model. We confirm that these conditions are satisfied in pre-trained GPT2 Transformer models. We discuss the implications of the Attention-SDM map and provide new computational and biological interpretations of Attention.

Motivation & Objective

  • To establish a formal mathematical link between self-attention in Transformers and Kanerva’s Sparse Distributed Memory (SDM), a biologically plausible associative memory model.
  • To investigate whether the structural and functional properties of attention in pre-trained models like GPT-2 align with SDM’s principles under realistic data conditions.
  • To provide a new computational and biological interpretation of attention by framing it as a high-dimensional approximate retrieval mechanism akin to SDM.
  • To explore the implications of this mapping for understanding attention’s success, interpretability, and potential neural implementation in the brain.

Proposed method

  • Derive the mathematical equivalence between the softmax attention mechanism and SDM’s read operation, showing that the exponential-over-sum of exponentials in attention approximates the intersection of high-dimensional hyperspheres in SDM.
  • Use the Query-Key Normalized Transformer variant to empirically validate the SDM-attention correspondence in pre-trained GPT-2 models.
  • Simulate SDM with varying numbers of neurons and Hamming radii to test convergence and robustness under noise, comparing binary and continuous SDM variants.
  • Train projection matrices to improve critical distances in SDM for MNIST and CIFAR-10 datasets, assessing generalization and performance gains.
  • Analyze the role of pattern correlation and data complexity by comparing MNIST (low-complexity) and CIFAR-10 (high-complexity) datasets in SDM convergence behavior.
  • Use cosine similarity and Hamming distance metrics to evaluate retrieval performance and robustness to noise in both synthetic and real-world image datasets.

Experimental results

Research questions

  • RQ1To what extent does the attention mechanism in Transformers mathematically approximate the retrieval process in Sparse Distributed Memory?
  • RQ2Do the structural and statistical conditions required for the SDM-attention correspondence hold in real pre-trained Transformer models such as GPT-2?
  • RQ3How does the performance of SDM-based attention approximation vary with data complexity, as seen in MNIST versus CIFAR-10?
  • RQ4Can learned projection matrices improve SDM’s critical distance and robustness to noise, and does this generalize across datasets?
  • RQ5What are the biological and computational implications of interpreting attention as a form of distributed memory retrieval?

Key findings

  • The softmax attention mechanism closely approximates the hypersphere intersection operation in SDM, particularly when queries and keys are normalized, validating the mathematical link between attention and associative memory.
  • In pre-trained GPT-2 models, the conditions required for the SDM-attention correspondence are satisfied, confirming the theoretical mapping holds in practice.
  • MNIST data, being lower in complexity, show better convergence and higher robustness in SDM-based retrieval than CIFAR-10, which exhibits higher pattern correlation and overfitting.
  • Learning a projection matrix improves critical distances in SDM for both MNIST and CIFAR-10, but generalization to test sets is limited, indicating overfitting to training data.
  • Performance degrades with fewer neurons, and continuous SDM variants are more sensitive to finite neuron counts than binary SDM due to smaller circle intersections.
  • The SDM framework enables a deeper interpretation of the Transformer as a whole, suggesting that attention operates as a form of high-dimensional associative memory retrieval.

Read this paper

Open the full text in the Nubint reader and ask about any passage as you read.

Read this paper on Nubint

This review was generated by AI from the original paper. Please check the paper before citing it.