Faiss-rs
This project provides Rust bindings to Faiss, the state-of-the-art vector search and clustering library.
Installing as a dependency
Currently, this crate does not build Faiss automatically for you. The dynamic library needs to be installed manually to your system.
- Follow the instructions here to build Faiss. The latest
master
branch should suffice, but in the event that it doesn't build properly, consider building Faiss from this fork,c_api_head
branch, which will contain the latest bindings to the C interface. - Afterwards, follow the instructions on building the C API of Faiss. This will result in the dynamic library
faiss_c
, which needs to be installed in a place where your system will pick up (in Linux, try somewhere in theLD_LIBRARY_PATH
environment variable, such as "/usr/lib", or try adding a new path to this variable). For GPU support, don't forget to buildgpufaiss_c
as well. - You are now ready to include this crate as a dependency:
[]
= "0.5.1"
If you have built Faiss with GPU support, you can include the "gpu" feature in the bindings:
[]
= { = "0.5.1", = ["gpu"]}
Using
A basic example is seen below. Please check out the documentation for more.
use ;
let mut index = index_factory?;
index.add?;
let result = index.search?;
for in result.labels.iter
.zip
.enumerate
License and attribution notice
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
This work is not affiliated with Facebook AI Research or the main Faiss software.