-
Notifications
You must be signed in to change notification settings - Fork 180
Description
Is your feature request related to a problem? Please describe.
When comparing vectors for determining semantic similarity, it is preferable to have options such as cosine similarity.
Describe the solution you'd like
In lines 578-582 corresponding to the FindSimilar function for the Milvus cache backend in milvus_cache.go, where dot products are calculated:
// Calculate dot product similarity score
var similarity float32
for j := 0; j < len(queryEmbedding) && j < len(storedEmbedding); j++ {
similarity += queryEmbedding[j] * storedEmbedding[j]
}
Dot product is the only option for calculating semantic similarity. It would be preferable to offer other options such as cosine similarity. Unless you can guarantee that the vectors are normalized, dot product and cosine similarity are not the same thing.