GitXplorerGitXplorer
E

faiss-rs

public
206 stars
38 forks
13 issues

Commits

List of commits on branch master.
Verified
e9724a555d805c4d8ab85d7ba1aa0bc8af876280

Merge pull request #87 from hamirmahal/fix/usage-of-deprecated-nodejs-16-action

EEnet4 committed 4 months ago
Verified
2487440e9c06e32b22b6e3609833d70ed17bc2f8

fix: usage of deprecated `Node.js 16` action

hhamirmahal committed 4 months ago
Verified
f8a0b4e2ee672797b1f42c455c62b39283a71f18

chore: changes from formatting on save

hhamirmahal committed 4 months ago
Verified
97cdff88bdf7be7f7eee93feb6528ca13f945a2f

Merge pull request #81 from agerasev/fix-gpu-res-leak

EEnet4 committed 10 months ago
Unverified
76eb6272d0896a16c82c466f04c41d8c9762d843

Fix `StandardGpuResources` memory leak

aagerasev committed 10 months ago
Verified
7a2843a955ae1ab7b34476182d62a0ed380e127d

Merge pull request #75 from tronicboy1/patch-1

EEnet4 committed 10 months ago

README

The README file for this repository.

Faiss-rs

faiss at crates.io Continuous integration status Minimum Rust Version Stable dependency status

This project provides Rust bindings to Faiss, the state-of-the-art vector search and clustering library.

Installing with dynamic linking

By default, this crate is dynamically linked with the Faiss library installed in your system, so it does not build Faiss automatically for you. To build the library yourself:

  1. Follow the instructions here to build Faiss using CMake, enabling the variables FAISS_ENABLE_C_API and BUILD_SHARED_LIBS. The crate is currently only compatible with version v1.7.2. Consider building Faiss from this fork, c_api_head branch, which will contain the latest supported bindings to the C interface. For example:

    cmake -B build -DFAISS_ENABLE_C_API=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_BUILD_TYPE=Release
    cmake --build build

    This will result in the dynamic library faiss_c ("c_api/libfaiss_c.so" on Linux), 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 mac users, this means placing it in /usr/local/lib/libfaiss_c.dylib). For GPU support, don't forget to enable the option FAISS_ENABLE_GPU. Note: faiss_c might link dynamically to the native faiss library, which in that case you will need to install the main shared object (faiss/libfaiss.so) as well.

  2. You are now ready to include this crate as a dependency:

    [dependencies]
    "faiss" = "0.11.0"

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

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

Installing with static linking

Alternatively to the above, enable the "static" Cargo feature to let Rust build Faiss for you. You will still need the dependencies required to build and run Faiss as described in their INSTALL.md, namely a compatible C++ compiler and a BLAS implementation.

[dependencies]
"faiss" = { version = "0.11.0", features = ["static"] }

Compiling Faiss with GPU support is also possible.

[dependencies]
"faiss" = { version = "0.11.0", features = ["static", "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.