Skip to main content

Module scoring

Module scoring 

Source
Expand description

Approximate inner product scoring without full decode.

The FibQuant codebook supports estimating the inner product of a query vector against a stored FibCodeV1 without running the full decode pipeline (rotation inverse + norm scaling). The method:

  1. Normalize the query, apply the same rotation → rotated query blocks.
  2. For each block, find the nearest codeword index (same as encode).
  3. Use a precomputed codebook Gram table G[i,j] = <cw_i, cw_j> to estimate <rotated_query_block, rotated_stored_block> as G[query_idx, stored_idx].
  4. Sum block-level estimates and scale by the stored norm.

This avoids decoding the stored vector entirely — you only need the packed indices and the stored norm, both of which are in FibCodeV1.

The estimate is approximate because the stored code uses the quantized codeword, not the original rotated block. The error is bounded by the codebook quantization noise and decreases as codebook size grows.

Structs§

FibPreparedQuery
Pre-rotated, pre-quantized query for batch scoring.
FibScorer
Approximate scorer for FibQuant codes.
GramTable
Precomputed codebook Gram table for approximate inner product scoring.
ScoredItem
A scored candidate from approximate search.

Functions§

decode_stored_norm