Rendered at 13:52:06 GMT+0000 (Coordinated Universal Time) with Cloudflare Workers.
freeone3000 13 minutes ago [-]
Obviously. The breakthrough was called “attention is all you need”! self-attention was being studied as an approach, like alternate schedulers, learning rates, various architecture connectivies, and so on. It turns out self-attention happened to include all of that; that’s the insight.
This is one of the most well written blog posts I've seen in a while. Thanks
ketothekingdom 1 days ago [-]
Thank you! It's been sitting in my head for so long. I'm glad I finally got to share it with people
3abiton 15 hours ago [-]
It was a great read. I've been recording a lot of the ideas I had, and especially after discussions with people. Sadly never found time to sit down, digest them and write them down yet. Your article is quite inspiring!
search_facility 3 hours ago [-]
Great explanation, thanks! Would be cool to see this for people BSky instead of ex-Twitter
nico 1 days ago [-]
Thank you for putting that excellent article together
The concepts of fidelity/recall and the images/animation at the top reminded me of this small playful project that touches upon these topics: https://nicobrenner.github.io/lossy-git/
ketothekingdom 1 days ago [-]
That's such a neat idea! Now I want to try it out too
plasticeagle 1 days ago [-]
I find some aspects of your writeup to be... quite annoying if I'm honest. The writing is good, but you fail to define several of your terms early on.
What is d_k - I assume it's the dimension of the k vector. Similarly, I assume d_v is the dimension of the v vector. What is the "i" suffix for here at this early stage? It doesn't need to be there, it's just confusing.
You say the keys are "used for lookup based on similarity". What does this mean? Similarity to what? The existing keys? Something else?
Your first example then introduces the identifier "M", which seems to be the number of memories. Again, this is not defined. It speaks again of similarities, and introduces "weights". But the matrix Mxd_k is a matrix made of all your keys, which aren't "weights" - or at least this term is new. The term "tokens" makes an appearance around this time also - something else that needs defining.
I think you need to go through the text of this article, with an eye to someone who is reading it for the first time. Define every term you use, remove unnecessary notation - and also perhaps explain at the start why one would be interested in a "memory store" of this nature.
There is a place for something that really explains what's going on here. I've yet to find it.
justinnk 1 days ago [-]
I found many of the things are clearly defined after the sentence „Here are the terms we’ll use throughout.“ right at the beginning (e.g. M, d_k, d_v).
newsy-combi 15 hours ago [-]
Where he does NOT state what d_k or R^d_k mean and there are countless other examples. I happen to know because of classes I took, but it's insane and obnoxious to assume that every reader did or went through any higher education at all. This is not high school math. It's not terribly complicated either, making this situation even more frustrating. The author could have spent just a little extra effort explaining these things to multiply his target audience - but he's either incapable to think from a different POV or pandering to his peers by not wasting time defining "the obvious". Pure academic blindness on full display here.
newsy-combi 15 hours ago [-]
Agreed 100%. Mathematicians SUCK at writing. No matter how hard they try, they'll gloss over important non-trivial definitions. And I think this author has been trying... but seems to at the same time ignore the negative feedback like yet another academia snob.
jkman 23 hours ago [-]
Instead of being condescending and annoying yourself, did you even try to reference other texts or resources to try to figure those things out? This is a freshman's complaint
superjan 8 hours ago [-]
I have only passing familiarity with how LLMs work and I found it enlighting. It makes me curious how recall quality degrades when quantization is applied. It looks like it’d gets worse quickly.
and others.
Hippocampal sparse coding/orthoganalization/pattern separation and completion/etc may be interesting search terms for you, if you are unfamiliar. If you do happen to be a hippocampal nut like I used to be during grad school, I salute you
_svm 1 days ago [-]
Really awesome write-up, and the kea is adorable!
aanet 20 hours ago [-]
Fantastic blog post.
Curious to hear more about the stack for your blog? Thanks
Shorel 19 hours ago [-]
No, after many years, I still hate Twitter/X.
Please write a proper Blog post.
Aurornis 8 hours ago [-]
> Please write a proper Blog post.
The Twitter thread is a summary of the blog post.
You can just read the blog post.
Shorel 1 hours ago [-]
Yeah, found it. I'm reading it now.
piterrro 8 hours ago [-]
After reading the article - no, I could not have invented transformers.
tooDumbForML_th 23 hours ago [-]
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"
pocksuppet 15 hours ago [-]
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.
SyzygyRhythm 6 hours ago [-]
> 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?
The article has the answer. The problem with that is that it is no longer differentiable.
The limit to infinite powers is to use the exponential function, which has weighted powers up to infinity. But you still need a kind of smoothing factor so that you don't end up just picking the closest one and losing differentiability, which they call beta and is picked based on how many memories you've stored.
zmmmmm 15 hours ago [-]
it's great to read a blog post like this.
I got to this part:
> If the keys are random unit vectors
And hesitated here. It seems then the article is predicated on us trying to store "white noise". However in the real world, data has much more structure than that. Every bit of structure is an opportunity to compress more. So all the conclusions here would be an upper/lower bound rather than a true estimate.
I assume this is accounted for by:
> In fact we haven’t actually considered the training data at all, which affects what actually is being represented in the keys and values
but it understates the point: much of the compressability as well as intelligence in the models come explicitly from the structure in the data. So it's very interesting you can derive MLP and transformer architecture even absent that. But the real leverage comes from the interaction of those things WITH structure in the data.
_kulang 13 hours ago [-]
I guess in embedding space it would be white noise? Perfect compression would result in something indistinguishable from white noise. Or at least this is my basic understanding, that degardless of data perfect compression looks like white noise
cowlevel 8 hours ago [-]
If keys and values were actually completely random, you'd use an associative array. The structure described does assume that nearby keys should yield nearby values, and in-between keys should yield interpolated values.
yoz-y 2 days ago [-]
Would be nice if articles defined the requirements to be a “you”.
penguin_booze 1 days ago [-]
The 'you' this article--and other articles like this--mentions, doesn't definitely include you, nor me, nor people like us.
Recently, Jensen Huang reportedly said he doesn't know where he lives (the address) with a straight face. This 'you' situation here is kind of like the Jensen situation: neither party understands what it's like to be the other party.
This is actually useful. I didn’t know that generic “you” meant “one”. I always interpreted it as “you the reader” and felt desperate once a week when reading articles like these.
wk_end 2 days ago [-]
As a native English speaker, I interpret it as “you the reader”. Or maybe I should say, I don’t intuit any material difference between “you the reader” and “any given reader” or “one”. I think your original comment is a good critique of the headline.
aatd86 1 days ago [-]
Doesn't have to be the reader, in general "you" would not know who it refers to specifically because it really mean anyone sharing the same experience. (see what I tried to do here?)
One would probably have encountered those constructions while reading though ;).
Never heard 'One' in colloquial English.
wongarsu 17 hours ago [-]
One could think that 'one' is a bit more like a general 'I' than a general 'you'
mdp2021 1 days ago [-]
It is an abstraction: "you" immediately, but not just you specifically, hence any abstract "objected" person (even the first person taken reflectively as a mental instance).
1 days ago [-]
satvikpendem 1 days ago [-]
Interesting. Are you a native English speaker? You in the general case is used quite a lot and I wouldn't be able to handle every single article or reference using that to mean to refer to me specifically.
fc417fc802 1 days ago [-]
But it does? It's generic, meaning you the reader are fully interchangeable with other possible subjects. At least that's the connotation it carries for me, and for what it's worth I'm a native speaker. If the reader (ie the target audience from the author's perspective) isn't interchangeable then I'd expect some other article to be used (ex they, the relevant professional, an interested party, etc).
satvikpendem 1 days ago [-]
I'm not sure it ever meant you the reader specifically, always have seen it meant to be generic or some hypothetical "one".
fc417fc802 19 hours ago [-]
I'm not exactly disagreeing with that statement though. I'm claiming that it additionally carries the implication of the reader being a member of that set while alternative turns of phrase don't.
Where it gets tricky is that the reader might not be part of the audience intended by the writer.
yoz-y 23 hours ago [-]
Am not. Recently I started reading more classic literature and realized just how much my comprehension is lacking, even after working in English exclusively for years.
coldtea 1 days ago [-]
>This is actually useful. I didn’t know that generic “you” meant “one”. I always interpreted it as “you the reader” and felt desperate once a week when reading articles like these.
It does mean "you, the reader" or "you, any random reader from my intended audience" (e.g. fellow PhDs) in articles like these.
Using it to mean "one" is a different use, in more formal talk.
NikolaNovak 2 days ago [-]
I love seeing helpful people create this moment :)
That said, the audience for this is still pretty niche.
(Even the audience for, say, 3b1b's explanation of what a transformer is, is niche.)
freebsd_lovefes 1 days ago [-]
[dead]
sam345 1 days ago [-]
My guess is comment meant that in the context of the headline "you" normally would refer to the average Joe on the street; in this case, it means the average Joe who has a PhD in math, CS, or whatever. It all certainly went over my head and probably 95% (or slightly less than that given this is HN) of the people who clicked the link. But I would take the headline as a compliment that I don't deserve.
layer8 23 hours ago [-]
I read it as “it’s possible for (some)one”, not as “it’s possible for (every)one”.
antonvs 24 hours ago [-]
They're asking what prerequisites would be needed to understand the article.
layer8 23 hours ago [-]
They seemed to be criticizing the use of “you” without qualification.
alex-moon 1 days ago [-]
"You could have invented..."
Oh you know there is gonna be maths in this one. (clicks link)
"Here are the terms we will use throughout: a 'memory store' is a function f..."
Yes. Ha ha! Yes!
monktastic1 1 days ago [-]
Were you hoping they would explain what is essentially a rather sophisticated math structure without using any... math?
newsy-combi 14 hours ago [-]
You can use math AND spend a few lines explaining the non-trivial syntax. It wouldn't be hard to do in this case and since the article is clearly meant for a large audience, it's a mistake from the author to gloss over various relevant definitions.
1 days ago [-]
mathisfun123 2 days ago [-]
why?
arcanemachiner 2 days ago [-]
Because I'm an idiot.
mllev15 1 days ago [-]
Yeah I was lost by the second tweet
femto 2 days ago [-]
"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?).
hasley 46 minutes ago [-]
Yep, I was delighted that an MMSE estimator came up so early!
BalistaCRATZ 1 days ago [-]
Definitely, not so surprising considering prediction and compression are two sides of the same coin
kridsdale1 1 days ago [-]
EE here. Indeed I asked Gemini Argon to translate this article in to DSP terms and it helped.
netfortius 1 days ago [-]
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)
Blahah 1 days ago [-]
Not sure if this was a joke or a timeline glitch, but the year was 1976 and the volume was 7 ;)
> Glanville, R. (1976). What is memory, that it can remember what it is? In R. Trappl et al. (Eds.), Recent Progress in Cybernetics & Systems Research, Volume 7 (Proceedings 3rd European Meeting on Cybernetics and Systems Research). Washington, DC: Hemisphere Press.
INSIDE EVERY WHITE BOX THERE ARE TWO BLACK BOXES TRYING TO GET OUT’
by Ranulph Glanville Portsmouth Polytechnic, England
The nature of the blackness of a black box (when an observer does not know what is going on inside the black box) and its whiteness (when an observer believes that he knows what is going on inside the black box) is considered and is applied to a description that is built by an observer of that black box. It is shown that while whiteness may be believed to have been reached within a system, such a system, nevertheless, remains black on the outside. This understanding is considered because it sheds light not only on black boxes and knowledge, but also on certain very basic cybernetic and broad psychological concepts.
KEYWORDS:conceptual system, individual, behavior, black box, white box, cybernetics, feedback, input, output, Object, self-reproduction.
the reference is:
Glanville, R. What is memory that it can remember
what it is? In R. Trappl, (Ed.), Progress in
and systems research (vol. 4).
Washington, D.C.: Hemisphere, 1978.(c)
[7] R. Glanville "What is Memory, that it can remember wheat it is?" in R. Trappl
(ed.) "Progress in Cybernetics and Systems Research Vol 4", Washington DC, Hemisphere, 1978
... very odd ...
skinfaxi 18 hours ago [-]
Given the down votes I suspect your joke flew over most heads.
sailfast 2 days ago [-]
This is a really interesting article! While I can’t profess to understand all the math it is a great way to demonstrate it.
I recall awhile back hearing someone ask whether intelligence was actually the same or similar to “compression” or storing all of this knowledge in weights - IE the ability to create something from reason or weights or relationships / connections. This article makes it even more interesting!
(For anyone not familiar with 3B1B, it's a YouTube channel that visualizes intriguing math concepts to explain them intuitively!)
lifeisloving 9 hours ago [-]
This is like the third time Ive had this video pushed in front of me today.
gitowiec 22 hours ago [-]
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
D-Machine 22 hours ago [-]
Thats MathJax, you need to allow JS to load from cdn.jsdelivr.net. If doing that doesn't cause the math to render, you likely have some other issue (perhaps a very old / strange browser, a caching issue, or some other kind of blocker additionally preventing the JS from loading).
rjbwork 22 hours ago [-]
You may have some other issue. That stuff renders as mathematical notation.
tourist2d 19 hours ago [-]
[dead]
dullcrisp 2 days ago [-]
For anyone here who understands this stuff, help me out because the article dropped me at the end when drawing the connection from memory to LLMs.
For an LLM, the keys are the tokens in your context, and the values are … what exactly?
wilkystyle 2 days ago [-]
In an attention layer, the query, key, and value are all computed at inference time using weight matrices that are determined as a result of the training. If X is the token representations entering the attention layer, then each of Q, K, and V would be determined by multiplying X by the corresponding learned weight matrix for queries, keys, and values:
Q = XW_q
K = XW_k
V = XW_v
From there, you can think of K and V like keys and values in a Python dictionary, and Q as the key you pass (e.g. d[Q] in Python to return some value V). The difference in an attention layer is that the query is matched to each key using a dot product, and rather than getting a single value back you get a weighted sum of values.
argee 1 days ago [-]
> The difference in an attention layer is that the query is matched to each key using a dot product, and rather than getting a single value back you get a weighted sum of values.
I understand you meant to compare it to dicts, but this is more like (the only?) similarity to outer product memory. Worth calling out since GP is confused about this connection specifically.
D-Machine 23 hours ago [-]
Yes, the main problem with this whole way of thinking about transformers and self-attention is that when you look at how they are actually implemented (i.e. what Q, K, and V are applied to at each layer, and consider the loss function during training), then the analogy to memory quickly starts to look tenuous and far-removed from what is actually happening.
Mainly, since self-attention layers operate on deeply-stacked representations of the outputs of previous layers, and since training has a loss function that doesn't make the updates work in the way the article says, the analogy to memory and lookup tables breaks down quite strongly. IMO, thinking of Q, K and V as memory or key-value lookup is thus not actually very helpful for understanding what these layers are really doing or why they work. Others agree (e.g. https://news.ycombinator.com/item?id=46535412), so don't feel bad if you think there is something hand-wavey about the lookup-table and memory explanations - it is only a weak analogy.
This has come up on HN before, and probably it is most accurate (but less intuitive, sadly) to see self-attention as a generalization of kernel methods (https://news.ycombinator.com/item?id=46535549). Broadly, self-attention is just one of the simplest ways to model similarities / correlations between all inputs (i.e. kernel method), but there are many, many other attention mechanisms. There are also many other ways to implement memory (e.g. LSTMs), and many other architectures that might in fact have even more memory capacity than transformers.
That being said, this is still truly an excellent article and it really provides some great intuitions for why transformers might work as well as they do. The softmax / exponentiation here functioning to increase memorization capacity by suppressing weak activations is super clear and interesting, and I really appreciated it. I suspect is not really be what is happening or is actually important about it, given other research (https://arxiv.org/html/2410.18613v1), and because much of what works in DL is usually more about matrix conditioning and keeping gradients well-behaved generally, rather than what the actual bare final math / weights in isolation from training would tend to suggest. But it does give a great intuition for why a trained transformer can have the capacity it does.
ketothekingdom 21 hours ago [-]
Definitely! It's more of an intuition but doesn't explain what vector gets put in the weights and the analysis doesn't involve the learning dynamics at all. I link some papers at the end that do think about how memory relates to the dataset. But the architecture having this storing+lookup property probably is important in helping transformers remember so much information.
asgraham 2 days ago [-]
To clarify slightly, K and V are used to construct the dictionary, and then Q is the lookup key D[Q] as described (with the lookup being based on similarity rather than exact hash as it would be in an actual dictionary).
D-Machine 21 hours ago [-]
See my comments and links below, you are not wrong, IMO this is not actually a great analogy for understanding LLMs (other than as an explanation for why a trained one can so efficiently compress such a large amount of information).
The animated bird, the kea is absolutely fabulous. I appreciate the effort and detail that went into this.
kator 1 days ago [-]
I was about to return here to say the same, I wonder how many people noticed it!
sugarkjube 1 days ago [-]
I didn't, so thanks for pointing out
crediblejhj 22 hours ago [-]
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?
D-Machine 21 hours ago [-]
Before getting too hung up on memory and seeing these as key value stores, or self-attention is suppression of interference, recognize that a lot of experts and people in these areas disagree with this analogy for fairly deep reasons (I link other resources and discussion here: https://news.ycombinator.com/item?id=50131741). It is still a useful analogy, but it is incomplete and weak in many ways when it comes to the actual details of training.
Also make sure to understand how self-attention layers are actually applied and the exact math and matrices involved. E.g. in PyTorch you are going to be doing sa(x, x, x), where x is the previous layer's output (essentially, embedded tokenization), and sa() does quite a few matrix multiplications. In cross-attention, you are doing sa(x, x, y), where y comes from a different part of the architecture.
Basically, read broadly here and don't get stuck on a single analogy / intuition for what these layers are doing. Focus on learning the actual math of the layer and the network first, and then look for analogies that help pump your intuition. But don't try too hard to force a single analogy onto the math.
Great article. My favorite fact about "transformers as a hopfield network" is that transformers are so good at memorizing that they only need one step to find a suitable memory as opposed to multiple steps for a vanilla hopfield network
t0rt01se 24 hours ago [-]
Wow!! I wish I had this perspective 13 years ago during those dull courses describing the mechanics of an MLP.
thoughtpeddler 20 hours ago [-]
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.
dingaling911 11 hours ago [-]
Beautiful human writing. Looking forward to reading this thoroughly.
1 days ago [-]
kooi 2 days ago [-]
Goodness, someone posts a great article which IMO accessible math, and people get upset.
If you think that is crazy, ohh boy, just wait til you see all the other papers underlying LLMs, AI, and optimization in general.
I appreciate this post because starting from linear algebra is the correct way to form an intuition of the higher dimensional semantic spaces we're dealing with.
D-Machine 22 hours ago [-]
Yeah, the notation and math concepts also all just first-year calculus (or analysis, more accurately) and stats (and the latter being only E for expectation). Literally just summation notation, blackboard bold R for the real numbers, double bars for norm / distance, and then max/min with subscript for the quantity being minimized.
Embarrassing to complain about notation so simple, and, frankly, if you can't understand math concepts and notation this basic, you simply can't meaningfully understand modern neural networks: without the math, all you are doing is substituting loose analogies and metaphor for understanding. This is clearly an article for people that want more than that.
newsy-combi 14 hours ago [-]
The notation itself sucks and anyone taking pride in the ability to parse it is suffering from Stockholm syndrome. It's also one of the most annoying things to look up because search engines ignore the symbols. AI can explain it based on a screenshot now, but then we might as well go to AI for the entire thing and I'm starting to lean in that direction just to spite authors like OP. You're also connecting the syntax to understanding of the concepts which is the cherry on top of the math snobbery in this thread. If the blog had pseudo-code instead of 18th century scribbles, the HN crowd would at least not openly admit to any parts they don't understand, because it's implied that you can code when you post here - not so much that you give a flying f--- about math or really anything theoretical.
D-Machine 11 hours ago [-]
> If the blog had pseudo-code instead of 18th century scribbles
E for expectation, blackboard bold, double-bar norms and indexed max/min are all early to mid 20th century notation, making them thoroughly modern. Only summation notation dates since the eighteenth century, and its relative stability over that period is in fact rather a strength and not a weakness. Summation notation is also nearly universal in any quantitative field, and far, far more concise than the equivalent looping C-style pseudocode or functional-style pseudocode.
> You're also connecting the syntax to understanding of the concepts which is the cherry on top of the math snobbery in this thread
Because that is in fact a big part of how it works. Good notation takes a lot of time and thought to develop, and the notation used in the post is far, far more concise and packs far more information into a tiny amount of space than pseudocode or other programming conventions. Much of math is abstraction (compacting complex ideas into specific symbols or concepts, and then coming up with simple rules to allow their manipulation), and is possible in large part only because of good notation like this. See some of Terry Tao's thoughts on the subject below.
The notation here is really also all first-year introductory notation, and incredibly simple. Most CS or computer engineering students should have seen it, and anyone that thinks they can learn anything non-trivial at all about neural networks by avoiding such basic notation is simply not a serious person at all.
EDIT: And it is a mistake to imply pseudocode is generally superior or easier to understand, because pseudocode is often too precise, and implies more structure and relations and implementation details than are actually needed or important. Meaning it actually often communicates the wrong thing compared to good notation.
This article does two things which make it unhelpful for me:
1. It uses math notation. This is a software development site, wouldn't this be much more clear to this audience written as psuedo code instead of a complex series of greek and latin letters?
2. It doesn't step through a concrete example. What is hollow R raised to the (M * d_v) ? Is it a number, a set, a list, a matrix?
To use an example I understand: RAG used to seem complicated to me when only math people were talking about it in math words. For example, let's take a line from wikipedia on embeddings:
> the representation is a real-valued vector that encodes the meaning of the word in such a way that the words that are closer in the vector space are expected to be similar in meaning
What made it clear was learning that generating an embedding is just a function(string) -> list[float], and RAG is just taking a list[float] for your prompt and finding other list[float] that are close to it in your dataset.
So what would make this article more clear, is step through a simplified example of putting a value into a memory store and querying that memory store, showing the actual data structures.
saghm 2 days ago [-]
> This is a software development site, wouldn't this be much more clear to this audience written as psuedo code instead of a complex series of greek and latin letters
At the risk of stating the obvious, this is a forum where people can post arbitrary links to other sites, some of which might have audiences that might not be "the exact set of people who read Hacker News". I'm not sure you'd be able to make a compelling argument that alexwang.ai is aimed at software developers and no one else.
craftkiller 2 days ago [-]
Yes, but you need to consider your audience when posting links to this site. For example, if I posted to HN a link to a really good cookie recipe, it wouldn't be a good fit for this site. The author did nothing wrong, but that doesn't make it a good submission to HN.
This article is a bit more of a grey area. It is on a subject that is deeply relevant to this site and I'm sure some HN readers will get value from it. My point is that an even better submission to HN would have been an article on the same topic but written for programmers rather than mathematicians.
saghm 2 days ago [-]
I'm surprised to this take, because I feel like I see math stuff posted here fairly often, and often with a large number of people commenting on it in substantive ways. Often times the math savvy crowd will even help explain stuff to people like me who are not particularly fluent in advanced math.
craftkiller 2 days ago [-]
> Often times the math savvy crowd will even help explain stuff to people
Perhaps, but HN apparently is pretty hostile to people explaining why something is not clear and how it could be more clear based on all the downvotes. I'll keep that in mind: "If you don't understand something, shut up!"
Nevermark 2 days ago [-]
Not understanding something isn’t the issue.
Also not an issue: the quality of the article.
Expect to be challenged by content here. Everybody is from time to time. Asking for a mathy analysis to drop the math, fundamentally misunderstands the value of the math.
craftkiller 2 days ago [-]
I'm not suggesting they drop any math. I'm suggesting they drop the math notation. As programmers, we spend 8+ hours per day reading code. Expressing the same math but in the syntax of code would make it accessible to more people on this site. It's like speaking in someone's native tongue instead of their 2nd language. I can read and mostly understand a news article written in French but it is going to take a lot of time and effort. If a news article is written in English I could read it quickly and easily. Both languages are presenting the same information, it is just a matter of how it is presented.
HN is a site for programmers (or specifically "hackers"). Posting an article to a site for programmers in math notation is like posting a French article to an English message board. Some people will be able to read it with varying levels of difficulty, but wouldn't it be better to post an English version of the same information so everyone can read it easily?
Nevermark 1 days ago [-]
The article was elevated as relevant by HN readers, not forced on them.
As an isolated wish, your ideas might be reasonable.
But framing them as necessary HN values, as a critique, as ideas others should conform to, you are not being sensible or reasonable.
pestatije 2 days ago [-]
the poster and the writer are different entities... only the writer influences the poster, not the other way around...now the poster saw value for HN readers and thats why it ended here.. with this logic your position doesn't make sense
mdp2021 1 days ago [-]
"hackers" = "resourceful".
> If you don't understand something
Ask, but if you advance weak ideas be prepared to be hit - and be glad about it, you are advised to revise the weak ideas.
SyneRyder 2 days ago [-]
I think people likely hit an early "break" and "goto xkcd 386" when they saw "this is a software development site" in your comment, without reading the rest of your comment.
Clear explanations are a good thing, but different explanations help people in different ways. Your explanation seems helpful to me, and reminds me of Ben Affleck's explanation in the GQ interview. But Ben Affleck connected it directly to arrays of RGB pixel data, which clicks more with me personally, but probably wouldn't with everyone. It certainly didn't make things any clearer to the interviewer.
saghm 2 days ago [-]
There's a certain irony in praising clear explanations as a defense of an explanation that needlessly veered into value judgment
SyneRyder 2 days ago [-]
Well, sure... but it seemed to me that they didn't realize they're posting on Startup News, a news site for founders of startups:
"... the thing that makes hackers such good startup founders is that they care about more than business. They have intellectual curiosity driving them as well as the desire to make money. So the way to make a news site for startup founders is to make it be about more than just startups. ... If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity."
My thought was to show some grace, considering that not everyone's been around here for 20 years or knows that "hacker" doesn't apply only to computer programmers. That was my thinking anyway.
craftkiller 2 days ago [-]
I had no idea it used to be called Startup News! When I joined in 2012 this site was "essentially /r/programming but for more serious programmers and without jokes"
saghm 2 days ago [-]
I didn't downvote, and I don't think there's a problem with explaining why something isn't clear. There's a difference between expressing criticism and saying that something doesn't belong here, and which I'd argue is evidenced from the fact that the reaction to my comment critiquing yours doesn't seem to have ruffled many feathers (at least not yet!)
craftkiller 2 days ago [-]
Not sure I'm understanding you correctly, but it sounds like you're saying that I said that this post doesn't belong here? I said no such thing. I said this article is "unhelpful for *me*" but "deeply relevant to this site" and "some HN readers will get value from it".
Imagine a nursing home that serves steak every day. One resident says "this food isn't helpful to me because I no longer have teeth to chew it. Wouldn't this be better for everyone if we had soup?". They're not suggesting outlawing steak, after all some people will get value from it. They suggesting a way to better serve the entire population of the nursing home.
mdp2021 1 days ago [-]
> software development site ... you need to consider your audience when posting links to this site ... a link to a really good cookie recipe ... for programmers
That is really your interpretation only - and it directly clashes with the explicitly intended: "intellectually curious" (which will be, if not polymaths, at least open).
Of course an intellectual curiosity space hosted around the world of startup enterprises will attract membership of people with experience in engineering.
If you check the submissions, it should be immediately evident that there is no closure.
ergonaught 2 days ago [-]
I see plenty of things shared here that don’t fit your preconception of what is a fit for a site you don’t operate.
fc417fc802 1 days ago [-]
> For example, if I posted to HN a link to a really good cookie recipe, it wouldn't be a good fit for this site.
Going to have to disagree with you here. That would very much depend on the particulars of and circumstances surrounding the recipe. This is a site for anything that would interest the typical hacker (whatever that actually is) after all.
Shorel 18 hours ago [-]
I'm frustrated I can't downvote you more than once. You are the example of anti-intellectualism that is allowing the world being controlled by dumbed down mass media.
If I consider the hacker news audience as "smart people" and/or "people with curiosity about science and technology", a couple of equations are exactly what should appear in every single post.
soulofmischief 2 days ago [-]
Have you considered that you are simply not the audience that Alex or speckx had in mind? It would be healthy to recognize this simple fact and move on while letting the intended audience (Hi! Longtime HN member for over a decade!) enjoy it.
craftkiller 1 days ago [-]
"If you don't understand something, shut up!"
Got it. Stay classy HN.
soulofmischief 1 days ago [-]
Please do not put words in my mouth. Did I say to shut up? I said to move on, since this is clearly stressing you out, and additionally because you are ostracizing other members of the community who are just fine with this content. This isn't Harrison Bergeron, the community as a whole does not have to cater to your own intellectual shortcomings. There is no need for sarcasm or snark.
craftkiller 1 days ago [-]
> I said to move on
They're the same thing on an internet forum. There is no space to move through, so while in the physical world "move on" is different from "shut up", on an online forum they both mean exactly the same thing: "don't say anything".
And yes, this is stressing me out. I took the time and effort to think about and explain how this post could reach a wider audience on hackernews, citing an example from my own learning experience, and nearly everyone has attacked me for it. The original article was clearly meant to explain/educate. You'd think "here's how you can do that for more people" would be useful feedback.
soulofmischief 1 days ago [-]
You are welcome to shout at the clouds all day. I'm not asking you to shut up, I'm telling you I think it's worth moving on, internally. I'm trying to explain why you would be better served by accepting that you're not the only member of the community. It's easy to forget that other people don't think the same way you do; Bram Moolenaar himself chastised me over this once and I took it to heart.
The thing is, there are fundamental issues with your post. You said, "if I posted to HN a link to a really good cookie recipe, it wouldn't be a good fit for this site", which is wrong; Hackers might be interested in cookies. The site guidelines state,
On-Topic: Anything that good hackers would find interesting. That includes more than hacking and startups. If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity.
Off-Topic: Most stories about politics, or crime, or sports, or celebrities, unless they're evidence of some interesting new phenomenon. If they'd cover it on TV news, it's probably off-topic.
If that cookie recipe is really good, I'm curious! Cooking is something many hackers love to do.
You also criticized the article for... using math notation... and wrongly assumed that other engineers on this site who also are interested in mathematics, like Alex Wang, would rather dispense with the compact notation and instead deliver pseudocode. This is entirely the author's prerogative, just as it's your prerogative to skip it and move on, or even criticize it. But you cannot get upset when your criticism is then itself critically evaluated, or claim others are being hostile for examining the content of your comment just as you did the content of the article. I know you weren't being hostile in your criticism, and I'm not aiming to be hostile in mine.
> You'd think "here's how you can do that for more people" would be useful feedback.
Sure! What this mostly comes down to is your misunderstanding of the breadth of our community, and the site guidelines. You truly did mean well, and I also mean well here, even if I am being blunt. The rest of your comment was fine and I don't take issue with the general sentiment.
fc417fc802 1 days ago [-]
> You also criticized the article for.
> What this mostly comes down to is your misunderstanding of the breadth of our community
Actually I think it's the people responding to him that aren't being sufficiently careful to read what he actually wrote and to understand the message he was attempting to convey. Granted he could have done a better job communicating (case in point, this very conversation) but that's often going to be the case.
It seems like people are interpreting it in a hostile manner when from my perspective the core of it is both actionable and reasonable feedback for anyone attempting to explain a technical topic. Both of the original points (using mathematical notation and failing to step through concrete examples) are each things that will alienate a decent chunk of any potential audience. In fact the former is one of my primary complaints about wikipedia articles on math adjacent topics.
mrandish 1 days ago [-]
FWIW, I found the idea of interference-to-signal ratio as a way to think about memory capacity to be intuitive and was really interested in getting a better sense of how models increase capacity, until it hit the first math notation formula. My disconnect was based on the approachable tone of the intro, from which I assumed it would be a more generally accessible article.
To be clear, I have no problem with math people conveying math stuff with math notation but it seemed like the type of article which, even if it will get into notation, first at least explains "the main idea of it" without notation, then expands with notation as necessary when fleshing details or implementation.
aDyslecticCrow 2 days ago [-]
I guess you're not the target audience for this article then.
This is pretty approachable maths, and explain really well. I've seen far worse in programming language theory papers, which would qualify as "software development" in my mind. There are plenty of users of this forum that would find this paper useful and interesting, with sufficient math background to read it to boot.
newsy-combi 14 hours ago [-]
>this paper
Nice Freudian slip. It's a blog post, not a paper. But it sure reads like a paper with its priority for reading speed over explanations that peers would find unnecessary. Except it's not written for peers. It adresses "You" the average reader. Unless "You" should mean "You, the person who took, cared about, and remembered various math classes in college," the article is good old clickbait.
plaguuuuuu 1 days ago [-]
Wait, you're saying that mathematics isn't useful to software engineers?
You should give it a go.
craftkiller 1 days ago [-]
That is not an accurate read of my post. My post was about two things:
1. The notation used
2. The lack of concrete examples
I'm not saying they should remove any of the content, just put it in a form more accessible to us. For example, I can read and mostly understand a news article in French, but it will take a lot of time and effort. If it was written in English, it would be easy for me to read. The two news articles have exactly the same content, one is just written in a form easier for me to understand.
Well putting this article in math notation without defining any of the data structures behind it, that's not like putting the article in French, it's like putting the article in Japanese. I can't understand any of it. Some Japanese speakers on this site are saying "I don't understand the problem, just learn Japanese." which is pretty much the least constructive comment they could make.
ricardobeat 1 days ago [-]
HN is not a place where people post content made for HN (or at least it didn't use to be). Relevant links are posted. They get upvoted if they are interesting. Articles from many other fields like physics, cryptography, hardware design, crocheting, nuclear safety, farming, etc, are posted very often and can still be an interesting read for people not familiar with the subject matter. Finally, engineers have a wide variety of backgrounds, and I bet a good chunk can read math notation or drive a soil compactor - there is no "us".
They might not all be a good read for you in particular; the choice is yours to make an effort, or "move on" as someone else suggested. You're being downvoted because you are making it sound like you are entitled to an easier explanation, an hypothetical version of the article that caters to you in particular. There are many ways you could have framed your comment differently without that baggage.
bluegatty 2 days ago [-]
Those are valid bits of feedback to make an articel more accessible, but it's totally fine and apprpriate as it is
2 days ago [-]
planckscnst 1 days ago [-]
What made it not useful to you likely makes it much more useful for me.
Fortunately, LLMs can work wonders in adapting content to be more accessible to a wide variety of audiences. Just give it a link and feed your exact post to it. It will be able to translate it into pseudocode and provide examples.
newsy-combi 14 hours ago [-]
It will also be capable to write the whole thing better. "Please pivot to LLM to make my posts readable" is not a winning strategy for bloggers.
>It's easy to forget that the average person probably only knows the formulas for Olivine and one or two Feldspars
That being said the llm is indeed the universal translator — the babelfish supreme — and is excellent at translating whatever you want into pseudocode in your language of choice.
msisk6 2 days ago [-]
Well, you could tell your AI of choice to read the article and explain the math. I did that with ChatGPT and it helpfully translated a lot of it into Python for me.
CamperBob2 2 days ago [-]
Send the link to Claude or your favorite alternative, and cut-and-paste your comment into the box, and you'll get exactly what you want.
spying_lg_tv 2 days ago [-]
Time to stop being a script kiddie and learn basic math.
The concepts of fidelity/recall and the images/animation at the top reminded me of this small playful project that touches upon these topics: https://nicobrenner.github.io/lossy-git/
What is d_k - I assume it's the dimension of the k vector. Similarly, I assume d_v is the dimension of the v vector. What is the "i" suffix for here at this early stage? It doesn't need to be there, it's just confusing.
You say the keys are "used for lookup based on similarity". What does this mean? Similarity to what? The existing keys? Something else?
Your first example then introduces the identifier "M", which seems to be the number of memories. Again, this is not defined. It speaks again of similarities, and introduces "weights". But the matrix Mxd_k is a matrix made of all your keys, which aren't "weights" - or at least this term is new. The term "tokens" makes an appearance around this time also - something else that needs defining.
I think you need to go through the text of this article, with an eye to someone who is reading it for the first time. Define every term you use, remove unnecessary notation - and also perhaps explain at the start why one would be interested in a "memory store" of this nature.
There is a place for something that really explains what's going on here. I've yet to find it.
and others. Hippocampal sparse coding/orthoganalization/pattern separation and completion/etc may be interesting search terms for you, if you are unfamiliar. If you do happen to be a hippocampal nut like I used to be during grad school, I salute you
Curious to hear more about the stack for your blog? Thanks
Please write a proper Blog post.
The Twitter thread is a summary of the blog post.
You can just read the blog post.
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"
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.
The article has the answer. The problem with that is that it is no longer differentiable.
The limit to infinite powers is to use the exponential function, which has weighted powers up to infinity. But you still need a kind of smoothing factor so that you don't end up just picking the closest one and losing differentiability, which they call beta and is picked based on how many memories you've stored.
I got to this part:
> If the keys are random unit vectors
And hesitated here. It seems then the article is predicated on us trying to store "white noise". However in the real world, data has much more structure than that. Every bit of structure is an opportunity to compress more. So all the conclusions here would be an upper/lower bound rather than a true estimate.
I assume this is accounted for by:
> In fact we haven’t actually considered the training data at all, which affects what actually is being represented in the keys and values
but it understates the point: much of the compressability as well as intelligence in the models come explicitly from the structure in the data. So it's very interesting you can derive MLP and transformer architecture even absent that. But the real leverage comes from the interaction of those things WITH structure in the data.
Recently, Jensen Huang reportedly said he doesn't know where he lives (the address) with a straight face. This 'you' situation here is kind of like the Jensen situation: neither party understands what it's like to be the other party.
Where it gets tricky is that the reader might not be part of the audience intended by the writer.
It does mean "you, the reader" or "you, any random reader from my intended audience" (e.g. fellow PhDs) in articles like these.
Using it to mean "one" is a different use, in more formal talk.
https://xkcd.com/1053/
(Even the audience for, say, 3b1b's explanation of what a transformer is, is niche.)
Oh you know there is gonna be maths in this one. (clicks link)
"Here are the terms we will use throughout: a 'memory store' is a function f..."
Yes. Ha ha! Yes!
> Glanville, R. (1976). What is memory, that it can remember what it is? In R. Trappl et al. (Eds.), Recent Progress in Cybernetics & Systems Research, Volume 7 (Proceedings 3rd European Meeting on Cybernetics and Systems Research). Washington, DC: Hemisphere Press.
See https://ranulphglanville.org.za/publications/
INSIDE EVERY WHITE BOX THERE ARE TWO BLACK BOXES TRYING TO GET OUT’ by Ranulph Glanville Portsmouth Polytechnic, England
The nature of the blackness of a black box (when an observer does not know what is going on inside the black box) and its whiteness (when an observer believes that he knows what is going on inside the black box) is considered and is applied to a description that is built by an observer of that black box. It is shown that while whiteness may be believed to have been reached within a system, such a system, nevertheless, remains black on the outside. This understanding is considered because it sheds light not only on black boxes and knowledge, but also on certain very basic cybernetic and broad psychological concepts.
KEYWORDS:conceptual system, individual, behavior, black box, white box, cybernetics, feedback, input, output, Object, self-reproduction.
the reference is:
Glanville, R. What is memory that it can remember what it is? In R. Trappl, (Ed.), Progress in and systems research (vol. 4). Washington, D.C.: Hemisphere, 1978.(c)
**
Also here: https://constructivist.info/radical/papers/glanville/glanvil...
[7] R. Glanville "What is Memory, that it can remember wheat it is?" in R. Trappl (ed.) "Progress in Cybernetics and Systems Research Vol 4", Washington DC, Hemisphere, 1978
... very odd ...
I recall awhile back hearing someone ask whether intelligence was actually the same or similar to “compression” or storing all of this knowledge in weights - IE the ability to create something from reason or weights or relationships / connections. This article makes it even more interesting!
(For anyone not familiar with 3B1B, it's a YouTube channel that visualizes intriguing math concepts to explain them intuitively!)
"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
For an LLM, the keys are the tokens in your context, and the values are … what exactly?
Q = XW_q
K = XW_k
V = XW_v
From there, you can think of K and V like keys and values in a Python dictionary, and Q as the key you pass (e.g. d[Q] in Python to return some value V). The difference in an attention layer is that the query is matched to each key using a dot product, and rather than getting a single value back you get a weighted sum of values.
I understand you meant to compare it to dicts, but this is more like (the only?) similarity to outer product memory. Worth calling out since GP is confused about this connection specifically.
Mainly, since self-attention layers operate on deeply-stacked representations of the outputs of previous layers, and since training has a loss function that doesn't make the updates work in the way the article says, the analogy to memory and lookup tables breaks down quite strongly. IMO, thinking of Q, K and V as memory or key-value lookup is thus not actually very helpful for understanding what these layers are really doing or why they work. Others agree (e.g. https://news.ycombinator.com/item?id=46535412), so don't feel bad if you think there is something hand-wavey about the lookup-table and memory explanations - it is only a weak analogy.
This has come up on HN before, and probably it is most accurate (but less intuitive, sadly) to see self-attention as a generalization of kernel methods (https://news.ycombinator.com/item?id=46535549). Broadly, self-attention is just one of the simplest ways to model similarities / correlations between all inputs (i.e. kernel method), but there are many, many other attention mechanisms. There are also many other ways to implement memory (e.g. LSTMs), and many other architectures that might in fact have even more memory capacity than transformers.
That being said, this is still truly an excellent article and it really provides some great intuitions for why transformers might work as well as they do. The softmax / exponentiation here functioning to increase memorization capacity by suppressing weak activations is super clear and interesting, and I really appreciated it. I suspect is not really be what is happening or is actually important about it, given other research (https://arxiv.org/html/2410.18613v1), and because much of what works in DL is usually more about matrix conditioning and keeping gradients well-behaved generally, rather than what the actual bare final math / weights in isolation from training would tend to suggest. But it does give a great intuition for why a trained transformer can have the capacity it does.
https://news.ycombinator.com/item?id=50131741
self attention is the best way to suppress interferences?
Also make sure to understand how self-attention layers are actually applied and the exact math and matrices involved. E.g. in PyTorch you are going to be doing sa(x, x, x), where x is the previous layer's output (essentially, embedded tokenization), and sa() does quite a few matrix multiplications. In cross-attention, you are doing sa(x, x, y), where y comes from a different part of the architecture.
Basically, read broadly here and don't get stuck on a single analogy / intuition for what these layers are doing. Focus on learning the actual math of the layer and the network first, and then look for analogies that help pump your intuition. But don't try too hard to force a single analogy onto the math.
EDIT: Also modern AI can provide useful insight into posts like this, I highly suggest using them when learning these things. E.g. https://chatgpt.com/share/6ad3aa3d-d110-83ea-a8c5-8653b34743...
If you think that is crazy, ohh boy, just wait til you see all the other papers underlying LLMs, AI, and optimization in general.
I appreciate this post because starting from linear algebra is the correct way to form an intuition of the higher dimensional semantic spaces we're dealing with.
Embarrassing to complain about notation so simple, and, frankly, if you can't understand math concepts and notation this basic, you simply can't meaningfully understand modern neural networks: without the math, all you are doing is substituting loose analogies and metaphor for understanding. This is clearly an article for people that want more than that.
E for expectation, blackboard bold, double-bar norms and indexed max/min are all early to mid 20th century notation, making them thoroughly modern. Only summation notation dates since the eighteenth century, and its relative stability over that period is in fact rather a strength and not a weakness. Summation notation is also nearly universal in any quantitative field, and far, far more concise than the equivalent looping C-style pseudocode or functional-style pseudocode.
> You're also connecting the syntax to understanding of the concepts which is the cherry on top of the math snobbery in this thread
Because that is in fact a big part of how it works. Good notation takes a lot of time and thought to develop, and the notation used in the post is far, far more concise and packs far more information into a tiny amount of space than pseudocode or other programming conventions. Much of math is abstraction (compacting complex ideas into specific symbols or concepts, and then coming up with simple rules to allow their manipulation), and is possible in large part only because of good notation like this. See some of Terry Tao's thoughts on the subject below.
The notation here is really also all first-year introductory notation, and incredibly simple. Most CS or computer engineering students should have seen it, and anyone that thinks they can learn anything non-trivial at all about neural networks by avoiding such basic notation is simply not a serious person at all.
EDIT: And it is a mistake to imply pseudocode is generally superior or easier to understand, because pseudocode is often too precise, and implies more structure and relations and implementation details than are actually needed or important. Meaning it actually often communicates the wrong thing compared to good notation.
https://terrytao.wordpress.com/advice-on-writing-papers/use-...
https://mathoverflow.net/questions/366070/what-are-the-benef...
NNCP: Lossless Data Compression with Neural Networks (2019)
https://news.ycombinator.com/item?id=27244004
https://bellard.org/nncp/
[1] https://en.wikipedia.org/wiki/Memristor
1. It uses math notation. This is a software development site, wouldn't this be much more clear to this audience written as psuedo code instead of a complex series of greek and latin letters?
2. It doesn't step through a concrete example. What is hollow R raised to the (M * d_v) ? Is it a number, a set, a list, a matrix?
To use an example I understand: RAG used to seem complicated to me when only math people were talking about it in math words. For example, let's take a line from wikipedia on embeddings:
> the representation is a real-valued vector that encodes the meaning of the word in such a way that the words that are closer in the vector space are expected to be similar in meaning
What made it clear was learning that generating an embedding is just a function(string) -> list[float], and RAG is just taking a list[float] for your prompt and finding other list[float] that are close to it in your dataset.
So what would make this article more clear, is step through a simplified example of putting a value into a memory store and querying that memory store, showing the actual data structures.
At the risk of stating the obvious, this is a forum where people can post arbitrary links to other sites, some of which might have audiences that might not be "the exact set of people who read Hacker News". I'm not sure you'd be able to make a compelling argument that alexwang.ai is aimed at software developers and no one else.
This article is a bit more of a grey area. It is on a subject that is deeply relevant to this site and I'm sure some HN readers will get value from it. My point is that an even better submission to HN would have been an article on the same topic but written for programmers rather than mathematicians.
Perhaps, but HN apparently is pretty hostile to people explaining why something is not clear and how it could be more clear based on all the downvotes. I'll keep that in mind: "If you don't understand something, shut up!"
Also not an issue: the quality of the article.
Expect to be challenged by content here. Everybody is from time to time. Asking for a mathy analysis to drop the math, fundamentally misunderstands the value of the math.
HN is a site for programmers (or specifically "hackers"). Posting an article to a site for programmers in math notation is like posting a French article to an English message board. Some people will be able to read it with varying levels of difficulty, but wouldn't it be better to post an English version of the same information so everyone can read it easily?
As an isolated wish, your ideas might be reasonable.
But framing them as necessary HN values, as a critique, as ideas others should conform to, you are not being sensible or reasonable.
> If you don't understand something
Ask, but if you advance weak ideas be prepared to be hit - and be glad about it, you are advised to revise the weak ideas.
Clear explanations are a good thing, but different explanations help people in different ways. Your explanation seems helpful to me, and reminds me of Ben Affleck's explanation in the GQ interview. But Ben Affleck connected it directly to arrays of RGB pixel data, which clicks more with me personally, but probably wouldn't with everyone. It certainly didn't make things any clearer to the interviewer.
https://news.ycombinator.com/hackernews.html
"... the thing that makes hackers such good startup founders is that they care about more than business. They have intellectual curiosity driving them as well as the desire to make money. So the way to make a news site for startup founders is to make it be about more than just startups. ... If you had to reduce it to a sentence, the answer might be: anything that gratifies one's intellectual curiosity."
My thought was to show some grace, considering that not everyone's been around here for 20 years or knows that "hacker" doesn't apply only to computer programmers. That was my thinking anyway.
Imagine a nursing home that serves steak every day. One resident says "this food isn't helpful to me because I no longer have teeth to chew it. Wouldn't this be better for everyone if we had soup?". They're not suggesting outlawing steak, after all some people will get value from it. They suggesting a way to better serve the entire population of the nursing home.
That is really your interpretation only - and it directly clashes with the explicitly intended: "intellectually curious" (which will be, if not polymaths, at least open).
Of course an intellectual curiosity space hosted around the world of startup enterprises will attract membership of people with experience in engineering.
If you check the submissions, it should be immediately evident that there is no closure.
Going to have to disagree with you here. That would very much depend on the particulars of and circumstances surrounding the recipe. This is a site for anything that would interest the typical hacker (whatever that actually is) after all.
If I consider the hacker news audience as "smart people" and/or "people with curiosity about science and technology", a couple of equations are exactly what should appear in every single post.
Got it. Stay classy HN.
They're the same thing on an internet forum. There is no space to move through, so while in the physical world "move on" is different from "shut up", on an online forum they both mean exactly the same thing: "don't say anything".
And yes, this is stressing me out. I took the time and effort to think about and explain how this post could reach a wider audience on hackernews, citing an example from my own learning experience, and nearly everyone has attacked me for it. The original article was clearly meant to explain/educate. You'd think "here's how you can do that for more people" would be useful feedback.
The thing is, there are fundamental issues with your post. You said, "if I posted to HN a link to a really good cookie recipe, it wouldn't be a good fit for this site", which is wrong; Hackers might be interested in cookies. The site guidelines state,
If that cookie recipe is really good, I'm curious! Cooking is something many hackers love to do.You also criticized the article for... using math notation... and wrongly assumed that other engineers on this site who also are interested in mathematics, like Alex Wang, would rather dispense with the compact notation and instead deliver pseudocode. This is entirely the author's prerogative, just as it's your prerogative to skip it and move on, or even criticize it. But you cannot get upset when your criticism is then itself critically evaluated, or claim others are being hostile for examining the content of your comment just as you did the content of the article. I know you weren't being hostile in your criticism, and I'm not aiming to be hostile in mine.
> You'd think "here's how you can do that for more people" would be useful feedback.
Sure! What this mostly comes down to is your misunderstanding of the breadth of our community, and the site guidelines. You truly did mean well, and I also mean well here, even if I am being blunt. The rest of your comment was fine and I don't take issue with the general sentiment.
> What this mostly comes down to is your misunderstanding of the breadth of our community
Actually I think it's the people responding to him that aren't being sufficiently careful to read what he actually wrote and to understand the message he was attempting to convey. Granted he could have done a better job communicating (case in point, this very conversation) but that's often going to be the case.
It seems like people are interpreting it in a hostile manner when from my perspective the core of it is both actionable and reasonable feedback for anyone attempting to explain a technical topic. Both of the original points (using mathematical notation and failing to step through concrete examples) are each things that will alienate a decent chunk of any potential audience. In fact the former is one of my primary complaints about wikipedia articles on math adjacent topics.
To be clear, I have no problem with math people conveying math stuff with math notation but it seemed like the type of article which, even if it will get into notation, first at least explains "the main idea of it" without notation, then expands with notation as necessary when fleshing details or implementation.
This is pretty approachable maths, and explain really well. I've seen far worse in programming language theory papers, which would qualify as "software development" in my mind. There are plenty of users of this forum that would find this paper useful and interesting, with sufficient math background to read it to boot.
Nice Freudian slip. It's a blog post, not a paper. But it sure reads like a paper with its priority for reading speed over explanations that peers would find unnecessary. Except it's not written for peers. It adresses "You" the average reader. Unless "You" should mean "You, the person who took, cared about, and remembered various math classes in college," the article is good old clickbait.
You should give it a go.
Well putting this article in math notation without defining any of the data structures behind it, that's not like putting the article in French, it's like putting the article in Japanese. I can't understand any of it. Some Japanese speakers on this site are saying "I don't understand the problem, just learn Japanese." which is pretty much the least constructive comment they could make.
They might not all be a good read for you in particular; the choice is yours to make an effort, or "move on" as someone else suggested. You're being downvoted because you are making it sound like you are entitled to an easier explanation, an hypothetical version of the article that caters to you in particular. There are many ways you could have framed your comment differently without that baggage.
Fortunately, LLMs can work wonders in adapting content to be more accessible to a wide variety of audiences. Just give it a link and feed your exact post to it. It will be able to translate it into pseudocode and provide examples.
https://xkcd.com/2501/
>It's easy to forget that the average person probably only knows the formulas for Olivine and one or two Feldspars
That being said the llm is indeed the universal translator — the babelfish supreme — and is excellent at translating whatever you want into pseudocode in your language of choice.