RAG
Vector quantisation & storage maths
float32 → int8 → binary, product quantisation, and why a billion vectors is a budgeting problem.
What it is and why it exists
Raw storage is vectors × dims × bytes. Scalar quantisation (int8) cuts 4×, binary 32×, product quantisation splits vectors into sub-vectors and stores code-book IDs. Quality drops a little; rescoring the top candidates with full vectors recovers most of it.
Quick prototype
float32 everything.
In production, at scale
Quantised index for the first pass, full-precision rescoring of the top few hundred, fewer dimensions where the model allows, and a storage + RAM estimate per tenant before launch.
Vendors and tools
| FAISS PQ / OPQ | Product quantisation |
|---|---|
| Qdrant / Weaviate / Milvus | Scalar and binary quantisation |
| pgvector halfvec / bit | Half-precision and binary vectors |
On AWS: OpenSearch supports byte and binary vectors and quantisation; S3 Vectors targets low-cost storage.
How it fails
- Binary quantisation on a model that wasn’t trained for it
- Forgetting HNSW graph overhead in RAM estimates
What the interviewer asks next
How much RAM for 10M chunks at 1,024 dims in float32?
10M × 1,024 × 4 B ≈ 41 GB for vectors alone, plus graph links. int8 brings vectors to ~10 GB; binary to ~1.3 GB.