Compress embedding vectors 5-8x with 98%+ search accuracy using TurboQuant (Google, ICLR 2026).
bash
python3 scripts/turboquant.py
15 built-in tests: FWHT correctness, MSE distortion, IP correlation, recall, compression ratio, determinism.
bash
python3 scripts/validate.py --db /path/to/memory.sqlite --auto-detect --bits 5
Auto-detects sqlite-vec vec0 tables, analyzes distribution, reports quantization quality and recall.
bash
python3 scripts/memory_quantize.py --db /path/to/memory.db --bits 5 --benchmark
python3 scripts/memory_quantize.py --db /path/to/memory.db --bits 5 --migrate
python
from turboquant import TurboQuantMSE
# Initialize (deterministic — same seed = same quantization)
tq = TurboQuantMSE(dim=3072, bits=5)
# Quantize for storage
stored = tq.quantize(embedding_vector) # float32 → compressed
# Reconstruct
reconstructed = tq.dequantize(stored) # compressed → float32
# Search: query stays float32, database is quantized
q_rot = tq.rotation.apply(query)
for doc in database:
score = doc['norm'] * doc['scale'] * np.dot(q_rot, tq.codebook[doc['indices']])
PresetModeBitsR@1CompressionUse CaseDefaultMSE5****98%****6.4xMost memory/RAG searchConservativeMSE698%+5.3xHigh-fidelity retrievalAggressiveMSE492%8.0xLarge-scale, storage-constrained
ParameterDefaultDescriptiondimauto-detectEmbedding dimension (768, 1536, 3072, etc.)bits5Bits per coordinate. See table above.seed42Rotation seed. Same seed = reproducible quantization.
Blockwise Hadamard Rotation → Lloyd-Max Scalar Quantization
Key properties:
See references/algorithm.md for full details.
BitsMSECosineR@1R@5R@10Bytes/vecCompression31.1e-50.98288%90%91%1,16010.6x43.2e-60.99592%93%93%1,5448.0x58.2e-70.999****98%****96%****96%1,9286.4x62.2e-71.00096%98%98%2,3125.3x78e-81.000100%98%99%2,6964.6x83e-81.00098%98%99%3,0804.0x
vec0 tables (auto-detected)