Hacker News new | ask | show | jobs
by SR2Z 997 days ago
You don't need to call cosine to compute cosine similarity - most of the time, a normalized dot product is sufficient.

Needless to say, dot products are directly supported in hardware via the FMA unit.

1 comments

Yes, this would be fast assuming the vectors are pre-normalized, obviating the need to repeatedly calculate two square roots.
Even if the vectors are NOT normalized, you don't always need to normalize them.

Add in nd indices and the costs tend to be very small.