Install and load
Run these commands in a Haybarn SQL session. The extension is available from the community repository.
INSTALL faiss FROM community;
LOAD faiss FROM community;
Using upstream DuckDB? Follow the maintainer’s installation instructions.
Usage example
Generate semi-random input data and queries
-- Generate semi-random input data and queries
-- Note that the dimensionality of our data will be 5
CREATE TABLE input AS SELECT i AS id, apply(generate_series(1, 5), j-> CAST(hash(i*1000+j) AS FLOAT)/18446744073709551615) AS data FROM generate_series(1, 1000) s(i);
CREATE TABLE queries AS SELECT i AS id, apply(generate_series(1, 5), j-> CAST(hash(i*1000+j+8047329823) AS FLOAT)/18446744073709551615) AS data FROM generate_series(1, 10) s(i);
-- Create the index and insert data into it
CALL FAISS_CREATE('name', 5, 'IDMap,HNSW32');
CALL FAISS_ADD((SELECT id, data FROM input), 'name');
-- On linux, with cuda, we can move the index to the GPU
-- CALL FAISS_TO_GPU('name', 0);
-- Get 10 results with uneven id
SELECT id, UNNEST(FAISS_SEARCH_FILTER('name', 10, data, 'id%2==1', 'rowid', 'input')) FROM queries;
-- Get 10 results with even id
SELECT id, UNNEST(FAISS_SEARCH_FILTER('name', 10, data, 'id%2==0', 'rowid', 'input')) FROM queries;
-- Get 10 results
SELECT id, UNNEST(FAISS_SEARCH('name', 10, data)) FROM queries;
Provided by duckdb-faiss-ext. Not yet verified on Haybarn 2.0.0.
Sample data & setupAbout this extension
The FAISS extension allows DuckDB users to store vector data in faiss, and query this data, making reliable vector search more accessible. On all linux platforms, this platform also supports GPU indexes, you can move a supported index to the GPU using CALL FAISS_MOVE_GPU({index_name}, {gpu number}). Currently only CUDA is supported, note that GPU support may be split into a separate extension in the future.
Some (most) indices are not supported for gpus, however this is very easily resolvable. Please open an issue over at our repository in order to get this resolved!
Project overview from the community descriptor.
Documentation and resources
Project and build details
- Repository
- duckdb-faiss-ext/duckdb-faiss-ext
- License
- MIT
- Maintainers
- JAicewizard, arjenpdevries
- Written in
- C++
- Build source
c8fb12d213fc- Build definition
- Community descriptor