pub fn top_k(query: &[f32], corpus: &[Vec<f32>], k: usize) -> Vec<Scored>Expand description
Rank corpus vectors against query and return the top k by cosine
similarity, highest first.
Ties break by ascending index so the ordering is deterministic (matters
for reproducible evals and snapshot tests). k == 0 or an empty corpus
returns an empty vector. Entries whose vector length does not match the
query score 0.0 (via cosine) rather than being silently dropped,
so the result length is stable.