Skip to main content

Module distance

Module distance 

Source
Expand description

Distance metrics for vector similarity search.

All Metric::distance functions return a value where smaller means closer, so the HNSW graph can order candidates with a single min-heap convention regardless of metric. Metric::score converts a raw distance back into a human-facing similarity where higher means more similar (used by the RAG layer and min_score cutoffs).

Enums§

Metric
The distance metric used by a vector index.

Functions§

dot
Dot product of two equal-length slices.
normalize
L2-normalizes a vector in place. A zero vector is left unchanged.
squared_l2
Squared Euclidean distance between two equal-length slices.