Compressed vector search for DuckDB — Google TurboQuant quantization, IVF indexing, rerank, ensembles, filtered search, cosine/L2/dot
Compatibility Matrix
This table covers all DuckDB releases that have not reached end-of-life, including LTS releases, and shows the 2 most recent patch releases of each. Older patch releases are not listed, but the extension may be available for them as well.
| Platform | 1.5.5 | 1.5.6 | 2.0.0 | 2.0.1 |
|---|---|---|---|---|
| Linux AMD64 | ||||
| Linux ARM64 | ||||
| macOS AMD64 | ||||
| macOS ARM64 | ||||
| Windows AMD64 | ||||
| Windows ARM64 | ||||
| WebAssembly |
Installing and Loading
INSTALL turbovec FROM community;
LOAD turbovec;
Example
LOAD turbovec;
-- Build a compressed vector index (8-dim vectors, 4-bit) from a list
SELECT * FROM turboquant_build_list(
[0.0::FLOAT,1.0,2.0,3.0,4.0,5.0,6.0,7.0,
8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0],
4, '/tmp/myidx.tv'
);
-- Add a vector to the index
SELECT * FROM turboquant_add(
'/tmp/myidx.tv', '[16.0,17.0,18.0,19.0,20.0,21.0,22.0,23.0]', 8
);
-- Top-k search (metric inferred from index: l2/cosine/dot)
SELECT * FROM turboquant_search('/tmp/myidx.tv', '[8.0,9.0,10.0,11.0,12.0,13.0,14.0,15.0]', 3);
-- Build an IVF index (num_lists=0 auto), then search
SELECT * FROM turboquant_build_ivf(
'[[0,1,2,3],[4,5,6,7],[8,9,10,11],[12,13,14,15]]', 4, 4, 0, '/tmp/myivf/'
);
SELECT * FROM turboquant_search_ivf('/tmp/myivf/', '[8.0,9.0,10.0,11.0]', 3, 0);
About turbovec
turbovec — Compressed Vector Search for DuckDB
High-performance approximate nearest neighbor (ANN) search using Google's TurboQuant data-oblivious product quantization, with IVF indexing, rerank, ensembles, and filtered search.
12 Functions:
| Function | Description |
|---|---|
turboquant_build(str, dim, bits, path) |
Build index from nested-array string |
turboquant_build_list(LIST, bits, path) |
Build from a flat vector LIST (dim auto) |
turboquant_build_concat(path, dim, bits, str) |
Append CSV vectors to an index |
turboquant_build_ivf(str, dim, bits, nlists, dir, [keep_raw]) |
Build IVF index (nlists 0 = auto √n) |
turboquant_build_ensemble(str, dim, bits, m, dir) |
Ensemble of m decorrelated indexes |
turboquant_add(path, str, dim) |
Incremental add |
turboquant_remove(path, idx) |
Incremental remove |
turboquant_search(path, query, k) |
Top-k search (l2/cosine/dot) |
turboquant_search_within(path, query, eps, k) |
Radius (WITHIN) / top-k+eps fused search |
turboquant_search_ivf(dir, query, k, probes, [rerank_factor]) |
IVF search, optional rerank |
turboquant_search_ivf_filter(dir, query, k, ids, [max_probes:=], [rerank_factor:=]) |
Filtered IVF search (pgvector-style iterative scan) |
turboquant_search_ensemble(dir, query, k) |
Ensemble search (score-averaged) |
turboquant_score(path, query) |
Full scoring, all vectors ranked |
turbovec_config(knob, value) |
Set/get process-wide search defaults |
Features:
- 2-bit (16×) / 4-bit (8×) data-oblivious compression, zero training
- SIMD search: NEON (ARM), AVX-512BW/AVX2 (x86)
- Beats FAISS PQ: +0.2–1.9pp R@1 on OpenAI embeddings; ARM +12–20% vs FastScan
- IVF v2 single-file layout (7–18× smaller than per-cluster files), k-means++ + parallel Lloyd
-
Rerank (
keep_rawbuild +rerank_factorsearch) — recall@10 0.846 → 0.996 @ ~2 ms - Ensembles (m permutation-decorrelated indexes, score-averaged) — recall@10 0.888 → 0.939
-
Filtered search (
turboquant_search_ivf_filter) — arbitrary SQL predicate as aLIST<BIGINT>allowlist, iterative probe widening - Radius (WITHIN) search and incremental add/remove
- Process-wide index cache — repeated search 37.7 ms → 1.77 ms on 100k vectors
- Multiple metrics: l2, cosine, dot
Platforms: Linux x64, macOS x64/arm64, Windows x64 (WASM and linux_arm64 excluded).
Built on Google's TurboQuant library.
Added Functions
| function_name | function_type | description | comment | examples |
|---|---|---|---|---|
| turboquant_add | table | NULL | NULL | |
| turboquant_build | table | NULL | NULL | |
| turboquant_build_concat | table | NULL | NULL | |
| turboquant_build_ensemble | table | NULL | NULL | |
| turboquant_build_ivf | table | NULL | NULL | |
| turboquant_build_list | table | NULL | NULL | |
| turboquant_remove | table | NULL | NULL | |
| turboquant_score | table | NULL | NULL | |
| turboquant_search | table | NULL | NULL | |
| turboquant_search_ensemble | table | NULL | NULL | |
| turboquant_search_ivf | table | NULL | NULL | |
| turboquant_search_ivf_filter | table | NULL | NULL | |
| turboquant_search_within | table | NULL | NULL | |
| turbovec_config | scalar | NULL | NULL |
Overloaded Functions
This extension does not add any function overloads.
Added Types
This extension does not add any types.
Added Settings
| name | description | input_type | scope | aliases | typed_value |
|---|---|---|---|---|---|
| temp_directory | Set the directory to which temporary files are written. | VARCHAR | GLOBAL | [] | post.db.tmp |