pub fn compare_embeddings(a: &Vec<f32>, b: &Vec<f32>) -> f32 {
    let dot_product = a.iter().zip(b.iter()).map(|(x, y)| x * y).sum::<f32>();
    let norm_a = a.iter().map(|x| x.powi(2)).sum::<f32>().sqrt();
    let norm_b = b.iter().map(|x| x.powi(2)).sum::<f32>().sqrt();
    let min_length = min(a.len(), b.len()) as f32;
    dot_product / (norm_a * norm_b * min_length)
}
This is an implementation of Cosine Similarity.
src/memory/mod.rs