In-context denoising with one-layer transformers: connections between attention and associative memory retrieval

Matthew Smart, Alberto Bietti, Anirvan M. Sengupta
2/7/2025
cs.LGcond-mat.dis-nn

No confident code implementation found for this paper.

Abstract

We introduce in-context denoising, a task that refines the connection between attention-based architectures and dense associative memory (DAM) networks, also known as modern Hopfield networks. Using a Bayesian framework, we show theoretically and empirically that certain restricted denoising problems can be solved optimally even by a single-layer transformer. We demonstrate that a trained attention layer processes each denoising prompt by performing a single gradient descent update on a context-aware DAM energy landscape, where context tokens serve as associative memories and the query token acts as an initial state. This one-step update yields better solutions than exact retrieval of either a context token or a spurious local minimum, providing a concrete example of DAM networks extending beyond the standard retrieval paradigm. Overall, this work solidifies the link between associative memory and attention mechanisms first identified by Ramsauer et al., and demonstrates the relevance of associative memory models in the study of in-context learning.

View on arXivView PDF

Code Implementations

No confident code match yet

We couldn't find an author-owned or strongly-evidenced community implementation for this paper. Any repos shown below are weak matches — verify before relying on them.

No code implementations found yet.

Know of an implementation? Let us know in the comments below!

Similar Papers

Cite this paper

@article{smart2025incontext,
  title  = {In-context denoising with one-layer transformers: connections between attention and associative memory retrieval},
  author = {Matthew Smart and Alberto Bietti and Anirvan M. Sengupta},
  year   = {2025},
  eprint = {2502.05164},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2502.05164v2},
  journal = {ICML 2025 2025}
}

Add a badge to your README

Shows whether official code is linked for this paper.

Code of Paper badge
[![Code of Paper](https://codeofpaper.com/badge/2502.05164.svg)](https://codeofpaper.com/paper/2502.05164)

Discussion