Expand description
Distance metrics and the distance computations built on them.
Enums§
- Metric
- How the distance between two vectors is measured.
as_strandFromStrconvert it to and from the name stored in an index’sinfo/metric.
Functions§
- calculate_
distances - Scores every row of
embeddingsagainst the queryq, as L2 distances or, for IP, inner products. Setis_normalizedonly if every row is unit-length, which lets L2 skip computing the rows’ norms. L2 distance for unit-length rows =sqrt(1 − 2·e·q + ‖q‖²). - negative_
squared_ distances - Computes the squared L2 distance between every row of
aand every row ofb, negated so a higher score is closer, as an(a.nrows(), b.nrows())matrix. Squared distance =‖a‖² − 2·a·b + ‖b‖².