Re:How to Build a Semantic Search Engine in Rust
by extasia on Wednesday November 09, 2022 @05:42PM
(#33539137)
For anybody interested in why this comment says "cosine similarity _or_ dot product", its because the vectors in word embedding models are typically scaled to unit length.
If cos(theta) := A.B / (|A|^2 * |B|^2)
And A and B are normalised, then the denominator is 1, and the RHS is equal to the dot product.
If cos(theta) := A.B / (|A|^2 * |B|^2)
And A and B are normalised, then the denominator is 1, and the RHS is equal to the dot product.