Skip to content

Provide other options for vector comparisons besides dot product #152

@arunkiyengar

Description

@arunkiyengar

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.

Metadata

Metadata

Labels

priority/P2Nice-to-Have / Exploratory

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions