Rust language bindings for Faiss
Clone or download
Enet4 Merge pull request #2 from justinaustin/remove_ids
Adding remove_ids method to Index trait
Latest commit 137bc35 Dec 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
faiss-sys Update native faiss revision Dec 9, 2018
src Merge pull request #2 from justinaustin/remove_ids Dec 9, 2018
.gitignore Ignoring /rls/ is no longer needed Jun 6, 2018
.travis.yml Travis scripts clean-up Jun 13, 2018
Cargo.toml removed version bump Dec 5, 2018
LICENSE-APACHE Add license files Jan 28, 2018
LICENSE-MIT Add license files Jan 28, 2018
README.md Update README.md Jun 27, 2018

README.md

Faiss-rs

faiss at crates.io Build Status dependency status

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.

  1. 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.
  2. 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 the LD_LIBRARY_PATH environment variable, such as "/usr/lib", or try adding a new path to this variable). For GPU support, don't forget to build and install gpufaiss_c instead.
  3. You are now ready to include this crate as a dependency:
[dependencies]
"faiss" = "0.6.0"

If you have built Faiss with GPU support, you can include the "gpu" feature in the bindings:

[dependencies]
"faiss" = {version = "0.6.0", features = ["gpu"]}

Using

A basic example is seen below. Please check out the documentation for more.

use faiss::{Index, index_factory, MetricType};

let mut index = index_factory(64, "Flat", MetricType::L2)?;
index.add(&my_data)?;

let result = index.search(&my_query, 5)?;
for (i, (l, d)) in result.labels.iter()
    .zip(result.distances.iter())
    .enumerate()
{
    println!("#{}: {} (D={})", i + 1, *l, *d);
}

License and attribution notice

Licensed under either of

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.