Skip to main content

topk

Function topk 

Source
pub fn topk(
    embeddings: &[Vec<f32>],
    query: &[f32],
    top_k: usize,
) -> Vec<(usize, f32)>
Expand description

Returns the top-k (index, similarity) pairs for query over embeddings, sorted by descending similarity.

Small corpora use exact brute force. Large corpora build (once) and reuse a cached HNSW index. Falls back to brute force on lock failure.