Vector indexes: recall traded for latency
An embedding maps text into a vector such that related meanings land near each other. Retrieval is then nearest-neighbour search, and the honest way to think about a vector index is as an index in Tier 3's sense: a structure that makes one access pattern fast and carries costs everywhere else.
The word doing the work is "approximate"
Exact nearest-neighbour search compares the query against every stored vector. That is a full scan — fine at a hundred thousand vectors, hopeless at a hundred million. So production systems use approximate nearest neighbour, and the approximation is the entire subject:
An ANN index returns most of the true nearest neighbours, most of the time, and every one of them exposes a dial between "fast and misses things" and "thorough and slow".
That dial has a default. The default was chosen by someone who did not know your corpus. Almost nobody measures where theirs is set, which leads to the most consequential number in this lesson:
A retrieval layer at 70% recall puts a hard 30% ceiling on your system's correctness that no amount of prompt engineering will lift. The passage was never in the prompt. The model is not the problem.
Recall is measurable, and cheaply: take a sample of real queries, compute the true nearest neighbours by brute force offline, then measure what fraction your production index actually returns at its production settings. That is an afternoon's work and it is the difference between tuning a system and guessing at one.
The index families, at design altitude
- Graph-based (HNSW). A navigable graph where search walks from node to neighbour toward the query. The strongest recall-per-millisecond available, and the memory-hungriest — the graph itself is large. Supports insertion, but the structure degrades as the corpus shifts, so a periodic rebuild is part of owning one.
- Partition-based (IVF). Cluster the space, then search only the nearest few clusters. Far cheaper in memory, with an obvious dial (how many clusters to probe). The catch is that the partitioning is trained on a sample, so a corpus that drifts away from that sample quietly loses recall.
- Quantisation. Compress each vector to fewer bits, trading precision for size. Usually layered on top of the above, and the reason a billion-vector index fits on hardware you can afford. Precision loss is real and shows up as recall loss.
Memory is the binding constraint here just as it was in 11.01, and the estimate is Tier 0 arithmetic: count × dimensions × bytes per value, plus index overhead. Ten million vectors at 1,024 dimensions in four-byte floats is about 40 GB before the index structure. Do that multiplication early — it is usually larger than the intuition that preceded it.
Filtering is the hard part, not search
"Nearest neighbours where tenant = X and status = active" sounds like a footnote and is the thing that breaks first. Two obvious approaches, both flawed:
- Filter first, then search. Correct, but a graph index navigates by following neighbours — remove most nodes and the graph fragments, so the walk cannot reach regions it should.
- Search first, then filter. Fast, and it can return almost nothing: ask for fifty neighbours, discover forty-eight belong to other tenants, and hand the model two passages while reporting success.
That second failure mode is the dangerous one, because it does not error — it silently returns too few results, and the answer quality degrades in a way that looks like a model problem. Check how your chosen index handles constrained search before you build multi-tenancy (12.04) on top of it, and test it with a selective filter rather than a permissive one.
Changing the embedding model is a full rebuild
Vectors from two different embedding models do not live in the same space and cannot be compared or mixed in one index. So upgrading the model means re-embedding the entire corpus and cutting over — which is Lesson 7.04's read-model rebuild, over a corpus where the recompute has a per-document cost. Plan it as a project with a dual-index window, not as a config change, and know the number before someone proposes the upgrade in a meeting.
Do you need a separate vector database?
Often not, and the reasoning is 4.06's. A relational database with vector support handles millions of vectors comfortably, keeps embeddings transactionally consistent with the rows they describe, and — the part that matters most — is not another copy to synchronise, secure, back up and erase from. A dedicated vector store earns its place when scale, filtering behaviour or hybrid-search features genuinely demand it. "We are doing AI" does not demand it.
Reading similarity scores as confidence. They are not calibrated, they are not comparable between queries, and a threshold tuned on one corpus is meaningless on another — a 0.83 top result tells you almost nothing about whether that passage answers the question. Teams build "if the score is below 0.7, say I don't know" and ship a system that refuses good answers and confidently returns bad ones. If you need a relevance decision, get it from a reranker that was trained to make one, and calibrate the threshold against labelled data rather than intuition.