29/35
Part 6 of 6 · A worked example and follow-upsLearn and do

Novelty against the training set is exact, and costs about 85 dollars

Compare each of the billion pile images with a reference set of, say, 10 million training images. By brute force that's 109×107=101610^9 \times 10^7 = 10^{16} dot products at 768 dimensions:

1016×768×2≈1.5×1019 operations10^{16} \times 768 \times 2 \approx 1.5 \times 10^{19} \text{ operations}

At 100 TFLOPS that's 1.5×1051.5 \times 10^5 seconds, about 43 GPU-hours, roughly $85. It's exact, with no index to tune and no recall lost. It's tempting to assume billion-scale search needs approximation. This one doesn't.

Density within the pile: probe an index, or count in a 1% sample

Every image against every other image is 101810^{18} dot products, about 4,300 GPU-hours by brute force.

An inverted file cuts that. With 2202^{20} lists, each list holds about 954 vectors. Probing 64 lists scans about 61,000 vectors per query instead of a billion, about 16,000 times fewer. The Faiss paper reports results at this scale: a high-accuracy k-NN graph on 95 million images in 35 minutes, and a graph over 1 billion vectors in less than 12 hours on 4 Maxwell Titan X GPUs.

There's a cheaper move. A density floor doesn't need exact neighbors among a billion images. Count neighbors within a radius among a uniform 1% sample, 10 million images, and multiply by 100. That costs the same 43 GPU-hours as the novelty search, and the two can share one pass.

Semantic dedup and clustering, from earlier, take minutes to under an hour each.

In the editor, write brute_force_hours(queries, refs) and ivf_scanned(n, lists, probes). The last line prices the billion against 10 million novelty search, and the inverted file that probes 64 of its 1,048,576 lists.