# How Transformers Store a Million Memories Without Forgetting

Original title: You could have invented transformers from memory

> Hacker News story 50122878 · language: en · submitted 2026-10-16
> Web version: https://zeli.app/story/50122878
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 491 · by [speckx](<https://news.ycombinator.com/user?id=speckx>) · 💬 116
[original](<https://alexwang.ai/posts/associative-memory/>) · [HN discussion](<https://news.ycombinator.com/item?id=50122878>)

## Summary

Large language models recall facts from across the world, but how much can they actually remember? By viewing linear layers, MLPs, and self-attention as memory stores, we can derive their capacities. Starting with a simple outer-product store that holds about 64 memories, we improve to an optimal linear store with twice the capacity, then to MLPs and self-attention, which can store over a million memories with 64-dimensional keys.

## Key quote

> With 64-dimensional keys, that’s a jump from about 64 memories, to about 2,700, to over a million.

## HN discussion (116 comments)

### [ketothekingdom](<https://news.ycombinator.com/item?id=50126675>)

> Hey author here! I have a short summary here if people find it helpful: https://x.com/heyyalexwang/status/2111158818730397932?s=46

### [tooDumbForML_th](<https://news.ycombinator.com/item?id=50131683>)

> I think I can follow most of this, or probably will be able to do so with some help from Claude as we go through it with my questions, but I thought I'd ask humans first.
>
> I've watched most of Karpathy's videos but it's been a while so if I ask a dumb question it's because I'm at a very basic level from a while ago.
>
> To try to turn this into something concrete, let's say I want to store as facts the 50 state capitals. We'll do the most basic tokenization possible, so I have ['AL': 1, 'AK': 2, 'AZ': 3, ... 'WI': 49, 'WY': 50, 'Montgomery': 51, 'Juneau': 52, ... 'Cheyenne': 100]
>
> (Do I need an embedding matrix here? I feel like I need a 100x64 embedding matrix, one for each "token", even for those very first linear examples? Maybe I need two 50x64 matrices?)
>
> But then I'm learning randomly initialized V and K matrices by going through and dotting my 'AL' row by K and my 'Montgomery' row by V and then dotting them together, and going through all of the rest of the states similarly and then optimizing a loss function until I get a V and K that gives me good performance?
>
> I kind of wanted to go one step further and adding two more tokens, a 'StateHasCapital' token and a 'IsCapitalOf' token (say 101 and 102), and somehow use that to learn with compound keys ['StateHasCapital'+'AL': 'Montgomery'] - if I'm really learning facts, can I train on all 50 States->Capitals and maybe 25 Capitals->States and then as a test to see if I'm learning "facts", use the remaining capitals that I didn't t […]

### [gitowiec](<https://news.ycombinator.com/item?id=50132341>)

> So I saw this:
>
> "Here are the terms we’ll use throughout. A memory store is a function $f$ that holds $M$ memories, for $i = 1, \ldots, M$. A memory is one key-value pair: a key $k_i \in \reals^{d_k}$, used for lookup based on similarity, and a value $v_i \in \reals^{d_v}$, which is what we want to retrieve. To use $f$, we query it with an input $x$, and it recalls an output $f(x)$. A good memory store recalls $v_i$ when we query it with $k_i$, or with another vector similar to $k_i$. In the literature, a memory store that recalls by similarity is called an associative memory."
>
> And thought "I need to disable noscript because I get crappy page view". I disabled and it didn't help. It's a little sad that there is no explanation in the article what all that dollar signs mean. I feel excluded

### [yoz-y](<https://news.ycombinator.com/item?id=50125731>)

> Would be nice if articles defined the requirements to be a “you”.

### [crediblejhj](<https://news.ycombinator.com/item?id=50132228>)

> Great post. I'm a first-year CS student without much math knowledge (also poor English). I'd like to check whether I got the key idea right.
>
> There are layers and each layer stores key, value pairs (normalized in this article).
>
> If I query Q then Q will be compared with every stored key "Q@A + Q@B + Q@C + ... = value". 
>
> If A is the answer then Q@A will be 1, others will be interferences.
>
> D dimension only has d orthogonal directions, so if I store more keys than the dimension, I can't avoid remaining interferences.
>
> What we want is reducing them by going through function F.
>
> And this article introduces heuristic capacity results with different memory store functions (linear -> ReLU -> self attention).
>
> Is it roughly right?
>
> self attention is the best way to suppress interferences?

### [thoughtpeddler](<https://news.ycombinator.com/item?id=50133581>)

> So refreshing to see actual human dialog at the start of an AI post/paper/explainer, instead of having that visceral "I'm just reading AI slop" feeling. Even if it's totally unrelated, the little bit about playing the Dune board game made me much more engaged and willing to listen to what the rest of the content had to say.

### [netfortius](<https://news.ycombinator.com/item?id=50129055>)

> Funny how age shows up in some cases. For me the first thing that came to mind, when starting to read the article, was Ranulph Glanville's 1978: "What is memory that it can remember what it is?" (Progress in cybernetics and systems research - vol 4)

### [femto](<https://news.ycombinator.com/item?id=50126408>)

> "interference-to-signal ratio", "capacity", ...  These terms, and their context, are things a communications/electrical engineer would understand.  I encourage comms engineers to start learning how AI works under the hood.  Chances are, a lot of what you know about maximising channel capacity and throughput is applicable to AI (can be seen as a channel with memory?).

---

## Cite

- Page: https://zeli.app/story/50122878
- Date: 2026-10-16
- Source: alexwang.ai (https://alexwang.ai/posts/associative-memory/)
- Hacker News: https://news.ycombinator.com/item?id=50122878

## Other languages

- zh: https://zeli.app/zh/story/50122878 · markdown: https://zeli.app/zh/story/50122878.md
- ja: https://zeli.app/ja/story/50122878 · markdown: https://zeli.app/ja/story/50122878.md
- ko: https://zeli.app/ko/story/50122878 · markdown: https://zeli.app/ko/story/50122878.md
- de: https://zeli.app/de/story/50122878 · markdown: https://zeli.app/de/story/50122878.md
- es: https://zeli.app/es/story/50122878 · markdown: https://zeli.app/es/story/50122878.md
- ru: https://zeli.app/ru/story/50122878 · markdown: https://zeli.app/ru/story/50122878.md
