News for hackers. Stuff that matters.
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by latency-guy2 on Tuesday March 12, 2024 @12:03AM (#39676079)
Not reading the paper, cosine similarity has little to no semantic understanding of sentences.

E.g. the following triple

1: "Yes, this is a demonstration"

2: "Yes, this isn't a demonstration"

3: "Here is an example"

<1, 2>, Has "higher" cosine similarity than <1, 3>, structurally equivalent except for one token/word, <1, 2> semantically means the opposite of each other depending on what you're targeting in that sentence. While <1, 3> means effectively the same thing.

If this paper is about persuading people about efficacy with regards to semantic understanding, OK, but that was always known. If its about something with relation to vectors and the underlying operations, then I'll be interested.

Re:Is Cosine-Similarity of Embeddings Really About Similarity? by Tostino on Tuesday March 12, 2024 @12:10AM (#39676117)
That is entirely dependant on the model for the embeddings. You can fine tune for pretty much any outcome you want.
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by seanbethard on Tuesday March 12, 2024 @03:24AM (#39676975)
You can't fine-tune for understanding or reasoning. You can't "get better performance" on understanding. You're either equipped for it or you're not.
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by soarerz on Tuesday March 12, 2024 @12:08AM (#39676109)
What is the cheapest way to capture similarity if not via dot product then?
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by gajus on Tuesday March 12, 2024 @01:06AM (#39676362)
Interested to know as well
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by latency-guy2 on Tuesday March 12, 2024 @02:27AM (#39676723)
I don't have an answer for this really outside of silly ones like "strict equality check", but I assert that no one else does either, at least today and right now, and its an inherent limitation due to the nature of embeddings and the space it desires to be (cheap, fast, good enough similarity for your use case).

You're probably best off using the commercial suggestion, and if its dot product, go for it. I am no expert in this area and my interest wanes every day.

Re:Is Cosine-Similarity of Embeddings Really About Similarity? by scotty79 on Tuesday March 12, 2024 @04:49AM (#39677422)
Instead of sums of multiplications you could for example use sum of squares of differences.

Means squared error instead of dot product, it's not cheaper but it's close

If you want to go cheaper you could use sum of abs of differences.

Re:Is Cosine-Similarity of Embeddings Really About Similarity? by soarerz on Wednesday March 13, 2024 @10:07AM (#39691366)
This is effectively "the same" as dot product.

For a lot of embeddings we have today, norm of any embedding vector is roughly of same size, so the angle between two vectors is roughly same size as length of difference that you are saying, and can be expressed in terms of 1 - dot product after scaling

Re:Is Cosine-Similarity of Embeddings Really About Similarity? by superkuh on Tuesday March 12, 2024 @12:31AM (#39676212)
That might be true for one-hot vectors but it's not true for learned embedding through the lens of attention. That said, I only made to page 3/9 of the paper before the mark-up for the math went over my head.
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by latency-guy2 on Tuesday March 12, 2024 @02:14AM (#39676666)
If we're talking about adding dimensionality and relying on the kernel, sure, but I only get so much incorrect by going from 1 to M dims.

I can't of course be certain in all cases, but dimensions are typically (past experience, and using knowledge from word2vec experiments from years ago) derivative of higher dimensions. The kernel still operates on the same concept by applying a norm along with whatever weightings to each dim.

Semantic understanding is still not there in my opinion, we might feign it by increasing specificity, but only so much. Largest contributor will likely still the determining factor rather than the series of smaller, more specific dimensions.

I tested this using similar sentences as my original comment and failing in more scenarios than passing. I of course am biased since it may be given I did not select the right dimensions or measures.

Re:Is Cosine-Similarity of Embeddings Really About Similarity? by seanbethard on Tuesday March 12, 2024 @01:55AM (#39676585)
It is true. And if you want to say anything about meaning this isn't even the right math.
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by vidarh on Tuesday March 12, 2024 @12:46AM (#39676285)
Whether your not the cosine similarity of either pair is higher depends on the mapping you create from the strings to the embedding vector. That mapping can be whichever function you choose, and your result will be entirely dependent on that.

If you choose a straight linear mapping of tokens to a number, then you'd be right.

Extending that, if you choose any mapping which does not do a more extensive remapping from raw syntactic structure to some sort of semantic representation, you'd be right.

But hence why we increasingly use models to create embeddings instead of simpler approaches before applying a similarity metric, whether cosine similarity or other.

Put another way, there is no inherent reason why you couldn't have a model where the embeddings for 1 and 3 are identical even, and so it is meaningless to talk about the cosine similarity of your sentences without setting out your assumptions about how you will created embeddings from them.

Re:Is Cosine-Similarity of Embeddings Really About Similarity? by latency-guy2 on Tuesday March 12, 2024 @02:39AM (#39676772)
> meaningless to talk about the cosine similarity of your sentences without setting out your assumptions about how you will created embeddings from them.

I agree, but from generics POV, you have to settle on a few things to compare between models. If you can't, then benchmarks are useless too outside of extremely narrow measures.

I only address structure in the parent, and sure, it can be too generic of a statement by only touching on structure. But I would almost assert structure is still an important feature, and I would almost assert that it is required or otherwise a dominant feature when you want to deliver a product for general use.

I don't think I get too much more incorrect going beyond a few dimensions given this.

Re:Is Cosine-Similarity of Embeddings Really About Similarity? by vidarh on Tuesday March 12, 2024 @06:57AM (#39678095)
From the introduction to the paper:

> Discrete entities are often embedded via a learned mapping to dense real-valued vectors in a variety of domains.

Already from that point, it is clear that a comparison based on the similarity of the textual version of the sentences is irrelevant to the evaluation in the paper. The paper consistently talk in terms of "learned embeddings" rather than simplistic direct mappings of words.

Re:Is Cosine-Similarity of Embeddings Really About Similarity? by seanbethard on Tuesday March 12, 2024 @01:42AM (#39676517)
It is meaningless to talk about cosine similarity of sentences, or words, at all. Choose whatever mapping you want. You'll still be in Firth Mode.
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by seanbethard on Tuesday March 12, 2024 @03:31AM (#39677015)
Uh oh. LOL. Got some angry Firthers out there.
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by vidarh on Tuesday March 12, 2024 @07:05AM (#39678134)
It's meaningful to talk about cosine similarity for anything that you can quantify in ways such that the cosine similarity reflects a measure you care about. Same applies for any function. If it works, it's meaningful to talk about it whether or not it has a reasonable interpretation beyond that.
Re:Is Cosine-Similarity of Embeddings Really About Similarity? by seanbethard on Tuesday March 12, 2024 @01:39AM (#39676504)
No understanding. Embeddings are a semantically vacuous representation and similarity is a semantically vacuous interpretation.