Chapter 11. Embeddings and vector search

Data Mining as Observation, draft 0.3, 2026-09-09. Week 11 of ECE 514. Readings due before this chapter are Mikolov et al. 2013 sections 1 to 4, Reimers and Gurevych 2019 section 3, Malkov and Yashunin sections 1 to 2, and Jégou, Douze, Schmid 2011 sections I to III [37, 38, 39, 40]. Every number below traces to a committed file listed in the last section.

Week three asked when direction is the signal and magnitude is the nuisance. That question returns here as a design decision, and this chapter answers it. The answer is not cosine. The answer is whatever the consumer of the vector reads.

An embedding is a vector whose only purpose is to be read by something. A ranking function reads it. An attention head reads it. A classifier reads it. Each of those readers has a read operator, and each discards directions the others keep. Nearness in an embedding space is therefore not a property of the space. It is a property of the reader. Every practical question in this chapter, which quantizer to use, how to score an index, what recall means, why some queries fail, and how many calls it costs to find out what a reader reads, comes back to that sentence.

The material comes from three instruments built between July and August 2026 and the benchmark that tests them. Two of the three ship on PyPI. The numbers are theirs.

11.1 Nearness is a property of the reader

Write the three readers this chapter uses as observer triples.

The cosine ranker reads the angle between a query and each stored vector and discards the norms. Its output metric is rank order. Its budget is the number of candidates it can score.

The softmax attention head, the unit of a language model that section 0.11 introduces, reads the dot product of a query with each stored key, scaled and exponentiated. Its output metric is the weighted average it produces. Its budget is the context length.

The linear classifier reads the projection of a vector onto one weight direction and discards everything orthogonal to it.

For the cosine ranker, a quotient that separates scale from direction and keeps only direction loses nothing the ranker reads. For the attention head that same quotient deletes the per-channel scale the logits depend on. For the classifier the quotient keeps 767 directions of 768 that the reader never looks at. Three readers, one vector, three different notions of which directions matter.

The companion theory states the condition under which the direction-only quotient is safe. The consumer's metric must be carried by the tangential part of the displacement between vectors. The theory paper calls it condition (A2). Cosine ranking over roughly isotropic embeddings satisfies it. Softmax logits over attention keys do not, because the keys' directions concentrate in a cone so tight that the informative angular displacement sits below the quantizer's cell size, and the scale the logits read is exactly what per-vector normalization removed.

That an embedding is a quotient of its objects, and that a cosine reader takes a further quotient in which rescaling the query changes no nearest neighbour while a dot-product reader does not, are machine-checked in Lean in appendix C.

The rest of this chapter is what happens when the quotient is chosen without asking the reader.

11.2 Reconstruction fidelity can be anti-correlated with what the reader needs

The founding measurement of the compression program is a table with four rows [12]. Qwen2.5-1.5B-Instruct on wikitext-2, perplexity (section 0.11) measured by quantizing and immediately dequantizing the keys after the rotary position embedding so that the rest of the model runs unchanged, values quantized the same way in every row, so that the key quantizer is the only variable. The fp16 baseline reads perplexity 12.24.

key quantizerbitsperplexitykey reconstruction error, mean
none, values only13.12
PolarQuant, direction only4106430.095
per-channel uniform414.910.062
per-channel non-uniform315.770.148

The direction-only quantizer sits between the two per-channel quantizers on reconstruction error and has the worst perplexity by three orders of magnitude. The three-bit per-channel quantizer has 2.4 times the four-bit one's reconstruction error and 670 times better perplexity than the direction-only one. The same quantizer is near lossless for values, which attention averages, and catastrophic for keys, which attention multiplies. Keys quantized before the rotary embedding behave the same way at perplexity near 22000, and three bits against four does not rescue it. The model has two key heads serving twelve query heads, so a corrupted key poisons every query head that reads it.

Key reconstruction error against perplexity, Qwen2.5-1.5B, wikitext-20.050.0750.10.1250.15key reconstruction error, meanperplexity, log scale10100100010000fp16 baseline 12.24direction only, 4 bits, error 0.095, perplexity 10643direction only, 4 bitsper-channel uniform, 4 bits, error 0.062, perplexity 14.91per-channel uniform, 4 bitsper-channel non-uniform, 3 bits, error 0.148, perplexity 15.77per-channel non-uniform, 3 bitssame harness, same values, the key quantizer is the only variable
Figure 11.1. Reconstruction error against perplexity for three key quantizers on one model. The direction-only quantizer sits between the other two on reconstruction error and has a perplexity three orders of magnitude worse.

In cosine terms the direction-only codec reads 0.995 against the uncompressed keys. Cosine weighted every coordinate equally. The consumer weighted them by the query distribution. Cosine said lossless and the consumer said ruined. This is the number the program is named after, and it is the same number chapter 8 used as the founding negative. There it was a lesson about metrics. Here it is a lesson about quotients. A reconstruction benchmark could not have found it, because for keys reconstruction error and perplexity move in opposite directions.

