File size: 1,142 Bytes
f2c824d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | # Binary Hamming + Int8 Rescore Vector Retrieval Benchmark
Clean, standalone C + Python reproduction benchmark accompanying SpecStream's engineering paper:
**"Millisecond semantic retrieval over 47 million Wikipedia paragraphs in 6 GB of RAM"**
Canonical paper: https://specstream.ai/blog/millisecond-semantic-retrieval-47m-wikipedia-6gb-ram
## What this benchmark demonstrates
At 47,018,430 paragraphs x 1,024 dimensions (`BAAI/bge-m3`, from `Upstash/wikipedia-2024-06-bge-m3`):
- Raw `float32`: 192.59 GB (179.36 GiB)
- Stage 1 binary sign bits (`128 B/vec`, 16 x `uint64_t` little-endian): **6.018 GB (5.605 GiB)**, 32x RAM compression, `mlock()` pinned in RAM
- Stage 2 scalar `int8` (`1,024 B/vec`, `clip(round(v * 127), -127, 127)`): **48.147 GB (44.840 GiB)**, `mmap()` on local NVMe, read only for the top `cand` Hamming candidates (default 3,000 = 3.07 MB read per query)
## Build and run
```bash
make
python3 bench.py --n 1000000 --dim 1024 --cand 3000 --k 10 --queries 20
```
Set `--n` to match available RAM (1,000,000 vectors = 128 MB binary + 1 GB int8; 10,000,000 vectors = 1.28 GB binary + 10 GB int8).
## License
MIT
|