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 train on to see if I can look up what state has the capital city of Olympia?
I might be conflating a whole bunch of steps that don't make sense in that initial linear example and adding complexity, and maybe trying to fit too much into the later examples too (I don't see the 'Query' matrix in the any of the parts of the post that get into self-attention, and maybe this post is just about "here's how memory works, not how LLMs work"
You always have an embedding matrix. The embedding matrix specifies which token vector is 'AL', which vector is 'AK', and so on, and which one is 'Cheyenne'. You could do it trivially and say that 'AL' is 1,0,0,0,0,..., 'AK' is 0,1,0,0,0,..., and 'Cheyenne' is ...,0,0,0,0,1, but that's still an embedding matrix - one which doesn't scale.
I didn't really follow the article to its conclusion. Surely the logical conclusion of "higher powers are better" is to take the limit as power goes to infinity - which is equivalent to just finding the most similar key and then returning the corresponding value. Why would you take a combination of all powers, when you know that higher powers work better?
Nothing in the article explained why we need "a memory" to work in this particular way that leads to it becoming a kind of transformer.
Talking about context tokens storing memories makes no sense. By definition, they are not memories, because they are all from the current prompt!
The whole blog post feels like a just-so story designed to make you think transformers were obvious.