$$\cos\big(k,\hat k\big)=0.995\qquad\text{while}\qquad \mathrm{PPL}:\ 12.24\ \to\ 10643. \tag{11.1}$$

That a direction-only quantizer keeps each key's length and its cosine with any query, while its score against a query moves by the length times the query's dot product with the direction error, is machine-checked in Lean in appendix C.

The lesson is installed as code rather than remembered. A calibration-time probe takes the declared consumer metric, cosine, Euclidean, or attention logits, and selects the quantizer family against it. The unit test for that probe reproduces the keys incident on synthetic key statistics. A streaming monitor reports the tangential fraction of the displacement, so that norm-dominated drift raises an alert before a release.

11.3 Accept on rank fidelity, and let a vacuous certificate tell you to rerank exactly

If reconstruction cannot be the acceptance metric, something else must be. For a ranking consumer the acceptance metric is rank fidelity, and the compression program ships a certificate for it.

The certificate takes the exact pairwise distances of a sample of anchor pairs and the same distances computed from the compressed vectors. The ratio of compressed to exact distance, taken per pair, has a spread. The certificate reads the ratio of its 97.5th percentile to its 2.5th percentile, the values that 97.5 and 2.5 percent of pairs fall below, and calls that the distortion, kappa. It trims the most distorted five percent of pairs, and there the word certificate has to be handled with care. In the strict setting, the zeroth and hundredth percentiles, kappa is the true worst-case distortion and the floor below is a guarantee, at the cost of being broken by a single collapsed pair. In the percentile setting the implementation computes kappa on the retained central pairs but mu hat over all pairs, so the floor is not a guarantee on either set, and the implementation itself calls it a robust estimate rather than a hard worst-case bound. The book says certificate and floor for the strict setting and estimate for the percentile one, and a report says which it ran. The certificate then reads a second number from the corpus itself, called mu hat, the fraction of unordered pairs of anchor pairs whose exact distances lie within a factor kappa of each other, which is the fraction of distance comparisons a kappa-distorted code could reorder. From those two numbers alone it states, in the strict setting, a floor valid for any corpus without assuming a distribution on the Kendall correlation between the exact ranking and the compressed ranking, one minus twice mu hat, and on the Spearman correlation, one minus three times mu hat. In the percentile setting the same two expressions are estimates. Section 0.8 defines both correlations with a worked example.

In the strict setting the floor is a deterministic statement about the ordering of the sampled anchor pairs, at the anchor count and seed the certificate records. Extending it even to queries drawn as the anchors were drawn is not automatic, since it needs the sampling argument of the paragraph below, with a confidence level, and it says nothing at all about queries from a different distribution. In the percentile setting the same sentence describes an estimate, and nothing is said about the trimmed five percent of pairs. Chapter 13 has the case in which a certificate's footprint and its traffic differ, and the same reading applies here.

$$\begin{gathered} r=\frac{d_{\mathrm{compressed}}}{d_{\mathrm{exact}}},\qquad \kappa_{\text{strict}}=\frac{\max r}{\min r},\qquad \tau\ \ge\ 1-2\hat\mu(\kappa_{\text{strict}}),\qquad \rho_S\ \ge\ 1-3\hat\mu(\kappa_{\text{strict}}), \\ \kappa_{97.5/2.5}=\frac{q_{97.5}(r)}{q_{2.5}(r)}\ \text{ gives the same two expressions as estimates, not floors.} \end{gathered} \tag{11.2}$$

The per-pair fact behind the strict floor, that a nearest neighbour is preserved whenever the runner-up is more than $\kappa_{\text{strict}}$ times as far, is machine-checked in Lean in appendix C. The floors themselves are derived in the source.

What the strict floor certifies is the global ordering of the sampled pairwise distances. The percentile estimate is not simply that ordering with five percent set aside. It trims the most distorted five percent of pairs when it forms kappa but computes mu hat over all pairs, so it pairs a trimmed distortion with an untrimmed count of reorderable comparisons, makes no worst-case statement about the trimmed pairs, and is a robust estimate rather than a bound. It does not directly certify any query's top-k recall, the ordering of one query's neighbours, or the pairs in the trimmed tail, and each of those needs its own measurement, which is why the compression program reports recall against truth beside the certificate rather than in place of it. A floor computed on a sample of anchor pairs is also a statement about that sample. Carrying it to the corpus needs a sampling argument with a confidence level, and the certificate records the anchor count and seed that such an argument would use rather than supplying the argument.

The example the specification carries reads kappa 1.0148 and mu hat 0.0664 over 19900 anchor pairs, which in the percentile setting estimates a Kendall correlation of at least 0.8671 and certifies nothing, and would certify that floor only if the same kappa held in the strict setting. The largest distortion at which the strict form could still certify a positive floor on that corpus is 1.83.

The certificate can also be vacuous. When no finite distortion certifies a positive floor, the test has proved nothing about the corpus. It has not shown that no compression can preserve rank, only that this certificate cannot certify one on these anchors, because their distance ratios are too concentrated for its bound to bite. That verdict is not a failure of the tool. It is the per-corpus signal that exact reranking is required after the approximate search, and a pipeline that reads it can budget for the rerank rather than discover the loss in production.

