API Reference

Faiss API

Faiss.IndexType
Index(dim::Integer; str::AbstractString="Flat", metric::String="L2", gpus::String="")

Create a Faiss index of the given parameters:

  • The dim is denote dimension of data to Index.
  • The str is an index factory string describing the type of index to construct. reference:index-factory
  • The metric is a metric of distance, have "L2", "IP"
  • The gpus is a string of setting gpu id. if "" denote use cpu.
Faiss.addFunction
add(idx::Index, vs::AbstractMatrix)

Add the columns of vs to the index.

Faiss.searchFunction
search(idx::Union{Index, IndexIDMap}, vs::AbstractMatrix, k::Integer)

Search the index for the k nearest neighbours of each column of vs.

Return (D, I) where I is a matrix where each column gives the ids of the k nearest neighbours of the corresponding column of vs and D is the corresponding matrix of distances.

Faiss.add_with_idsFunction
add_with_ids(idx::IndexIDMap, vs::AbstractMatrix, ids::Array{Int64})
Base.sizeFunction
size(idx::Union{Index, IndexIDMap})
Base.showFunction
show(io::IO, ::MIME"text/plain", idx::Index)
Faiss.downcastFunction
downcast(idx::Index)

Return the same index downcasted to its most specific type.

Extended Functions

Faiss.add_searchFunction
add_search(idx::Index, vs_query::AbstractMatrix, vs_gallery::AbstractMatrix; 
            k::Integer=100, flag::Bool=true)

Add vs_gallery to idx and Search the index for the k nearest neighbours of each column of vs_query.

Return (D, I) where I is a matrix where each column gives the ids of the k nearest neighbours of the corresponding column of vs and D is the corresponding matrix of distances.

Faiss.add_search_with_idsFunction
add_search_with_ids(idx::IndexIDMap, vs_query::AbstractMatrix, vs_gallery::AbstractMatrix, ids::Array{Int64}; 
                    k::Integer=100, flag::Bool=true)

Add vs_gallery with ids to idx and Search the index for the k nearest neighbours of each column of vs_query.

Faiss.local_rankFunction
local_rank(vs_query::AbstractMatrix, vs_gallery::AbstractMatrix; k::Integer=10, 
            str::String="Flat", metric::String="L2", gpus::String="")

Create Index and Add vs_gallery to idx and Search the index for the k nearest neighbours of each column of vs_query.

Return (D, I) where I is a matrix where each column gives the ids of the k nearest neighbours of the corresponding column of vs and D is the corresponding matrix of distances.