Skip to main content

l2_normalize

Function l2_normalize 

Source
pub fn l2_normalize(v: &mut [f32])
Expand description

L2-normalizes in place, which is what every BGE/E5/GTE consumer expects of an embedding and what common_embd_normalize’s default (p == 2) does. A zero vector is left alone, exactly as upstream leaves it (it divides by norm > 0 ? 1/norm : 0, i.e. it zeroes — and a zero vector is already zero).