Three properties make the certificate an artifact rather than a number. It is bound to the SHA-256 hash (section 0.12) of the exact bytes it certifies, so it cannot be carried from one corpus to another. It records the metric, the anchor count, and the seed, so a third party can reproduce the measurement. And when the distortion is consumer-relative it names the read operator it was computed against, because two defensible references for a single attention head, the probe-recovered sensitivity and the raw query covariance, differ by about 0.3 in subspace overlap on real heads. A number computed against one and read as the other is a different quantity.

That the fraction of rows at or below a value is nondecreasing in the value, and that an upper percentile over a lower one is at least one, are machine-checked in Lean in appendix C.

The certificate is also the contract that lets a stranger's quantizer be judged by the same rule. A reference plugin outside the main repository implements two methods, compress and decompress, and one entry-point line. The conformance kit runs five checks, round trip, packed storage, the affine contract, sparse overlay, and serialization. One of the five reports skip rather than pass, because the plugin has no sparse overlay, and skip is a legitimate outcome. Because the plugin satisfies the affine contract exactly, with zero offset and one scale per channel, it inherits fused compute-on-codes decoding with no kernel work, demonstrated from outside the tree. Any third-party format can then be certified by the same rank floor as the in-tree formats.

11.4 Recall against your own ranking is not recall

The metric the session deck names for approximate search is recall at k. Recall against what is the question this section answers.

$$\begin{gathered} \mathrm{recall}@k=\frac{\big|\text{returned top-}k\ \cap\ \text{true top-}k\big|}{k}, \\ \text{true top-}k\text{ computed from the uncompressed vectors}. \end{gathered} \tag{11.3}$$

That recall lies in the unit interval and is one exactly when the returned list is the true list, and that a stratum failing entirely moves the aggregate by no more than its weight, are machine-checked in Lean in appendix C.

The vector-search benchmark that motivates the rest of this chapter began from one measurement [16]. An index reproduced its own exact ranking with recall 0.999. Against the fp32 exact neighbours of the same queries at the same instant, it read 0.592. A system can reproduce its own ranking almost perfectly while diverging from the true neighbours, and it can preserve the true neighbours while degrading actual relevance. The benchmark therefore reports three truths. Geometric truth is exact k-nearest-neighbour search under the frozen metric. Structural truth is relevance from links, citations, question-answer pairs, and cross-language pairs, free but biased, with the bias statistics shipped beside the labels. Human truth is independent relevance judgment on a few thousand queries. One number cannot see the difference between them.

The benchmark also refuses to report an average. Queries carry difficulty strata, local intrinsic dimension, neighbour margin, hubness exposure, neighbour dispersion, and disagreement between geometric and structural truth, and results are reported by stratum. An average recall conceals the failures worth studying. Section 11.6 says which queries those are.

A generator that matched every geometric statistic and none of the index behaviour. The benchmark's synthetic generator had passed a battery of ten registered geometric criteria against real corpora. An open characterization then ran identical inverted-file indexes (section 0.11), which partition the corpus into 1024 k-means cells and search only the cells whose centres are nearest the query, with twenty iterations of k-means and seed 7, over three blocks of a real corpus and two seeds of the generator, with exact ground truth for ten thousand queries each. That probing more cells never loses a candidate, that a neighbour is found exactly when its cell is probed, and that the scanned fraction with equal cells is the probe count over the cell count, are machine-checked in Lean in appendix C.

statisticreal, three blocksgenerator, two seeds
recall at 10 with one probe0.533 to 0.5360.914 to 0.917
recall at 10 with eight probes0.823 to 0.8280.981 to 0.982
probes for 95 percent recall47 to 502
median margin, second to first neighbour0.051 to 0.0520.054

The margins match. The cell occupancy statistics nearly match. The probe depth needed for the same recall differs 25 times. Both sides are internally tight, about one percent spread on every statistic, so the difference is structural. The diagnosis is that the generator's coarse structure is its generative clusters, which k-means recovers, so 92 percent of a query's true top ten sit in the query's own cell. Real neighbourhoods are hostile to partition. About a third of a real query's true top ten are in other articles, scattered across cells that no 1024-way partition co-locates, and the one-probe recall of 0.53 matches the same-article share of the real neighbourhood. The property that governs inverted-file difficulty is the alignment between neighbour structure and any recoverable partition, and none of the ten registered criteria measures it. The margin and occupancy statistics that folklore associates with search difficulty matched while the difficulty diverged 25 times.

Inverted-file recall at 10, real corpus against generator00.250.50.751recall at 101 probe, real, three blocks 0.5350.5351 probe, generator, two seeds 0.9150.9151 probe8 probes, real, three blocks 0.8250.8258 probes, generator, two seeds 0.9810.9818 probesreal, three blocksgenerator, two seedsprobes needed for 95 percent recall, real 47 to 50, generator 2, a 25 times difference
Figure 11.2. A generator that matched every registered geometric statistic and none of the index behaviour. Recall at ten on real data and on the generator at one and eight probes, and the probe count each needs for 95 percent recall.

