API Reference
Faiss API
Faiss.Index
— TypeIndex(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.add
— Functionadd(idx::Index, vs::AbstractMatrix)
Add the columns of vs
to the index.
Faiss.search
— Functionsearch(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_ids
— Functionadd_with_ids(idx::IndexIDMap, vs::AbstractMatrix, ids::Array{Int64})
Faiss.remove_with_ids
— Functionremove_with_ids(idx::IndexIDMap, ids::Array{Int64})
Base.size
— Functionsize(idx::Union{Index, IndexIDMap})
Base.show
— Functionshow(io::IO, ::MIME"text/plain", idx::Index)
Faiss.downcast
— Functiondowncast(idx::Index)
Return the same index downcasted to its most specific type.
Extended Functions
Faiss.add_search
— Functionadd_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_ids
— Functionadd_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_rank
— Functionlocal_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.