Skip to main content

sparse_maxsim

Function sparse_maxsim 

Source
pub fn sparse_maxsim(
    query_tokens: &[(&[u32], &[f32])],
    doc_tokens: &[(&[u32], &[f32])],
) -> f32
Available on crate feature sparse only.
Expand description

Sparse MaxSim (SPLADE-style) scoring.

Computes Σᵢ max(w_q[i] * w_d[i]) or similar aggregation for sparse vectors.

For SPLADE, the score is typically just dot product of expanded vectors. But for “Sparse ColBERT” (late interaction over sparse vectors), we need maxsim.

§Arguments

  • query_tokens - List of sparse vectors for query tokens
  • doc_tokens - List of sparse vectors for doc tokens

§Returns

Sum of max similarities.