The benchmark's own record calls this the Goodhart concern, now measured. A generator can be tuned to every published geometric statistic and still tell an index nothing about how hard the real data is. One registered admission gate, relative contrast, is a standard hardness predictor and was mandatory, and it discriminated nothing in the battery. It is reported rather than removed.

For a course project, the rule is direct. Report recall against exact neighbours computed from the uncompressed vectors, never against the index's own ranking, and report it by stratum.

11.5 The compression numbers that stand, and the ones that do not

The compression program keeps a claims ledger [12] in which every headline has a status, and continuous integration fails when the ledger and its machine-readable twin disagree. The statuses are the reason the numbers can be quoted.

One retrieval number is gated in continuous integration. On a public word-embedding corpus of 1.18 million vectors, full dimension with three-bit scalar quantization and a twelvefold rerank gives about 9.6 times compression at recall at ten near 0.999, and the command that replays it is part of the test suite.

The headline number is not gated. On a private sample of 199 thousand sentence embeddings at 768 dimensions, 32 times compression at recall at ten of 0.9993 ties optimized product quantization, beats a recent binary quantizer, and builds about twenty times faster than the product quantizer. It is marked reported, because the corpus is private, and the ledger says so beside it. A one-million-book corpus corroborates it and can be regenerated. A 27.7 times figure at high recall and a 114 times pipeline-storage figure are likewise marked reported and hold only on high-dimensional encoders with concentrated spectra. That the pieces' squared errors add, that the best code for the whole is the best code for each piece separately, and the bit count of the table, are machine-checked in Lean in appendix C.

The ledger also records where the method loses. Principal-component truncation without retraining is reproducible and wins only on high-dimensional embeddings. On compact descriptor sets of one hundred or 256 dimensions it loses to product quantization. The build-time advantage is over optimized product quantization, twenty times at 199 thousand vectors and four times at one million. The binary quantizer it beats on recall builds in well under a second and is far cheaper to build. The advantage over it is recall at matched bytes, not build time.

The session deck says there is no free corner of the accuracy, latency, and memory trade. The ledger is what that sentence looks like when each corner is a row with a status.

11.6 Hubs belong to the queries

Take a corpus of a million vectors, find each vector's ten nearest neighbours, and count how many times each vector appears in someone else's list. In low dimension the count is about ten for everyone. In the dimensions embeddings live in, a few vectors appear in hundreds of lists and a large fraction appear in almost none. The first are hubs. The second are anti-hubs. The skewness of the count distribution is the standard one-number summary, and it emerges with dimension for two reasons the reader already knows from week three. Distances concentrate, so tiny systematic advantages decide the top ten. Centrality and local density are such advantages.

Two corpora with the same skewness and different hubs. A real text corpus and a synthetic look-alike were measured at the same count skew. The real corpus's largest hub appeared in 78 lists. The synthetic corpus's largest hub appeared in 369. In the real corpus, being a hub was predicted by local density, with correlation about 0.67 against the negative tenth-neighbour distance, and hubs sat about eight percent below the population's local scale. In the synthetic corpus, hubs were 34 percent closer to the mean than average and 34 percent below the population's local scale. Same scalar, different mechanism. An index, a quantizer, or a graph builder treats those two corpora very differently. The anatomy tool therefore reports a vector, with each hub typed by its percentile in the centrality and density distributions, and it abstains from attributing a mechanism when the largest count is below two and a half times k, because noise hubs get no prescription. The two mechanisms have different remedies. Centrality super-hubs call for centering and a check of the pipeline for a mean shift or collapsed subspace upstream. Density-driven hubs call for mutual-proximity rescaling.

Hubness is a property of the queries. The counts are collected over a query set. A corpus that looks mildly hubby under its own rows as queries can look extremely hubby under a real workload that keeps visiting the same regions. The benchmark measured this directly on a real corpus of 1024-dimensional embeddings with one thousand committed real queries. The best single predictor of who gets retrieved, for all four response variables at every partition size, was a scalar measure of how much query mass sits near a point. Seven features of local corpus geometry, density, three neighbour radii, radius slope, local intrinsic dimension, and anisotropy, together added at most 20 percent to what that single scalar already carried at twelve leaves, against a registered threshold of 25 percent on at least three of four responses. Zero of four cleared it. The registered failure clause reads that retrieval response depends on the latent code essentially through one axis, query exposure. A point is not a hub because of where it sits. It is a hub because of what the queries ask for.

Anti-hubs are where compressed indexes fail first. Queries whose true nearest neighbour is an anti-hub are the hardest retrieval cases in the corpus, because the signal separating the right answer from the crowd is smallest. Quantization rounds fine distinctions away first. The damage lands on those queries, and aggregate recall barely moves, because they are a minority. The hub-difference tool reports four things recall at k cannot. Recall restricted to queries whose true nearest neighbour is a bottom-decile row. The fifth-percentile per-query recall. The correlation between the exact and compressed searches' hub rankings. And the overlap of their top-one-percent hub sets. It takes any two neighbour-id arrays, so it compares an exact search to a graph index, two shardings, or two quantizer operating points, and it can fail a build when the anti-hub recall drops below a threshold.

