Faiss

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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

`#include <IndexIVFSpectralHash.h>`

Inheritance diagram for faiss::IndexIVFSpectralHash:

## Public Types
enum | ThresholdType { Thresh_global, Thresh_centroid, Thresh_centroid_half, Thresh_median }
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
| IndexIVFSpectralHash (Index *quantizer, size_t d, size_t nlist, int nbit, float period)
void | train_residual (idx_t n, const float *x) override
void | encode_vectors (idx_t n, const float *x, const idx_t *list_nos, uint8_t *codes) const override
InvertedListScanner * | get_InvertedListScanner (bool store_pairs) const override
| get a scanner for this index (store_pairs means ignore labels)
Public Member Functions inherited from faiss::IndexIVF
| IndexIVF (Index *quantizer, size_t d, size_t nlist, size_t code_size, MetricType metric=METRIC_L2)
void | reset () override
| removes all elements from the database.
void | train (idx_t n, const float *x) override
| Trains the quantizer and calls train_residual to train sub-quantizers.
void | add (idx_t n, const float *x) override
| Calls add_with_ids with NULL ids.
void | add_with_ids (idx_t n, const float *x, const idx_t *xids) override
| default implementation that calls encode_vectors
virtual void | search_preassigned (idx_t n, const float *x, idx_t k, const idx_t *assign, const float *centroid_dis, float *distances, idx_t *labels, bool store_pairs, const IVFSearchParameters *params=nullptr) const
void | search (idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
void | range_search (idx_t n, const float *x, float radius, RangeSearchResult *result) const override
void | range_search_preassigned (idx_t nx, const float *x, float radius, const idx_t *keys, const float *coarse_dis, RangeSearchResult *result) const
void | reconstruct (idx_t key, float *recons) const override
void | reconstruct_n (idx_t i0, idx_t ni, float *recons) const override
void | search_and_reconstruct (idx_t n, const float *x, idx_t k, float *distances, idx_t *labels, float *recons) const override
virtual void | reconstruct_from_offset (idx_t list_no, idx_t offset, float *recons) const
idx_t | remove_ids (const IDSelector &sel) override
| Dataset manipulation functions.
void | check_compatible_for_merge (const IndexIVF &other) const
virtual void | merge_from (IndexIVF &other, idx_t add_id)
virtual void | copy_subset_to (IndexIVF &other, int subset_type, idx_t a1, idx_t a2) const
size_t | get_list_size (size_t list_no) const
void | make_direct_map (bool new_maintain_direct_map=true)
void | replace_invlists (InvertedLists *il, bool own=false)
| replace the inverted lists, old one is deallocated if own_invlists
Public Member Functions inherited from faiss::Index
| Index (idx_t d=0, MetricType metric=METRIC_L2)
void | assign (idx_t n, const float *x, idx_t *labels, idx_t k=1)
void | compute_residual (const float *x, float *residual, idx_t key) const
void | display () const
Public Member Functions inherited from faiss::Level1Quantizer
void | train_q1 (size_t n, const float *x, bool verbose, MetricType metric_type)
| Trains the quantizer and calls train_residual to train sub-quantizers.
| Level1Quantizer (Index *quantizer, size_t nlist)

## Public Attributes
VectorTransform * | vt
bool | own_fields
int | nbit
float | period
ThresholdType | threshold_type
std::vector< float > | trained
Public Attributes inherited from faiss::IndexIVF
InvertedLists * | invlists
| Acess to the actual data.
bool | own_invlists
size_t | code_size
| code size per vector in bytes
size_t | nprobe
| number of probes at query time
size_t | max_codes
| max nb of codes to visit to do a query
int | parallel_mode
bool | maintain_direct_map
| map for direct access to the elements. Enables reconstruct().
std::vector< idx_t > | direct_map
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
Public Attributes inherited from faiss::Level1Quantizer
Index * | quantizer
| quantizer that maps vectors to inverted lists
size_t | nlist
| number of possible key values
char | quantizer_trains_alone
bool | own_fields
| whether object owns the quantizer
ClusteringParameters | cp
| to override default clustering params
Index * | clustering_index
| to override index used during clustering

## Detailed Description

Inverted list that stores binary codes of size nbit. Before the binary conversion, the dimension of the vectors is transformed from dim d into dim nbit by vt (a random rotation by default).

Each coordinate is subtracted from a value determined by threshold_type, and split into intervals of size period. Half of the interval is a 0 bit, the other half a 1.

Definition at line 31 of file IndexIVFSpectralHash.h.

## Member Function Documentation

void faiss::IndexIVFSpectralHash::encode_vectors | ( | idx_t | n,
|  | const float * | x,
|  | const idx_t * | list_nos,
|  | uint8_t * | codes
| ) |  | const
| override virtual

Encodes a set of vectors as they would appear in the inverted lists

Parameters

  list_nos | inverted list ids as returned by the quantizer (size n). -1s are ignored.
  codes | output codes, size n * code_size

Implements faiss::IndexIVF.

Definition at line 161 of file IndexIVFSpectralHash.cpp.

void faiss::IndexIVFSpectralHash::train_residual | ( | idx_t | n,
|  | const float * | x
| ) |  |
| override virtual

Sub-classes that encode the residuals can train their encoders here does nothing by default

Reimplemented from faiss::IndexIVF.

Definition at line 66 of file IndexIVFSpectralHash.cpp.

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

- /data/users/hoss/faiss/IndexIVFSpectralHash.h
- /data/users/hoss/faiss/IndexIVFSpectralHash.cpp