MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / sq8_score

Function sq8_score

nodedb-vector/src/collection/search.rs:23–38  ·  view source on GitHub ↗
(
    codec: &crate::quantize::sq8::Sq8Codec,
    query: &[f32],
    encoded: &[u8],
    metric: DistanceMetric,
)

Source from the content-addressed store, hash-verified

21/// asymmetric distance.
22#[inline]
23fn sq8_score(
24 codec: &crate::quantize::sq8::Sq8Codec,
25 query: &[f32],
26 encoded: &[u8],
27 metric: DistanceMetric,
28) -> f32 {
29 match metric {
30 DistanceMetric::Cosine => codec.asymmetric_cosine(query, encoded),
31 DistanceMetric::InnerProduct => codec.asymmetric_ip(query, encoded),
32 // L2 (and all other metrics that don't have a specialized asymmetric
33 // form yet) fall back to squared L2 — correct for ordering when the
34 // metric is L2 and a reasonable proxy otherwise since we rerank with
35 // exact FP32 below.
36 _ => codec.asymmetric_l2(query, encoded),
37 }
38}
39
40/// Candidate-generation + rerank for a sealed segment that has a quantized
41/// codec attached. Generates a widened candidate pool via HNSW, re-scores

Callers 1

quantized_searchFunction · 0.85

Calls 3

asymmetric_cosineMethod · 0.80
asymmetric_ipMethod · 0.80
asymmetric_l2Method · 0.80

Tested by

no test coverage detected