Memory Retrieval in Transformers: Insights from The Encoding Specificity Principle

Viet Hung Dinh, Ming Ding, Youyang Qu, Kanchana Thilakarathna
1/28/2026
cs.LG
transformer-attention

No confident code implementation found for this paper.

Abstract

While explainable artificial intelligence (XAI) for large language models (LLMs) remains an evolving field with many unresolved questions, increasing regulatory pressures have spurred interest in its role in ensuring transparency, accountability, and privacy-preserving machine unlearning. Despite recent advances in XAI have provided some insights, the specific role of attention layers in transformer based LLMs remains underexplored.

Show full abstract

This study investigates the memory mechanisms instantiated by attention layers, drawing on prior research in psychology and computational psycholinguistics that links Transformer attention to cue based retrieval in human memory. In this view, queries encode the retrieval context, keys index candidate memory traces, attention weights quantify cue trace similarity, and values carry the encoded content, jointly enabling the construction of a context representation that precedes and facilitates memory retrieval. Guided by the Encoding Specificity Principle, we hypothesize that the cues used in the initial stage of retrieval are instantiated as keywords. We provide converging evidence for this keywords-as-cues hypothesis. In addition, we isolate neurons within attention layers whose activations selectively encode and facilitate the retrieval of context-defining keywords. Consequently, these keywords can be extracted from identified neurons and further contribute to downstream applications such as unlearning.

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{dinh2026memory,
  title  = {Memory Retrieval in Transformers: Insights from The Encoding Specificity Principle},
  author = {Viet Hung Dinh and Ming Ding and Youyang Qu and Kanchana Thilakarathna},
  year   = {2026},
  eprint = {2601.20282},
  archivePrefix = {arXiv},
  url    = {http://arxiv.org/abs/2601.20282v1}
}

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/2601.20282.svg)](https://codeofpaper.com/paper/2601.20282)

Discussion