Two results from 2026 cited in the primer moved hubness from a quality concern to a security one. An attack that injects a handful of vectors near the embedding-space centroid creates centrality super-hubs that appear in a large fraction of retrieval lists. The mechanism taxonomy above is the defence's vocabulary.

11.7 Reading a consumer costs the full dimension

Everything above assumes the read operator is known. For a cosine ranker it has a closed form. For an attention head it is spanned by the head's queries, so it also has a closed form. For a consumer with no closed form, a fine-tuned classifier, a reranker, a black-box scoring service, the read operator has to be measured from the outside by perturbing the input and watching the output move, using the finite differences of section 0.5. The measurement instrument for that is a separate package [15], and its specification carries the number this section is about.

Give the probe k directions in a d-dimensional input space, and ask how many of sixteen read directions it resolves, the sixteen having been planted in a synthetic consumer so that the truth is known.

k over d0.250.50.751.01.251.5
directions resolved122161616

Three quarters of the budget buys two directions of sixteen. The last quarter buys the other fourteen. The cliff does not soften if only the top direction is wanted. Below full dimension a single reading is a projection onto a random subspace, and a projected operator's leading eigenvector is not the operator's unless the subspace happens to contain it. The calibration that tested the low-rank shortcut was declared with a bar that could kill the hypothesis, and it did. Required budget was full dimension at every graded rank from one to sixteen. Rank one recovered better than rank sixteen at half the dimension, 0.646 against 0.366, and never enough to clear 0.90 below full dimension.

$$\text{directions resolved}(k)=\begin{cases}1\ \text{or}\ 2,& k<d\\[2pt] \operatorname{rank}P_C,& k\ge d\end{cases}\qquad \text{cost}=2d\ \text{consumer calls per operating point}. \tag{11.4}$$

The cliff in its affine form, that a probe confined to fewer directions than the dimension cannot tell some pair of consumers apart on any call, and that probing the full basis recovers the gradient in two calls per coordinate, is machine-checked in Lean in appendix C.

Directions resolved against the probe budget k over d04812160.250.50.7511.251.5k over ddirections resolved of 16k over d 0.25, resolved 1k over d 0.5, resolved 2k over d 0.75, resolved 2k over d 1.0, resolved 16k over d 1.25, resolved 16k over d 1.5, resolved 16the cliff at k = dmeasured at 96 operating points, five seeds, ambient dimension 32; the same cliff holds at equal total budget within 8 times
Figure 11.3. The budget cliff. Directions of a planted sixteen-direction read subspace resolved by a probe given k directions in a d-dimensional space. Recovery is a cliff at k equal to d, and it is rank-independent.

The obvious objection is that many cheap points might average their way back. A sealed calibration fixed the total number of directional observations at 3072 and traded directions for operating points. At rank 16 the median resolution read 0.02, 0.11, 0.05, and 0.04 at one eighth, one quarter, one half, and three quarters of the dimension, and 1.0 at full dimension and above. Scaling the cheap arm to eight times the flagship budget moved its median from 0.062 to 0.057. The per-seed margin of full dimension over the best sub-dimensional cell at equal budget was 0.883 at the median against a sealed rule of 0.3. Within eight times the full-dimension spend, reallocating directions into points buys nothing at any graded rank. The asymptotic question past eight times is recorded open and priced. Nobody spends a hundredfold budget to avoid a onefold one.

The law was measured first and proved second. The confinement theorem states that transcripts confined to a k-dimensional subspace cannot identify hidden components below full dimension, and that known side information about a k0-dimensional exclusion moves the cliff to exactly d minus k0 and never softens it. The noisy version was proved next and then measured on a fresh seed. Noise prices accuracy, never admission.

The law is a statement about the probe as specified. The reader receives responses confined to the k directions it chose, the read operator is planted in a fixed subspace, and noise enters as the noisy theorem models it. Within the readscope instrument and its calibrations those are the conditions, and the cliff is a theorem under them. A reader that could choose its directions adaptively from earlier responses, or that had side information about the subspace, is the k0 case the theorem also covers, and no cheaper escape is claimed.

The accuracy of the instrument on real consumers is graded against exact closed forms, not against another estimate. 124 attention and recurrent-state cells across five model families, from 1.5 billion to 32 billion parameters and one state-space model, recover their read subspace at resolution 1.000 at a budget of 1.25 times the dimension. The instrument's linearity is partial. Direction transfers across domains and magnitude does not, and the specification says so on its sheet.

The prospective test that first established the blind probe [13] recovered a planted read subspace at overlap 0.936 against a chance level of 0.059, seeing only the consumer's outputs, and its blind statistic predicted the consumer-relative flip twelve of twelve times where reconstruction could not. That was a planted subspace with a smooth consumer. The real-model hardening is the 124 cells above.

