pub fn cosine_similarity(a: &[f32], b: &[f32]) -> f32Expand description
True cosine similarity in [-1, 1], normalizing both inputs.
The local SHA1 embedder returns unit-norm vectors, but managed/BYOK
providers may not, so a bare dot product would rank by magnitude and
disagree with the ANN cosine path. Dividing by the norms keeps the
linear-scan fallback consistent for any provider. Zero-norm inputs
return 0.0 rather than NaN.