Skip to main content

maxsim_flat

Function maxsim_flat 

Source
pub fn maxsim_flat(
    query: &[Vec<f32>],
    document: &[f32],
    dimension: usize,
) -> f32
Expand description

MaxSim over already-normalized query vectors and a flat document matrix.

Routes to a vectorised kernel when the dimension is a multiple of 16 on aarch64 (covers the standard ColBERT/E5/MPNet embedding sizes 128, 384, 512, 768, 1024), and to the packed AVX-512/AVX2 kernel for any dimension on x86_64. Falls back to the scalar path everywhere else.

When one query is scored against many documents, build a MaxSimQuery once instead: on x86_64 this call re-packs the query every time.