1 Answer
- Newest
- Most votes
- Most comments
1
DocumentDB's output for vector searches does not include similarity scores, unlike MongoDB. To obtain these scores, you can calculate them manually using a function like the following:
import math def euclidean_distance(vec1, vec2): return math.sqrt(sum((a - b) ** 2 for a, b in zip(vec1, vec2)))
This function calculates the Euclidean distance between two vectors, which can be used as a measure of similarity. For example:
query_vector = [0.2, 0.5, 0.8] document_vector = [0.2, 0.5, 0.8] # Example vector from a returned document score = euclidean_distance(query_vector, document_vector)
In this case, the
score
value represents the similarity between the query vector and a document's vector. Smaller score indicate higher similarity.
Resources:
Relevant content
- asked 2 years ago
- asked 10 months ago
- asked 3 years ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 8 months ago
- AWS OFFICIALUpdated 8 months ago