The practical rule is one line. Pay two times the dimension in consumer calls per operating point, or expect the dominant direction and nothing else. For a data-mining project that wants to know which features a black-box model actually reads at one operating point, with a probe confined to the directions it chooses, that is the price of the answer, and that is the case the theorem covers. Whether many cheap points spread across operating points can average their way back to the population operator was measured within the tested budget range and is not a theorem. Cheap and half right is not on the menu at one point.

11.8 Domain fine-tuning moves the relation it trained on

The session deck introduces sentence embeddings and contrastive training at survey level. One measurement shows what fine-tuning does and does not transfer, and chapter 12 continues it.

A general multilingual sentence encoder was adapted to United States case law [41] by contrastive fine-tuning on citation pairs, and evaluated on two held-out relations with opinion-level disjoint splits. On citation retrieval, the relation it trained on, the AUROC (section 0.8) rose from 0.765 to 0.971, an increase of 0.206 with a 95 percent interval from a paired bootstrap (section 0.9) of 0.190 to 0.223. On docket lineage, a district opinion matched to its appellate reviewer, a relation the model never saw, it rose from 0.545 to 0.562, an increase of 0.018 with an interval of 0.004 to 0.031. The distance between those two increases bounds how much of the gain is transferable structure and how much is specialization to the trained relation.

The first attempt at the same adaptation used an unsupervised contrastive objective and reached 0.340 on citation retrieval, below the base encoder by 0.145 with an interval of negative 0.214 to negative 0.081. Its training loss fell while held-out retrieval fell with it. The weights were kept in the model card and not distributed. The published version's anisotropy, the mean cosine between random pairs, fell from 0.570 to 0.259, which is the direction-only quotient becoming more informative rather than less.

11.9 A mechanism that fit the story and failed its test

The compression program's ledger carried an unexplained negative. Four-bit key-value quantization degraded on very long generation tasks, and nothing in the program said why. A mechanism presented itself. A key written early in the sequence is read by every query after it. A head's read operator is spanned by its queries. If the query distribution moves along the sequence, then a codebook fitted at calibration is later applied to a consumer that has moved. The measurement instrument had already found that read operators do drift along the sequence, at rank one agreeing 0.667 across positional windows against a null of 0.933, on sixteen cells of one three-billion-parameter model.

The mechanism was sealed as a four-bar test against the degradation curve on a seven-billion-parameter model over forty documents with 512 generated tokens. The first bar asked whether the phenomenon reproduced under the corrected codebook. It did, with a 13.4 point difference in the record's fallback overlap scorer. The second bar asked whether the degradation survived teacher forcing, which removes the model's own outputs from the context. It did not. The third bar asked whether the orientation of the quantization error relative to the read operator did any work, against a null that randomly rotated the error while keeping its eigenvalues. The positional and rotated conditions read negative 0.015 and positive 0.005. The fourth bar asked whether the measured drift predicted the per-document damage. The Spearman correlation was negative 0.13 at a p of 0.45, and the sign test read p 0.42. Three of four bars failed and the verdict is recorded as a fail.

What the failed test established is the mechanism nobody had proposed. The collapse is feedback compounding of a constant codebook error through the model's own generated tokens, which is why teacher forcing removes it. The measurement instrument's record cites its own refutation beside the drift result, because a census that omits its own refutations is not a census. The drift is real. It is not the cause.

11.10 What a retrieval report may claim

A project that builds or compresses a vector index reports the following, each with the ledger class from chapter 8.

A report whose acceptance metric is cosine will be returned. A report whose certificate is vacuous and whose rerank is budgeted will be graded on the budget.

Exercises

Warm-up

  1. Write the cosine ranker, the softmax attention head, and a linear classifier as observer triples, naming what each discards.
  2. State the tangential-displacement condition in your own words and say which of the three readers of section 11.1 satisfies it.
  3. Explain how a quantizer can have the best reconstruction error and the worst perplexity in the same table.
  4. What does a vacuous rank certificate tell a pipeline to do, and why is that not a failure of the certificate?
  5. Why is a certificate bound to the hash of the vectors it certifies?
  6. State the difference between recall against an index's own ranking and recall against exact neighbours, and say which one the benchmark refuses to report alone.
  7. Why did a generator that matched every registered geometric statistic still need 25 times fewer probes than real data?
  8. Explain why the compression ledger marks its headline number reported rather than reproducible.
  9. Why is hubness a property of the query set rather than of the corpus?
  10. Why can aggregate recall stay high while anti-hub recall collapses?
  11. State the budget rule for reading a consumer and what a probe below it returns.
  12. Explain why teacher forcing removing a degradation points at feedback compounding rather than drift.

