Expand description
Query-time search over a built Index.
The flow mirrors PLAID’s reference implementation:
- For every query token, find the
n_probetop dot-product coarse centroids (matchingS_c,q = C · Q^T). This is paper Stage 1. - Optional centroid pruning: drop probed centroids whose best
score across all query tokens sits below
centroid_score_threshold. This is used both here (to shrink the reachable centroid set before postings are gathered) and below, at token level, when scoringD̃. - Union the doc-level IVF postings for the surviving centroids to get a set of candidate documents.
- Optional centroid interaction. When
n_candidate_docsis set, the cascade runs in two refinement passes:- Stage 2 (paper §4.3): approximate MaxSim with the pruned mask
applied at token level; keep top
n_candidate_docs(paper’sndocs). - Stage 3 (paper §4.2): approximate MaxSim without pruning on
the Stage 2 survivors; keep top
n_candidate_docs / 4(paper’sndocs/4empirical heuristic), clamped to at leasttop_k.
- Stage 2 (paper §4.3): approximate MaxSim with the pruned mask
applied at token level; keep top
- Decode the survivors’ stored residual codes into approximate embeddings and compute exact MaxSim against the query.
- Sort by exact MaxSim score and return the top-
top_k.
The pruning and interaction stages share a precomputed
[n_query_tokens, n_centroids] query-centroid score matrix that
step 1 would conceptually compute anyway, and together they
drastically shrink the set of candidates reaching the expensive
decode in step 5. Callers that want the legacy behaviour (every
probed candidate decodes, no pruning) can pass
n_candidate_docs = None and centroid_score_threshold = None.
Structs§
- Search
Params - Tunable knobs for a single search call.
- Search
Result - One entry in a ranked search result list.
Functions§
- search
- Run a PLAID-style search over
indexand return the top-top_kdocuments ranked by ColBERT MaxSim againstquery_tokens. - top_
n_ centroids - Indices of the
ncentroids with the highest dot-product againstpoint, most relevant first.