Match each vector-compression scheme to its core mechanism.
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.
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.
Detailed answer & concept explanation~5 min readEverything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example. Click to expand.
Everything you need to truly understand this topic: intuition, mechanics, step by step explanation, code, formulas, and worked example.
Everything important, quickly.
4 min: PQ codebook mechanism + OPQ rotation fix + SQ uniform bucketing + BQ sign bit and popcount + how each composes with IVF or HNSW + 2026 vendor defaults.
| Scheme | Bytes/vec (1024-dim) | Training needed | Distance kernel | Recall hit |
|---|---|---|---|---|
| PQ (pq_m=16) | 16 | Yes (codebook per subspace) | Sum of 16 table lookups | Moderate |
| OPQ (pq_m=16) | 16 | Yes (rotation + codebook) | Rotate, then PQ lookup | Lower than PQ at same size |
| SQ-int8 | 1024 | No | int8 SIMD dot product | Tiny |
| BQ | 128 | No (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.
- Cohere's binary embeddings (released 2024) are specifically trained so that BQ over them keeps recall above 0.95, making BQ a first-class production option, not a research curiosity.
- Pinecone's compressed serverless tier uses a PQ variant under the hood; users do not see the algorithm name but pay the lower per-vector storage rate.
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?
QHow would you decide pq_m for a 1024-dim corpus targeting recall 0.95?
Don't say thisRed flags and common mistakes that signal junior thinking. Click to expand.
Red flags and common mistakes that signal junior thinking. Click to expand.
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.
The night-before-the-interview bullets. Scan these on the way to the call.
Primary sources. Skim if you want the original framing.
Same topic, related formats. Practice these next.