News for hackers. Stuff that matters.
Re:Embeddings: What they are and why they matter by toxik on Wednesday October 25, 2023 @03:43AM (#38010289)
I disagree that your version is more readable. If you don’t know linear algebra, the code is inscrutable, and if you do, dot(x,y)/norm(x)/norm(y) is about as close to the math as you can get.
Re:Embeddings: What they are and why they matter by drcongo on Wednesday October 25, 2023 @05:23AM (#38010890)
My linear algebra is terrible, but I understand what's happening in Simon's example pretty well.
Re:Embeddings: What they are and why they matter by toxik on Wednesday October 25, 2023 @08:24AM (#38012033)
I sincerely doubt you possess any kind of geometric understanding of what is going on in that code just from reading the first principles variant of cosine similarity.
Re:Embeddings: What they are and why they matter by forgotpwd16 on Wednesday October 25, 2023 @06:53AM (#38011431)
>If you don’t know linear algebra, the code is inscrutable

Whether you do or don't know linear algebra, code is self-explanatory. Dot product is just the sum of element-wise products. But what the heck are dot and norm to someone that doesn't.

Re:Embeddings: What they are and why they matter by toxik on Wednesday October 25, 2023 @08:27AM (#38012057)
That’s exactly my point, it ISN'T self explanatory when it’s mathematical code like this, expressed in terms of addition and multiplication. Understanding the dot product as “sum of multiplications” is an extremely shallow understanding, and in no way does it explain why taking the dot product and dividing by magnitudes (What are those? Root of sum of squares? Why?) produces anything useful.

This code says nothing about the geometric nature of what is going on, only the arithmetic. Then we might as well read assembler. Abstractions help us reason.

Re:Embeddings: What they are and why they matter by simonw on Wednesday October 25, 2023 @09:45AM (#38012708)
The whole point of my talk here was to reassure people that you don't need to understand linear algebra in order to make use of embeddings.
Re:Embeddings: What they are and why they matter by alexvitkov on Wednesday October 25, 2023 @10:24AM (#38013153)
You either know the math or you don't, and if you don't, you're not gonna get any new magic intuitions no matter how it's shuffled around.
Re:Embeddings: What they are and why they matter by forgotpwd16 on Wednesday October 25, 2023 @11:41AM (#38013987)
>What are those? Root of sum of squares? Why?

I see what you mean. Probably can be argued that learning and applying a specific concept doesn't necessarily imply learning the deeper mathematics behind it and understanding its nature. So can just say cosine similarity measures the similarity of two vectors (lists in python) and its implementation is that sum divided by the product of sqrts of those two other sums without having to introduce and explain dot product and norm. Of course the reverse can be argued too.

Re:Embeddings: What they are and why they matter by Q6T46nT668w6i3m on Wednesday October 25, 2023 @10:26AM (#38013168)
I’d think you’d want to know dot and norm before embeddings. Especially since most people learn mathematical objects from the perspective of the operators that construct and manipulate them.