Zenaique

Match each vector compression scheme to its core mechanism.

Match pairs·Medium·4.0 · 0·~2 min·Asked atDeloitteMeeshoQdrant·Relevant atMicrosoftNVIDIA
Attempt it

Drag each answer to line up with its matching prompt

PQ (Product Quantization)

Reduce each dimension to a single sign bit; distance becomes popcount(XOR) over packed bitstrings

OPQ (Optimized PQ)

Learn a rotation matrix that decorrelates dimensions before PQ encoding, lowering quantization error at the same byte budget

SQ (Scalar Quantization)

Per dimension uniform bucketing of float32 values into 8-bit (or 4-bit) integers, simple, no training

BQ (Binary Quantization)

Split vector into sub-vectors; each sub-vector becomes a 1-byte index into a learned per subspace codebook

TL;DR

PQ splits the vector and looks up per-subspace codebook entries. OPQ rotates first, then runs PQ. SQ bucket-rounds each dim to 8 or 4 bits. BQ keeps only the sign bit per dim and uses popcount(XOR) as distance.

Memory aid
Sign in to see the mnemonic that makes this stick.
Easy to grasp

Imagine you have a thousand-number recipe card and you need to fit a million of them in a single shoebox. **PQ** chops the card into chunks and replaces each chunk with a tiny sticker from a sticker book the library invented. **OPQ** is the same trick, but first the cards are shuffled into a friendlier order so the stickers fit even better. **SQ** keeps the same layout but rounds every number to the nearest of 256 (or 16) shades of gray. **BQ** is the most brutal: it only records whether each number was positive or negative, packing the whole card into a bracelet of beads where each bead is just one bit. You lose detail, but comparing two bracelets is almost free.

Key concepts

Concept explanation~2 min read

Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.

Vector quantization is the lever that turns 'we cannot afford this index' into 'this fits on a single machine.' All four schemes in this question reduce storage and accelerate distance computation, but they do it through fundamentally different mechanisms. Mixing them up signals a candidate who has read the headlines but never built a billion-scale index.

The right mental model: PQ and OPQ are a family (codebook based, learned, sub-space structured). SQ and BQ are a different family (per-dimension, deterministic, no training). The match-pairs question rewards seeing that split before pairing each scheme to its mechanism description.

PQ: split, learn codebooks, look up

Product Quantization was introduced by Jegou, Douze, and Schmid in 2011 and is still the foundation of every billion-scale ANN deployment. The mechanism in three steps. First, choose pq_m, the number of sub-spaces. A 1024-dim vector with pq_m = 16 splits into 16 sub-vectors of 64 dims each. Second, for each sub-space position run k-means with 256 centroids over a training sample of the corpus, producing 16 codebooks of 256 sub-vectors each. Third, encode every database vector as 16 bytes: one byte per sub-space, holding the codebook index of the closest centroid.

The payoff lives at query time. For a query, compute the squared distance from the query's sub-vector to each of the 256 centroids in each sub-space. That gives a 16 x 256 lookup table per query. To compare the query against any database vector, sum 16 table lookups, one per sub-space. The per-vector distance computation drops from 1024 float multiply-accumulates to 16 table lookups. Storage drops from 4096 bytes to 16 bytes per vector.

Recall cost is real but bounded. A typical billion-scale IVF-PQ deployment with pq_m = 32 lands around recall 0.85 to 0.90 against Flat ground truth. Two-stage re-ranking on the top candidates closes most of the gap.

OPQ: rotate first, then PQ
SQ: the no-training default
BQ: one bit per dimension, popcount as distance
Sign in to unlock the full deep dive.

Situations where this technique stops working.

Sign in to see when this approach fails.

2–4 min · Everything important, quickly.

Sign in to see the quick scan of the deep dive.
SchemeBytes/vec (1024-dim)Training neededDistance kernelRecall hit
PQ (pq_m=16)16Yes (codebook per subspace)Sum of 16 table lookupsModerate
OPQ (pq_m=16)16Yes (rotation + codebook)Rotate, then PQ lookupLower than PQ at same size
SQ-int81024Noint8 SIMD dot productTiny
BQ128No (assumes zero-centered)popcount(XOR)Largest of the four

Real products, models, and research that use this idea.

  • Faiss ships PQ, OPQ, SQ, and binary indexes as separate index factories. The 'IVF65536,OPQ32_64' string is the canonical billion-scale recipe at Meta and inside Milvus.
  • Qdrant exposes scalar quantization (int8 and int4) and binary quantization as per-collection toggles in 2026; users rarely build PQ by hand because the SQ and BQ options cover most cost-sensitive cases.
Sign in to see more production examples.

What an interviewer would ask next. Try answering before peeking at the approach.

QWhy does OPQ's learned rotation help at the same byte budget?
A

Variance across sub-spaces becomes more uniform, so the 256-centroid budget per sub-space is spent more evenly. Quantization error drops.

2 more follow-ups an interviewer would ask next. Sign in to reveal them.

Red flags & common mistakes

The phrases that signal junior thinking. Click to expand.

Most common mistake

Treating SQ and PQ as the same family. SQ buckets each dimension independently; PQ groups dimensions into sub-spaces with a learned codebook per sub-space. Different objects, different recall behavior.

Sign in to see all red flags and common mistakes.

60 second bullets to scan on the way to the call.

  • Why PQ needs a codebook and SQ does not

  • What problem OPQ solves over plain PQ (anisotropic variance)

Sign in to unlock the revision sheet.

Primary sources. Browse if you want the original framing.

Similar questions

Same topic, related formats. Practice these next.

4 curated
Next question
HNSW vs IVF, when…
Flashcard·Medium