By hand

  1. A 768-dimensional embedding is stored as 32-bit floats. Compute the bytes per vector. Compute the bytes per vector at 3 bits per coordinate and the compression ratio.
  2. A certificate reads mu hat 0.0664. Compute the Kendall floor and the Spearman floor. State the value of mu hat at which the Kendall floor becomes zero.
  3. An index returns ten items for a query, six of which are in the true top ten from the uncompressed vectors. Compute recall at 10 against exact truth. State the recall the index would report against its own ranking.
  4. An inverted-file index has 1024 cells and searches 48 of them. Compute the fraction of the corpus scanned. If real data needs 48 probes for 95 percent recall and a generator needs 2, compute the ratio of corpus scanned.
  5. An attention head has dimension 128 and the probe measures its read operator at 96 operating points. Compute the number of consumer calls at the budget rule of section 11.7. Compute the calls if the probe were cut to half the dimension, and state from the table what it would resolve.
  6. A language model needs 3.58 bits per token on a test text. Compute its perplexity.
  7. Fine-tuning raised AUROC on the trained relation by 0.206 and on an unseen relation by 0.018. Compute the fraction of the trained-relation gain that transferred, and state what the two intervals in section 11.8 say about whether the smaller gain is real.

Programming

  1. Reproduce the four-row table of section 11.2 on any open model with a key-value cache you can patch. Report perplexity and key reconstruction error for a direction-only quantizer and a per-channel quantizer at the same bit width. State which direction the two numbers move in.
  2. Compute a rank certificate for one compressed embedding set from your project. Report kappa, mu hat, the Kendall floor, and whether you computed it in the strict setting, where the floor is a guarantee, or the percentile setting, where it is an estimate. If the certificate is vacuous, report the rerank depth at which recall against exact neighbours recovers to 0.99.
  3. For your Lab 4 index, report recall at 10 against the index's own exact ranking and against the exact neighbours of the uncompressed vectors, for the same queries. Report the two numbers side by side.
  4. Compute the neighbour-count distribution for your corpus under its own rows as queries and under your real query set. Report the largest count and the skewness under each. State which query set your recall numbers were computed with.
  5. Report recall restricted to queries whose true nearest neighbour is in the bottom decile of neighbour count, beside the aggregate recall.
  6. Choose one black-box scorer in your project. State its input dimension d. State how many calls to the scorer a full-dimension read-operator probe would cost per operating point, and whether your budget covers it. If it does not, state what the probe would return.
  7. Your project fine-tunes an encoder. Name one relation the fine-tuning trained on and one it did not. Report the held-out gain on each with a paired bootstrap interval.
  8. Build an inverted-file index on your corpus and on a Gaussian sample with the same dimension and count. Report the probe count each needs for 95 percent recall against exact neighbours. State whether your corpus is partition-friendly.

Answers to the warm-up and by-hand problems are collected in the answer key at the end of the book.

Homework 11. Certify the index

Assigned in week 11 as the companion to Lab 4, due Sunday of week 13. Twenty-five points.

Part A, two recalls (5 points). Programming exercise 22. The two numbers side by side, and one paragraph on which one Lab 4's debrief should quote.

Part B, the certificate (6 points). Programming exercise 21. Kappa, mu hat, the floor with its setting named as strict or percentile, and the certificate's JSON committed with the hash of the vectors it certifies. A vacuous certificate is acceptable and earns full marks if the rerank depth is reported.

Part C, the tail (6 points). Programming exercises 23 and 24. The count distribution under both query sets, anti-hub recall beside aggregate recall, and the threshold at which you would refuse the build.

Part D, the reader (5 points). Programming exercise 25. If your budget covers the probe, run it and report the effective rank. If it does not, report what the probe would return and do not run it. Running a sub-dimensional probe and reporting its top direction as the consumer's earns zero for this part.

Part E, the statement (3 points). The six items of section 11.10 for your index. A report whose acceptance metric is cosine earns zero for this part.

Preregistration. Before Part B, commit a file stating whether you expect the certificate to be vacuous and the Kendall floor you expect if not. Include the commit hash. Graded on having been made.

Sources for every number

Paths are relative to a checkout of the named repository, at the commit and with the access status listed in appendix A, all under github.com/ahb-sjsu unless appendix A says otherwise. Shas, DOIs, and versions are as recorded in the source files on 2026-09-03. A row is reproduced by opening the cited lines at that commit, and where a row names a script the command is the one the repository's README gives for it.

