Skip to main content

compute_top_neighbors

Function compute_top_neighbors 

Source
pub fn compute_top_neighbors(
    embeddings: &[Vec<f32>],
    ids: &[String],
    top_k: usize,
    threshold: f32,
) -> Vec<Vec<MemoryNeighbor>>
Expand description

Top-k most similar neighbors per embedding, cosine-similarity only.

Returns one Vec<MemoryNeighbor> per input, in the same order. Each output is sorted by similarity desc, length ≤ top_k, and filtered to similarity >= threshold. Self-edges are removed.