Faiss
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends
Public Types | Public Member Functions | Public Attributes | List of all members
faiss::IndexHNSW Struct Referenceabstract

#include <IndexHNSW.h>

Inheritance diagram for faiss::IndexHNSW:
faiss::Index faiss::IndexHNSW2Level faiss::IndexHNSWFlat faiss::IndexHNSWPQ faiss::IndexHNSWSQ

Public Types

typedef HNSW::storage_idx_t storage_idx_t
 
- Public Types inherited from faiss::Index
using idx_t = long
 all indices are this type
 
using component_t = float
 
using distance_t = float
 

Public Member Functions

 IndexHNSW (int d=0, int M=32)
 
 IndexHNSW (Index *storage, int M=32)
 
virtual DistanceComputerget_distance_computer () const =0
 
void add (idx_t n, const float *x) override
 
void train (idx_t n, const float *x) override
 Trains the storage if needed.
 
void search (idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
 entry point for search
 
void reconstruct (idx_t key, float *recons) const override
 
void reset () override
 removes all elements from the database.
 
void shrink_level_0_neighbors (int size)
 
void search_level_0 (idx_t n, const float *x, idx_t k, const storage_idx_t *nearest, const float *nearest_d, float *distances, idx_t *labels, int nprobe=1, int search_type=1) const
 
void init_level_0_from_knngraph (int k, const float *D, const idx_t *I)
 alternative graph building
 
void init_level_0_from_entry_points (int npt, const storage_idx_t *points, const storage_idx_t *nearests)
 alternative graph building
 
void reorder_links ()
 
void link_singletons ()
 
- Public Member Functions inherited from faiss::Index
 Index (idx_t d=0, MetricType metric=METRIC_L2)
 
virtual void add_with_ids (idx_t n, const float *x, const long *xids)
 
virtual void range_search (idx_t n, const float *x, float radius, RangeSearchResult *result) const
 
void assign (idx_t n, const float *x, idx_t *labels, idx_t k=1)
 
virtual long remove_ids (const IDSelector &sel)
 
virtual void reconstruct_n (idx_t i0, idx_t ni, float *recons) const
 
virtual void search_and_reconstruct (idx_t n, const float *x, idx_t k, float *distances, idx_t *labels, float *recons) const
 
void compute_residual (const float *x, float *residual, idx_t key) const
 
void display () const
 

Public Attributes

HNSW hnsw
 
bool own_fields
 
Indexstorage
 
ReconstructFromNeighborsreconstruct_from_neighbors
 
- Public Attributes inherited from faiss::Index
int d
 vector dimension
 
idx_t ntotal
 total nb of indexed vectors
 
bool verbose
 verbosity level
 
bool is_trained
 set if the Index does not require training, or if training is done already
 
MetricType metric_type
 type of metric this index uses for search
 

Detailed Description

The HNSW index is a normal random-access index with a HNSW link structure built on top

Definition at line 69 of file IndexHNSW.h.

Member Function Documentation

void faiss::IndexHNSW::add ( idx_t  n,
const float *  x 
)
overridevirtual

Add n vectors of dimension d to the index.

Vectors are implicitly assigned labels ntotal .. ntotal + n - 1 This function slices the input vectors in chuncks smaller than blocksize_add and calls add_core.

Parameters
xinput matrix, size n * d

Implements faiss::Index.

Definition at line 294 of file IndexHNSW.cpp.

void faiss::IndexHNSW::reconstruct ( idx_t  key,
float *  recons 
) const
overridevirtual

Reconstruct a stored vector (or an approximation if lossy coding)

this function may not be defined for some indexes

Parameters
keyid of the vector to reconstruct
reconsreconstucted vector (size d)

Reimplemented from faiss::Index.

Definition at line 312 of file IndexHNSW.cpp.

void faiss::IndexHNSW::search_level_0 ( idx_t  n,
const float *  x,
idx_t  k,
const storage_idx_t *  nearest,
const float *  nearest_d,
float *  distances,
idx_t labels,
int  nprobe = 1,
int  search_type = 1 
) const

Perform search only on level 0, given the starting points for each vertex.

Parameters
search_type1:perform one search per nprobe, 2: enqueue all entry points

Definition at line 355 of file IndexHNSW.cpp.


The documentation for this struct was generated from the following files: