ContentsThe library

Vectors, Distance and Similarity

The Cost of Asking What Is Nearby

Last timeWhere Intuition Stops Working

Comparing a query against every stored vector is exact and grows with the size of the collection. Every fast alternative gives up the guarantee of exactness in exchange, and the trade is measurable.

Everything up to here has been about comparing two vectors. Retrieval is about

comparing one against millions, which is a different problem, and the difference

is entirely about cost.

What the honest answer costs

Compare the query against every stored vector, keep the best few. This is exact,

simple, easy to get right, and the cost is linear in the size of the collection.

FIG 1Exhaustive search, at three collection sizes
vectors storedmultiplications per quercost relative to the fir
ten thousand vectors1000030000001
a million1000000300000000100
a hundred million1000000003000000000010000
Three hundred coordinates per vector throughout. The first row is nothing at all and the second is a few tens of milliseconds, which sounds acceptable until it is multiplied by the number of queries per second. The third is where exhaustive search stops being an option.

Two things are worth saying before moving on. First, exhaustive search is

underrated: at ten thousand or a hundred thousand vectors it is fast, exactly

correct, trivial to maintain and has no parameters to tune. Second, it

parallelises perfectly, so a large machine moves the threshold further out than

people expect.

The lesson stops here

5 more paragraphs to go

You have read the opening. The rest of the argument, the problems that check whether it landed, and the lines worth keeping at the end all come with a plan.

The first lesson of every course in the library reads the whole way through, free, so you can see exactly what the rest of them are.

See the planThe contents

This is the reading half

Starting the course gives you your own copy of it. Every idea on every page has problems standing under it, marked with a reason rather than a tick, and any sentence you do not believe can be opened and argued with. None of that can happen on a page nobody owns.

The contents

The rest of this course

  1. 01The Same List, Read Two Ways
  2. 02Straight Lines and City Blocksopening only
  3. 03Multiply, Add, and Get an Angleopening only
  4. 04Dividing the Lengths Outopening only
  5. 05When Distance and Angle Become the Same Questionopening only
  6. 06Everything Is Far Away and Nothing Is Nearbyopening only
  7. 07The Cost of Asking What Is Nearbyyou are here
  8. 08Which Question Are You Actually Askingopening only

Read alongside