SectionClaimSource
11.1condition (A2), cosine satisfies it, post-rotary keys do not, the cone below cell sizeturboquant-pro\docs\KV_KEYS_FINDING.md:61-86; the-angular-observer\README.md:26-31
11.2fp16 12.24, values-only 13.12, PolarQuant K4 10643 and 0.095, per-channel uniform K4 14.91 and 0.062, per-channel NUQ K3 15.77 and 0.148, 2.4x and 670x, pre-rotary near 22000, 2 key heads serve 12 query headsturboquant-pro\docs\KV_KEYS_FINDING.md:1-49
11.2cosine 0.995turboquant-pro\README.md:86-88; turboquant-pro\CLAIMS.md row kv_keys_per_channel
11.2the calibration-time probe and the streaming monitorturboquant-pro\turboquant_pro\a2_probe.py:315-438; turboquant-pro\tests\test_a2_probe.py
11.3kappa as the max-over-min ratio in the strict setting, giving a guaranteed floor, and as the 97.5 over 2.5 percentile ratio in the percentile setting, giving a robust estimate; the vacuous verdictturboquant-pro\turboquant_pro\rank_certificate.py:88-130
11.3tau floor 1 minus 2 mu, Spearman floor 1 minus 3 mu, example kappa 1.0148, mu 0.0664, floor 0.8671, 19900 pairs, max certifiable 1.83, vacuous means exact rerank, sha256 binding, reference field and the 0.3 overlap differenceturboquant-pro\docs\CERTIFICATE_SPEC.md:1-80
11.3reference plugin, five conformance checks with one skip, affine contract and fused decodetqp-reference-plugin\README.md:41-75
11.40.999 against own ranking vs 0.592 against fp32 truth, three truth layers, difficulty strataopenvector-bench\README.md:60-96
11.4R80 table, 25x probe depth, 92 percent own cell, one third cross-article, 0.53 matches same-article share, relative contrast discriminates nothingopenvector-bench\results\R80_ANN.md:1-40; turboquant-pro\docs\RESEARCH_ROADMAP.md:133-160
11.59.6x at recall 0.999 CI-gated on GloVe 1.18M; 32x at 0.9993 on private 199k LaBSE, ties OPQ, beats RaBitQ, 20x build; 27.7x and 114x reported; PCA truncation loses on compact sets; 20x at 199k and 4x at 1M over OPQ; RaBitQ builds in under a secondturboquant-pro\CLAIMS.md:28-49
11.5CI fails when CLAIMS.md and claims.yaml disagreeturboquant-pro\CLAIMS.md:1-27; turboquant-pro\tests\test_claims_ledger.py
11.6count of ten, hubs and anti-hubs, max 78 vs 369, density correlation about 0.67, 8 percent vs 34 percent, abstain below 2.5k, centering vs mutual-proximity rescalingturboquant-pro\docs\HUBNESS_PRIMER.md:1-60,60-170
11.6query mass best single feature at every K for all four responses, seven features add at most 20 percent at 12 leaves, threshold 1.25 on three of four, zero of four, 1000 real queries, 1024 dimensionsopenvector-bench\results\R13_STAGE0_RESULT.md:40-50; openvector-bench\results\R13_STAGE1_RESULT.md:1-40
11.6anti-hub recall, p05, hub-rank correlation, hub-set overlap, the build gateturboquant-pro\docs\HUBNESS_PRIMER.md:86-131
11.6the centroid-injection attackturboquant-pro\docs\HUBNESS_PRIMER.md:168-197, citing arXiv 2604.05480
11.7k over d table 1, 2, 2, 16, 16, 16readscope\README.md:118-141; readscope\SPEC.md:243-285, record readscope\calibration\records\c2e-budget-law.json
11.7rank-independent, 0.646 vs 0.366 at half dimension, never 0.90 below k equals dreadscope\CALIBRATION.md:419-434 F-15
11.7C-15 equal budget, 3072 observations, medians 0.02, 0.11, 0.05, 0.04, 1.0, 1.0, margin 0.883 vs 0.3, 0.062 to 0.057 at 8xreadscope\SPEC.md:285-323, record readscope\calibration\records\c15-budget-surface.json, readscope\calibration\DECLARATION-C15.md
11.7confinement theorem, side information moves the cliff to d minus k0, noisy cliff proved then measuredreadscope\PRINCIPLES.md:112-142; geometric-observation\crucible\OT3-THEOREM.md; geometric-observation\crucible\OT3-NOISY-THEOREM.md
11.7124 cells at resolution 1.000 at k over d 1.25, five families, linearity partialreadscope\README.md:200-222
11.7GO-1 overlap 0.936 vs 0.059, flip 12 of 12, reconstruction 0.40geometric-observation\claims\LEDGER.md row GO-1; geometric-observation\chapters\ch10_the_blind_probe.md:34-52
11.80.765 to 0.971 with interval 0.190 to 0.223, 0.545 to 0.562 with interval 0.004 to 0.031, v1 0.340 with interval negative 0.214 to negative 0.081, anisotropy 0.570 to 0.259lebse\README.md:40-75; lebse\PAPER.md:1-15,60-66; lebse\MODEL_CARD.md:48-52
11.9drift at rank one 0.667 vs null 0.933, sixteen cellsreadscope\CALIBRATION.md:600-660 F-24; readscope\calibration\records\c11c-operator-drift.json
11.9C-12 four bars, 40 documents, 512 tokens, 13.4 point difference, teacher forcing removes it, negative 0.015 vs 0.005, Spearman negative 0.13 at p 0.45, sign test p 0.42, verdict FAIL, feedback compoundingreadscope\calibration\records\c12-longgen-drift-sym.json; readscope\calibration\DECLARATION-C12.md at commit 90e2ce2; readscope\SPEC.md:806-825

previous, Chapter 10. Outliers, hubs, and abstention  ·  next, Chapter 12. Text mining and retrieval-augmented pipelines