Learn · When the Reader Is a Machine
budding
Lexical, Vector, and the Deterministic Floor
Use the cheapest retrieval relation that is exact enough, then combine unlike rankings without pretending their scores share a scale.
“Our results show BM25 is a robust baseline and re-ranking and late-interaction-based models on average achieve the best zero-shot performances, however, at high computational costs.”
— Nandan Thakur et al., BEIR: A Heterogeneous Benchmark for Zero-Shot Evaluation of Information Retrieval Models
This is the twenty-seventh chapter in a book about search from first principles. You will choose lexical or vector retrieval from the requested relation, inspect the representation and approximate-neighbor errors hidden by “semantic search,” and derive the exact homogeneous law that licenses top-k of top-k. You will show why raw heterogeneous scores cannot be added, derive reciprocal rank fusion's rank-only invariance, expose grouped results as segmentation rather than fusion, and calculate how tail latency compounds across repeated retrieval. The next chapter crosses beyond words by extracting text from images, audio, and video without pretending those projections are the media themselves.
Ask which relation the query names
Consider two requests for a machine part:
XR-417-B;- “the part that stops the rattling near the fan.”
The first asks for symbol identity. Normalized exact matching, prefix lookup, or a rare-token inverted index can answer deterministically. A learned semantic representation may blur the identifier with visually or linguistically nearby strings and add no useful evidence.
The second asks for paraphrase and function. Its useful document may contain “vibration-damping bracket” without sharing a query term. Lexical evidence can miss it; a representation trained to place related descriptions nearby may recover it.
Choose the cheapest relation that is exact enough:
| Question shape | Strong first tier | What it proves |
|---|---|---|
| identifier, command, exact quotation | exact or prefix lexical lookup | declared symbol/text relation |
| rare named entity or code token | lexical ranking | direct token evidence |
| paraphrase or synonymy | semantic candidate retrieval | proximity in one representation |
| cross-lingual request | aligned multilingual representation | proximity under its training objective |
| mixed intent | measured hybrid | only the declared fusion policy |
BEIR measured a robust BM25 baseline across its heterogeneous benchmark. That is source evidence for those datasets, not proof that lexical retrieval wins a new task. It is enough to reject the caricature that a deterministic baseline is obsolete before local evaluation begins.
A vector index searches a chosen geometry
A feature extractor maps each item to a vector
A distance or similarity then defines neighbors in that geometry. The index does not discover meaning independently; it accelerates neighbor search for the representation it was given.
Three errors must remain separable:
- representation error: relevant items are far apart or irrelevant items are close under ;
- neighbor-search error: the approximate index misses a true neighbor under the chosen geometry; and
- decision error: a retrieved neighbor is admitted, fused, or grounded under the wrong policy.
Changing index parameters cannot repair a representation that puts the wrong items together. Retraining or replacing the representation cannot prove an approximate index reached the nearest vectors. Evaluation needs an exhaustive vector-search oracle on a bounded corpus plus task relevance judgments.
Representation identity includes model, preprocessing, tokenizer, numeric precision, dimension, normalization, and corpus revision. Mixing vectors from two identities creates a geometry neither model defined.
Approximate neighbors spend a recall budget
Exact nearest-neighbor search compares the query with every vector. At scale, graph indexes such as HNSW build layers of proximity links. Search begins in a sparse upper layer and descends through denser neighborhoods, exploring a bounded candidate frontier.
The important controls are not magic constants:
- graph degree changes memory, construction, and navigability;
- construction effort changes index quality and build cost;
- query exploration width changes latency and neighbor recall; and
- filters, deletions, and corpus updates alter reachability and maintenance.
Every approximate result receipt carries these identities and the exploration budget. “Nearest” without the metric, representation, and recall regime is an overclaim.
The evaluator sweeps recall@k against latency, memory, build time, and update behavior. It also separates vector-neighbor recall from task relevance: finding the exact nearest vectors perfectly does not prove those vectors answer the query.
The middle is a spectrum, not a binary
“Lexical or vector” hides several useful representations and interaction points. Put them on two axes: what each document stores, and when the query may interact with it.
Learned sparse retrieval
SPLADE learns a sparse vector over a fixed lexical vocabulary. For term coordinate , query and document receive nonnegative learned weights and . Scoring remains a sparse dot product:
The model can assign weight to expansion terms absent from the authored text, so it can bridge some vocabulary mismatch while retaining inverted-index execution and interpretable term coordinates. It is learned sparse, not the deterministic lexical floor: model training, vocabulary, expansion, sparsity regularization, and weight quantization become index identity.
Sparsity is the resource bargain. Weaker regularization can improve a measured ranking while expanding postings and query work. Report nonzero query and document coordinates, postings visited, index bytes, latency distribution, and held-out relevance together. The SPLADE paper's measured tradeoff belongs to its models and corpora; it does not set a universal regularization value.
Late interaction
A dense bi-encoder compresses a whole query and document into one vector each. ColBERT instead retains contextual token vectors and delays interaction until query time. A simplified MaxSim score is
Each query token finds its strongest document-token match, preserving more fine-grained evidence than one pooled document vector. The cost is a much larger multi-vector index and a scoring problem that ordinary single-vector nearest- neighbor machinery does not solve directly.
ColBERTv2 compresses those token representations and changes supervision. PLAID is an execution engine for the resulting late-interaction model: it uses centroids for coarse retrieval, prunes candidates progressively, then performs finer scoring. Therefore ColBERTv2 and PLAID are not two independent rankers to fuse. One defines learned representations and scoring; the other approximates and accelerates candidate retrieval for that scoring contract.
As with every optimized path, compare PLAID with an exhaustive ColBERTv2 oracle on bounded corpora and record parameter regimes that reach each pruning stage. MacAvaney and Tonellotto's later reproduction found a workload-dependent frontier and a competitive lexical-retrieval-plus-reranking baseline. That is a useful reminder to measure the simple staged alternative, not a universal verdict against PLAID.
Learning to rank
Learning to rank consumes candidates and features, then learns an ordering objective from judgments or interaction evidence. It usually sits after a high-recall first stage. If candidate generation returns set , no reranker can place a relevant document outside :
This ceiling makes candidate recall an independent guard for every reranker improvement.
LambdaMART is a common family of additive regression-tree rankers trained with ranking-sensitive gradients. QuickScorer is not the learner. It is an inference algorithm and bit-vector representation for evaluating additive regression-tree ensembles efficiently. Saying “we use QuickScorer” identifies how a tree model runs, not which objective, labels, features, or model produced it.
A generative language model can also rerank a bounded list using pointwise, pairwise, or listwise prompts. RankGPT-style work measured such behavior on its benchmarks. The method adds a context limit, model and prompt version, stochastic or provider behavior, position and permutation sensitivity, token cost, and much larger latency. Treat the output as another versioned ranker; test permutations, repeats, hard negatives, candidate-recall ceilings, and cost-weighted quality against smaller supervised rerankers.
The useful pipeline taxonomy is now explicit:
| Stage | Examples | Can recover an omitted document? |
|---|---|---|
| deterministic floor | exact, prefix, BM25 | yes, within its indexed relation |
| learned first-stage retrieval | SPLADE, dense bi-encoder, ColBERT/PLAID | yes, within its representation and search budget |
| bounded reranking | LambdaMART/QuickScorer, cross-encoder, GPT ranker | no; it only reorders admitted candidates |
| final fusion and policy | homogeneous top-k, RRF, eligibility, abstention | no; it composes or rejects existing evidence |
These stages may be collapsed in one implementation, but their proof obligations remain different.
Top-k of top-k is exact in one homogeneous case
Let every shard use the same scorer , query interpretation, corpus revision, stable identity relation, and total tie-break order. Define
after deduplicating equal identities.
Then is associative, commutative, and idempotent:
More importantly,
Proof: if candidate is omitted from shard 's local top-k, at least candidates in that shard precede under the same total order. Those same candidates precede globally, so cannot enter global top-k. Thus local omission removes no possible global winner.
The proof fails when shards disagree on scorer, tie-break, query analysis, index revision, or identity. Overlapping shards must deduplicate before the idempotence claim. Heterogeneous providers do not inherit this law merely because each returns a list named “top-k.”
Algorithm — homogeneous top-k tree
MERGE-TOP-K(LISTS, LIMIT, CONTRACT)
Input: bounded LISTS sharing one scored total-order CONTRACT
Output: deterministic global top LIMIT
heap ← EMPTY-MIN-HEAP(LIMIT)
seen ← EMPTY-IDENTITY-SET
for each list in STABLE-SHARD-ORDER(LISTS)
REQUIRE-SAME-CONTRACT(list, CONTRACT)
for each candidate in TAKE(list, LIMIT)
if not CONTAINS(seen, candidate.identity)
seen ← ADD(seen, candidate.identity)
heap ← KEEP-BEST(heap, candidate, LIMIT)
return SORT-BY-CONTRACT(heap, CONTRACT)The stable shard order does not decide relevance; it only makes diagnostics and resource use reproducible. The total score/tie contract decides the result.
Raw heterogeneous scores have no common arithmetic
Suppose lexical scores range from 0 to 25 while vector cosine similarities lie between -1 and 1. Adding them gives the lexical scale more influence, not necessarily more evidence. Min-max normalization depends on the observed candidate set; z-scores depend on distribution shape; both can move when an unrelated candidate arrives.
Calibrated relevance probabilities may be combined under a justified model, but calibration itself is task-, corpus-, and policy-specific. Without it, raw score fusion is unit arithmetic without shared units.
Reciprocal rank fusion discards score scales. For document across ranked lists , define
omitting a term when is absent. The constant controls how sharply the contribution falls with rank.
RRF is invariant under any strictly increasing transformation of a source's raw scores because ranks do not change. It rewards agreement across systems and high placement without asking score 8.2 to mean the same thing as cosine 0.74.
The constant is not irrelevant. Large flattens the difference between nearby ranks; small emphasizes the head. Cormack, Clarke, and Büttcher reported results for their experimental settings. A new system pins and tests it across held-out tasks rather than calling the source's value universal.
Segmentation is not fusion
A search surface may show pages, passages, commands, and settings in separate groups. Each group has a correct local order, but the layout order between groups is not a relevance comparison.
This can be honest. Label groups and state that group placement is a product decision. The failure is to imply one global “best result” while concatenating heterogeneous lists with no cross-group algebra.
Segmentation is fusion by fiat when the surface inherits a global guarantee from a ranker that never compared the groups. Every local test can pass while the composed surface has no stated property.
Choose one:
- preserve groups and explicitly deny cross-group relevance order;
- fuse shared identities with a declared heterogeneous method such as RRF;
- route the query to one eligible provider before ranking; or
- define a calibrated common objective and prove its bounds.
Do not use color, section order, or independent top-k caps as an unstated aggregation function.
Tail latency compounds in two different ways
Let one retrieval call have latency distribution .
For sequential calls with finite mean,
For independent parallel calls, completion waits for the maximum:
The median parallel completion time is therefore
At , is approximately , so the median of the maximum lies near one call's p99 under the independence model. Correlation can make the tail worse or different; the equation is a diagnostic model, not a production promise.
An agentic loop can pay both costs: several providers fan out within a turn, then several turns occur serially. Optimize tail settlement, bounded fan-out, cache identity, and the number of retrieval calls—not only single-call p50. Dean and Barroso's tail-at-scale analysis motivates this question in large services; local traces must establish the actual distribution and dependence.
Sometimes the book is the wrong implementation plan
For a few thousand static documents, a database full-text index, an embedded library, or even a bounded scan may meet every relevance and latency need. For an exact codebase lookup, a line-oriented search tool may be clearer. For a large organization with operational staff and a suitable privacy contract, a hosted service may be cheaper than owning indexing and evaluation.
Use the cost model:
- corpus and update size;
- query volume and latency envelope;
- required relations and languages;
- privacy and authorization boundaries;
- evaluation and operations capacity;
- offline and deterministic requirements; and
- total maintenance cost.
Building an inverted index, vector pipeline, approximate graph, fusion layer, and evaluator for a tiny stable corpus is not mastery of the book. Recognizing that the simple tool already satisfies the contract is.
Negative results
| Temptation | Failure |
|---|---|
| replace identifiers with semantic vectors | an approximate relation weakens exact symbol lookup |
| call SPLADE ordinary exact lexical search | learned expansion changes the evidence and index identity |
| call PLAID a separate semantic model | it is an engine for late-interaction retrieval and pruning |
| evaluate only reranker nDCG | the candidate generator's recall ceiling disappears |
| call QuickScorer the learned objective | an inference engine is mistaken for model training and labels |
| use a GPT reranker without permutation tests | prompt order and model behavior become hidden ranking features |
| call vector neighbors meaning | the representation defines the geometry and its errors |
| tune graph search to fix bad embeddings | neighbor recall cannot repair representation error |
| take top-k of heterogeneous top-k | local omission no longer certifies global inferiority |
| add lexical and vector scores | incomparable scales become arbitrary weights |
| call groups globally ranked | layout order masquerades as relevance fusion |
| optimize only p50 | parallel maxima and serial loops expose the tail |
| build every tier | operational complexity exceeds the problem's actual contract |
Lessons
- Choose retrieval from the relation named by the query.
- Exact identifiers and rare tokens deserve a deterministic lexical floor.
- Vector retrieval searches one versioned representation geometry.
- Learned sparse retrieval trades vocabulary expansion against inverted-index sparsity and work.
- Late interaction retains token vectors; PLAID accelerates ColBERTv2's retrieval rather than defining a separate relevance model.
- A reranker cannot recover a relevant item omitted by candidate generation.
- QuickScorer evaluates tree ensembles; it does not choose their learning objective or evidence.
- GPT reranking is another bounded, versioned ranker with context, order, latency, and reproducibility costs.
- Separate representation, approximate-neighbor, and decision errors.
- Homogeneous top-k is associative, commutative, and idempotent under one scorer, total order, identity relation, query, and revision.
- That law exactly licenses top-k of top-k and exactly excludes heterogeneous providers.
- RRF combines heterogeneous rankings without assuming score-scale agreement.
- RRF's constant changes head-versus-tail weighting and must be evaluated.
- Grouped results are segmented; cross-group order is a layout decision unless a fusion algebra says otherwise.
- Sequential calls add means; parallel fan-out exposes high quantiles through the maximum.
- A database, scan, local tool, or hosted service may be the correct endpoint.
Practice
- Classify ten queries by the exact, lexical-ranked, or semantic relation they request.
- Give one representation error and one approximate-neighbor error that produce the same missing result.
- Prove the top-k-of-top-k law and construct a counterexample with two incompatible scorers.
- Show that RRF is invariant under a strictly increasing transformation of one source's scores.
- Calculate RRF for three documents at two values of and explain the changed head weighting.
- Specify the honest contract for a grouped pages/commands/settings surface.
- Derive the median maximum quantile for 10 and 100 independent providers.
- Choose a corpus where a bounded scan is preferable to every index in this book and defend the cost model.
- Place BM25, SPLADE, dense retrieval, ColBERTv2/PLAID, LambdaMART with QuickScorer, and a GPT reranker into candidate-generation and reranking stages; name each stage's recall ceiling.
References
- Nandan Thakur, Nils Reimers, Andreas Rücklé, Abhishek Srivastava, and Iryna Gurevych. “BEIR: A Heterogeneous Benchmark for Zero-Shot Evaluation of Information Retrieval Models.” NeurIPS Datasets and Benchmarks, 2021.
- Yu. A. Malkov and D. A. Yashunin. “Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs.” IEEE TPAMI 42.4, 2020.
- Thibault Formal, Benjamin Piwowarski, and Stéphane Clinchant. “SPLADE: Sparse Lexical and Expansion Model for First-Stage Ranking.” SIGIR, 2021.
- Omar Khattab and Matei Zaharia. “ColBERT: Efficient and Effective Passage Search via Contextualized Late Interaction over BERT.” SIGIR, 2020.
- Keshav Santhanam, Omar Khattab, Jon Saad-Falcon, Christopher Potts, and Matei Zaharia. “ColBERTv2: Effective and Efficient Retrieval via Lightweight Late Interaction.” NAACL, 2022.
- Keshav Santhanam, Omar Khattab, Christopher Potts, and Matei Zaharia. “PLAID: An Efficient Engine for Late Interaction Retrieval.” CIKM, 2022.
- Claudio Lucchese, Franco Maria Nardini, Salvatore Orlando, Raffaele Perego, Nicola Tonellotto, and Rossano Venturini. “QuickScorer: A Fast Algorithm to Rank Documents with Additive Ensembles of Regression Trees.” SIGIR, 2015.
- Weiwei Sun et al. “Is ChatGPT Good at Search? Investigating Large Language Models as Re-Ranking Agents.” EMNLP, 2023.
- Gordon V. Cormack, Charles L. A. Clarke, and Stefan Büttcher. “Reciprocal Rank Fusion Outperforms Condorcet and Individual Rank Learning Methods.” SIGIR, 2009.
- Ronald Fagin, Amnon Lotem, and Moni Naor. “Optimal Aggregation Algorithms for Middleware.” Journal of Computer and System Sciences 66.4, 2003.
- Jeffrey Dean and Luiz André Barroso. “The Tail at Scale.” Communications of the ACM 56.2, 2013.