Scalar quantization
Round each coordinate on its own. It needs no training, it is what most vector databases ship, and one small formula explains both why it works and where it stops.
1Rounding with a step
Pick a step size and round each coordinate to the nearest multiple of it. With bits you get levels.
If the step is small compared with the spread of the data, the rounding error is spread evenly between and . The variance of a uniform distribution of width is
Slide the bits, then the clip range With few bits you must choose: a wide range wastes levels on values that almost never occur, a narrow one clips the tails (red). Press best c to see the compromise move outward as bits are added.
Two more things to notice in the readout:
- The output’s entropy is below . The middle levels are used far more than the outer ones. An entropy coder could store the same indices in fewer bits, which is layer 4 of the stack.
- is accurate from about 3 bits up. Below that the “small step” assumption fails.
2The three you will meet
| Name | Bits per coordinate | Size of a 384-d vector | Training | Typical use |
|---|---|---|---|---|
| float32 | 32 | 1,536 B | none | the model’s output |
| float16 | 16 | 768 B | none | storage; almost no loss |
| int8 | 8 | 384 B | a min and max | the default “quantized” option in vector DBs |
| int4 | 4 | 192 B | per-coordinate ranges | when RAM is tight |
| binary | 1 | 48 B | none | first-pass filter with re-ranking |
At 8 bits the top-10 lists are almost untouched. At 1 bit, recall without re-ranking is poor, yet 5.4 Bits as a compressed sketch shows the same bits are an excellent shortlist generator.
3Where it stops
Scalar quantization treats every coordinate alone, so it is blind to two things:
- Correlation between coordinates. Each coordinate’s range is coded as if the others told you nothing. A rotation first (3.4 From spectrum to bit budget) fixes the linear part of that.
- The floor of one bit. There is no way to give a coordinate a third of a bit. Marginalia’s index budget is 16 bytes for 384 dimensions: 0.33 bits per dimension.
To spend less than one bit per coordinate, you have to stop quantizing coordinates and start quantizing vectors.