Vector Engine
The vector engine powers semantic search — nearest-neighbor retrieval over high-dimensional embeddings. It uses a custom HNSW index with multiple quantization levels and hardware-accelerated distance math.
When to Use
- Semantic search over embeddings (text, images, audio)
- RAG pipelines for AI agents
- Recommendation systems
- Similarity matching and deduplication
Key Features
- HNSW index — Multi-layer proximity graph. Construction at full precision (FP32/FP16) for structural integrity; traversal on quantized payloads for cache residency.
- Quantization — SQ8 (~4x memory reduction), PQ (~4-8x), IVF-PQ (~16 bytes/vector for 100M+ datasets).
- Adaptive pre-filtering — Roaring Bitmap-based filtering. Automatic strategy selection: pre-filter (selective), post-filter (broad), or brute-force.
- Distance metrics — L2, cosine, inner product, Manhattan, Chebyshev, Hamming, Jaccard, Pearson.
- Cross-engine fusion — Combine with graph (GraphRAG), full-text (hybrid BM25+vector), or spatial filtering.
SQL Usage
-- Create a collection with a vector index
CREATE COLLECTION articles;
CREATE VECTOR INDEX idx_embed ON articles METRIC cosine DIM 384;
-- Insert with embedding
INSERT INTO articles { title: 'Understanding Transformers', embedding: [0.12, -0.34, 0.56, ...] };
-- Nearest neighbor search
SEARCH articles USING VECTOR(embedding, ARRAY[0.1, 0.3, -0.2, ...], 10);
-- Filtered vector search
SELECT title, vector_distance(embedding, ARRAY[0.1, 0.3, ...]) AS score
FROM articles
WHERE category = 'machine-learning'
AND id IN (SEARCH articles USING VECTOR(embedding, ARRAY[0.1, 0.3, ...], 10));
-- Hybrid BM25 + vector (RRF fusion)
SELECT title, rrf_score(
vector_distance(embedding, $query_vec),
bm25_score(body, 'transformer attention')
) AS score
FROM articles
LIMIT 10;
Quantization & Storage Precision
Storage Precision (storage_dtype — raw HNSW structural storage):
| Type | Bytes/dim | Best for |
F32 | 4 | Maximum accuracy, small indexes |
F16 | 2 | Balanced memory vs accuracy |
BF16 | 2 | Better dynamic range than F16 (preferred for embeddings) |
Quantization (quantization — index-level compression, independent of storage_dtype):
Codes are traversed for speed, then top candidates are re-ranked against full-precision vectors. Memory is the per-vector code size at 384 dimensions; smaller codes trade recall for footprint and scale.
quantization | Code size (384d) | Best for |
none | 1536 B (dim×4) | < 1M vectors, maximum accuracy |
sq8 | 384 B (dim×1) | 1–10M vectors, near-lossless |
pq | m B (default m=16) | 10M+ vectors, classic Product Quantization |
opq | m B (rotation + PQ) | PQ + learned rotation, minor accuracy bump |
binary | 48 B (dim/8) | Massive scale, sign-bit asymmetric search |
rabitq | 48 B + scalars | 1-bit frontier with bounded error |
bbq | 62 B (dim/8 + 14 B) | Centroid-asymmetric 1-bit + corrective |
ternary | ~77 B (dim/5) | BitNet b1.58 trit-packed |
How It Works
Vectors are indexed in the HNSW graph at full precision. During search, quantized copies are traversed for speed, then top candidates are re-ranked against full-precision vectors. When metadata filters are present, the engine builds a Roaring Bitmap of matching IDs and selects the optimal strategy based on selectivity.