Log inStart free
LESSON 22.12 · 6 STAGES · 3 CONTROLS · 3 CHECKSPRO · PREVIEW

Product quantization

Watch 200 points shrink to 6-bit codes and still find their neighbors.


Pro lesson. Stage 1 is free to watch. Pro opens all 6 stages, 3 controls and 3 checks, in this lesson and every other.

Go Pro · $8.25/mo
EXPLAINER · 22.12 · INDEX BAY200 POINTS · 2 PARTS: X AND Y
01
Stage 1 of 6 · Split the vector
Product quantization splits each vector into parts. Here p62, nearest to the query q3, splits into x and y parts.
Explain it simply

Each dot is one stored vector, like the embedding of a document. Product quantization cuts every vector into parts. Here a part is one number: the x parts sit on the rug below, the y parts on the left. A real embedding of 768 numbers might split into 96 parts of 8.

200 teal points on a square. Dashed lines carry point p62 down to its x part and left to its y part.

points, parts, querycentroids, griderror, missedtables, resultsguides; ring: true 3 nearest
005050100100x party partp62 = (29.23, 27.16)x part 29.23x codebooky part 27.16y codebookevery point splits the same way: 200 × 2 parts200 points, 2 parts eachone point, splitp62 = (29.23, 27.16) → x part 29.23 · y part 27.16005050100100x party partp62 = (29.23, 27.16)x part 29.23x codebooky part 27.16y codebookevery point splits the same way: 200 × 2 parts200 points, 2 parts eachone point, splitp62 = (29.23, 27.16) → x part 29.23 · y part 27.16
Toy: 200 2-D points and 5 queries, shared with 22.C2
STAGE 1 / 6
MATH · STAGE 1HOVER A SYMBOL OR A SHAPE
x=(x(1), x(2))\sy{x}{data}{x} = (\sy{x}{data}{x^{(1)}},\ \sy{x}{data}{x^{(2)}})
p62=(29.23,27.16)p_{62} = (29.23, 27.16)

Each vector splits into an x part and a y part.

Common mix-ups

MYTHThe PQ score is each point's true distance.

The fix, and 1 more mix-up with the diagram to show them, come with Pro.

Predict, then reveal
3 CHECKS · PRO
Q01At q3 with 8 centroids per part, does a rerank of the best 10 find all 3 true nearest?

Make your guess, then test it in the diagram. All 3 checks come with Pro.

PRO LESSON · YOU WATCHED STAGE 1 OF 6
Unlock the full explainer
  • 5 more stages and 3 live controls
  • 2 mix-up cards and 3 predict-then-reveal checks
  • Watch it as a narrated video, in three voices
  • Every Pro lesson and capstone · 656 in total

$99 a year, or $15 a month. Cancel any time.