The library

Be able to say what it means for two things to be close, choose the right measure for a given set of vectors, and know what goes wrong with all of these measures when the number of dimensions is large

Vectors, Distance and Similarity

Search, recommendation and retrieval all rest on one idea: turn things into lists of numbers and ask which are near. This course covers length, distance, the dot product, the angle, and what high dimensions do to all of them.

8 lessons, written and corrected before you arrived. Reading them here needs no account. The first reads the whole way through; the others open and then stop. Starting the course gives you your own copy, where every idea has problems standing under it and you can ask about any sentence.

Start reading

  1. 01The Same List, Read Two WaysA vector is a list of numbers, and everything interesting comes from agreeing to read that list as a position in space or as a direction with a length.
  2. 02Straight Lines and City Blocksopening onlyThe length of a vector is the square root of the sum of its squared coordinates, the distance between two is the length of their difference, and there is more than one reasonable way to measure both.
  3. 03Multiply, Add, and Get an Angleopening onlyMultiply two vectors coordinate by coordinate and add the results. That one number turns out to encode the angle between them, which is why it appears in almost every similarity calculation.
  4. 04Dividing the Lengths Outopening onlyDivide the dot product by both lengths and what is left is the cosine of the angle, a similarity between minus one and one that ignores how long either vector is.
  5. 05When Distance and Angle Become the Same Questionopening onlyGive every vector unit length and the two families of measure stop competing: straight-line distance and the angle then rank every pair in exactly the same order.
  6. 06Everything Is Far Away and Nothing Is Nearbyopening onlyIn a space with hundreds of coordinates, distances between unrelated points stop varying much and almost every pair of directions is close to perpendicular. Both facts have consequences.
  7. 07The Cost of Asking What Is Nearbyopening onlyComparing 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.
  8. 08Which Question Are You Actually Askingopening onlyDistance, dot product and angle disagree about which pairs are close. The choice follows from one question about your data and one about how the vectors were produced.