11Binary (B1) storage precision: a 32× smaller vector payload, a rescore obligation that isn’t optional
Verbs: the fourth storage_precision — binary (usearch’s B1 scalar kind, one packed sign bit per dimension, searched by Hamming distance rather than cosine) — set through jammi.connect(..., config=...) · the same retrieve→rescore path f16/int8 use, but resolved at binary’s own precision-specific default oversample of 32 (vs. 4 for every other precision) when the deployment leaves the knob unset · Background: HNSW as the navigable proximity graph every precision’s sidecar is built over (Malkov and Yashunin 2020), the recall-vs-memory trade quantization buys (Johnson, Douze, and Jégou 2021) · Checked: measurement (recall@1 and recall@10 against the engine’s exact search, the sidecar’s on-disk byte count — decomposed into its vector payload and its HNSW link overhead — and an independent numpy replay of the raw sign-bit Hamming ranking with no rescore at all; every number measured live).
The preceding chapter measured f16/int8: both shrink the sidecar’s own stored vectors while leaving the retrieve→rescore default (oversample = 4) untouched, and both recover the exact f32 baseline’s recall at that default. binary is the fourth point on the same storage_precision axis, and it is not a smaller step in the same direction — it is a much bigger one. Packing each dimension down to a single sign bit is the most aggressive quantization the sidecar offers: 1 bit per dimension against f32’s 32, a full 32× smaller vector payload, searched by Hamming distance (a bit count) instead of cosine similarity. That coarseness buys a large memory win on the structure a search actually traverses, but — measured below — the sidecar file’s own total size shrinks by materially less than 32×, because an HNSW graph also carries per-node link overhead that has nothing to do with how the vectors themselves are stored, and that overhead does not shrink with storage_precision at all. The aggressive quantization also means the retrieve stage’s own ranking is far noisier than int8’s — so binary needs its own, much wider default oversample to let the exact-f32 rescore recover the answer at all. This chapter measures both halves of that trade honestly: the vector payload really does shrink 32×, the whole graph file shrinks by a real but smaller factor once link overhead is counted, and the default oversample of 32 really is load-bearing, not a conservative buffer — turn it down towards 1 and recall collapses, because the retrieve stage no longer offers the rescore stage enough real candidates to recover from.
11.1 The corpus, the oracle, and the tables
The same corpus the preceding chapter measures: the papers embedded once, held-out queries, and the engine’s exact search as the ground truth — both the true top-k and its own top-1. Every table imports the same vectors.
2026-10-03T07:43:22.078200Z WARN jammi_kernels::admission: fused-kernel domain check failed; falling back to the eager composition op="attention_block_fused" predicate="head_dim_is_attention_block_fixed_head_dim"
11.3binary with the knob left unset — does the default land on 32?
A deployment that sets storage_precision = "binary" and never touches oversample must get binary’s own default of 32, not the 4 every other precision falls back to. On ONE table built with no oversample key at all, the search with no override and the search with an explicit per-request 32 must be the same search.
claim("an unset oversample resolves to binary's own default of 32", (default_at_1, default_at_10) == (explicit_at_1, explicit_at_10))claim(f"rescored at that default, binary keeps f32's recall@{K} to within two points", default_at_10 >= f32_at_10 -0.02, f"{default_at_10:.4f} against {f32_at_10:.4f}")
✓ an unset oversample resolves to binary's own default of 32
✓ rescored at that default, binary keeps f32's recall@10 to within two points (1.0000 against 1.0000)
11.3.1 The whole graph file is not 32× smaller
One bit per dimension against f32’s 32 shrinks the vector payload exactly 32×. But an HNSW sidecar also stores each node’s links — the navigable connectivity a search walks (Malkov and Yashunin 2020) — and that overhead is a property of the graph’s topology, not of how each vector is stored. Subtracting the analytic vector payload from each measured file isolates it:
rows =len(corpus.corpus_ids)payload_f32 = rows * corpus.dims *4payload_binary = rows * ((corpus.dims +7) //8)links_f32 = f32_usearch - payload_f32links_binary = binary_bytes["usearch"] - payload_binaryprint(f"{'':>8}{'vector payload':>16}{'link overhead':>16}{'file':>14}")print(f"{'f32':>8}{payload_f32:>16,}{links_f32:>16,}{f32_usearch:>14,}")print(f"{'binary':>8}{payload_binary:>16,}{links_binary:>16,}{binary_bytes['usearch']:>14,}")print(f"payload ratio {payload_binary / payload_f32:.4f} — the 1-bit-vs-32-bit packing, exactly")print(f"file ratio {graph_ratio:.4f} — what a deployment keeps resident")
vector payload link overhead file
f32 46,080 53,992 100,072
binary 1,440 53,992 55,432
payload ratio 0.0312 — the 1-bit-vs-32-bit packing, exactly
file ratio 0.5539 — what a deployment keeps resident
claim("the vector payload shrinks exactly 32×", abs(payload_binary / payload_f32 -1/32) <1e-9)claim("the graph file shrinks by less, because the links do not shrink with precision", payload_binary / payload_f32 < graph_ratio <1, f"file ratio {graph_ratio:.4f}")
✓ the vector payload shrinks exactly 32×
✓ the graph file shrinks by less, because the links do not shrink with precision (file ratio 0.5539)
“Binary is 32× smaller” is true of the vectors inside the graph; the file shrinks by the measured, smaller factor above, because the links do not shrink at all. The smaller the vectors, the larger the links’ share: at a real embedding’s hundreds of dimensions the payload still dominates an f32 graph, at the fixture encoder’s 32 the links already weigh as much. And, as for int8, a quantized table also writes the .rawf32 rescore companion — the exact vectors, which do not shrink with storage_precision at all.
11.4binary without rescore — an independent floor
binary always rescores: there is no knob, public or internal, that returns a raw Hamming ranking as a search answer. To show why, numpy ranks the whole corpus by the Hamming distance of a naive fixed-0 sign code — bit = 1 iff the coordinate is positive — with no rescore. (The engine’s own code fits a per-dimension threshold instead; the next chapter measures that fit.)
corpus_bits = corpus.vectors >0hits_at_1, overlap_at_10 =0, 0.0for q, truth inzip(corpus.queries, corpus.exact): ranked = np.argsort(((q >0) != corpus_bits).sum(axis=1), kind="stable") ids = [corpus.corpus_ids[j] for j in ranked[:K]] hits_at_1 += ids[0] == truth[0] overlap_at_10 +=len(set(ids) &set(truth)) / Khamming_at_1 = hits_at_1 /len(corpus.queries)hamming_at_10 = overlap_at_10 /len(corpus.queries)print(f"raw Hamming, no rescore: recall@1 {hamming_at_1:.4f} recall@{K}{hamming_at_10:.4f}")print(f"engine, rescored at the default: recall@1 {default_at_1:.4f} recall@{K}{default_at_10:.4f}")
raw Hamming, no rescore: recall@1 0.0000 recall@10 0.0375
engine, rescored at the default: recall@1 0.7000 recall@10 1.0000
claim("the engine's rescore recovers what the raw Hamming ranking loses", hamming_at_1 < default_at_1 and hamming_at_10 < default_at_10,f"recall@{K}{default_at_10:.4f} against {hamming_at_10:.4f}")
✓ the engine's rescore recovers what the raw Hamming ranking loses (recall@10 1.0000 against 0.0375)
A single sign bit per dimension, ranked by raw Hamming distance, is a coarse ranking; the engine never returns it, and measuring it independently is what makes the sweep below legible: oversample is not tuning a small correction, it is how much of that coarse ranking the exact rescore gets to repair.
11.5 Dialing oversample — binary needs a wider recovery than int8
The retrieve stage proposes k * oversample Hamming candidates for the exact rescore; a true neighbour outside the candidate set cannot be recovered. Five otherwise-identical binary tables, each stamped at an explicit oversample:
GRID = [1, 4, 8, 16, 32]sweep = {}for ov in GRID:with precision.built(corpus, "binary", ov) as (db, _): sweep[ov] = (precision.recall(db, corpus, k=1), precision.recall(db, corpus))print(f"{'oversample':>10}{'candidates':>12}{'recall@1':>11}{'recall@10':>11}")for ov in GRID:print(f"{ov:>10}{K * ov:>12}{sweep[ov][0]:>11.4f}{sweep[ov][1]:>11.4f}")
claim("a narrow candidate set loses true neighbours", sweep[1][1] < sweep[32][1],f"recall@{K}{sweep[1][1]:.4f} at 1, {sweep[32][1]:.4f} at 32")claim("widening the candidate set never loses recall",all(sweep[a][1] <= sweep[b][1] for a, b inzip(GRID, GRID[1:])))
✓ a narrow candidate set loses true neighbours (recall@10 0.3425 at 1, 1.0000 at 32)
✓ widening the candidate set never loses recall
Unlike int8, whose recall reached the exact baseline by the shared default of 4, binary’s keeps climbing well past it: the coarser the retrieve ranking, the more candidates the rescore needs to see. That is why binary’s own default is 32 — the point on this curve where widening further stops buying recall.
11.6 The per-request override — search(..., oversample=...)
On the table stamped at oversample=1, the same queries with a per-request oversample=32:
with precision.built(corpus, "binary", 1) as (db, _): narrow = precision.recall(db, corpus) widened = precision.recall(db, corpus, oversample=32)print(f"table default (1): recall@{K}{narrow:.4f}")print(f"per-request override to 32: recall@{K}{widened:.4f}")
claim("a per-request 32 is the same search as a table default of 32", widened == sweep[32][1])claim("and it recovers what the table's own default of 1 lost", widened > narrow,f"recall@{K}{widened:.4f} against {narrow:.4f}")
✓ a per-request 32 is the same search as a table default of 32
✓ and it recovers what the table's own default of 1 lost (recall@10 1.0000 against 0.3425)
The override recovers, on the same on-disk graph and with no rebuild, the recall a wider table default gives — reachable from search’s own keywords at binary precision too.
11.7 Bridge note
The biggest quantization step needs the widest recovery, and rescore is what makes that honest. HNSW (Malkov and Yashunin 2020) gives approximate search its speed by navigating a proximity graph instead of scanning every vector; binary pushes the accuracy-for-memory trade (Johnson, Douze, and Jégou 2021) to its most aggressive point on this axis — one packed sign bit per dimension, ranked by Hamming distance, a vector payload a full 32× smaller than f32’s. Measured here: that 32× is real for the payload, but the whole graph file shrinks by a smaller, still-real factor, because a fixed per-node link-overhead cost (the topology HNSW itself needs, independent of how each node’s vector is stored) does not shrink with storage_precision — so “binary is 32× smaller” is a claim about the vectors inside the graph, not the graph file a deployment actually keeps memory-resident. And the raw, un-rescored Hamming ranking really is close to useless on its own — but the engine never ships that number, because needs_rescore() is unconditional for binary. What the deployment default buys is not “32× cheaper, free” — it is “a much smaller vector payload inside the same graph topology, with recall recovered by a mandatory exact rescore at an oversample wide enough to still find the true neighbours in the coarse candidate set,” measured here at the engine’s own default of 32 where an untouched deployment lands exactly there, not at the shared 4 every other precision uses. Both the deployment-default storage_precision = "binary" and the per-request oversample override are reachable from the same public jammi.connect / search surface every other chapter in this book writes against.
Johnson, Jeff, Matthijs Douze, and Hervé Jégou. 2021. “Billion-Scale Similarity Search with GPUs.”IEEE Transactions on Big Data 7 (3): 535–47.
Malkov, Yu A., and Dmitry A. Yashunin. 2020. “Efficient and Robust Approximate Nearest Neighbor Search Using Hierarchical Navigable Small World Graphs.”IEEE Transactions on Pattern Analysis and Machine Intelligence 42 (4): 824–36.