Faiss

- Main Page
- Namespaces
- Classes
- Files

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

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

`#include <IndexIVFPQ.h>`

Inheritance diagram for faiss::IndexIVFPQR:

## Public Member Functions
| IndexIVFPQR (Index *quantizer, size_t d, size_t nlist, size_t M, size_t nbits_per_idx, size_t M_refine, size_t nbits_per_idx_refine)
void | reset () override
| removes all elements from the database.
long | remove_ids (const IDSelector &sel) override
| Dataset manipulation functions.
void | train_residual (idx_t n, const float *x) override
| trains the two product quantizers
void | add_with_ids (idx_t n, const float *x, const long *xids) override
void | add_core (idx_t n, const float *x, const long *xids, const long *precomputed_idx=nullptr)
| same as add_with_ids, but optionally use the precomputed list ids
void | reconstruct_n (idx_t i0, idx_t ni, float *recons) const override
void | merge_from (IndexIVF &other, idx_t add_id) override
void | search (idx_t n, const float *x, idx_t k, float *distances, idx_t *labels) const override
Public Member Functions inherited from faiss::IndexIVFPQ
| IndexIVFPQ (Index *quantizer, size_t d, size_t nlist, size_t M, size_t nbits_per_idx)
void | add_core_o (idx_t n, const float *x, const long *xids, float *residuals_2, const long *precomputed_idx=nullptr)
void | train_residual_o (idx_t n, const float *x, float *residuals_2)
| same as train_residual, also output 2nd level residuals
void | reconstruct (idx_t key, float *recons) const override
size_t | find_duplicates (idx_t *ids, size_t *lims) const
void | encode (long key, const float *x, uint8_t *code) const
void | encode_multiple (size_t n, long *keys, const float *x, uint8_t *codes, bool compute_keys=false) const
void | decode_multiple (size_t n, const long *keys, const uint8_t *xcodes, float *x) const
| inverse of encode_multiple
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 override
void | search_and_reconstruct (idx_t n, const float *x, idx_t k, float *distances, idx_t *labels, float *reconstructed)
void | precompute_table ()
| build precomputed table More...
Public Member Functions inherited from faiss::IndexIVF
| IndexIVF (Index *quantizer, size_t d, size_t nlist, MetricType metric=METRIC_INNER_PRODUCT)
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
| Quantizes x and calls add_with_key.
virtual void | copy_subset_to (IndexIVF &other, int subset_type, long a1, long a2) const
size_t | get_list_size (size_t list_no) const
void | make_direct_map (bool new_maintain_direct_map=true)
double | imbalance_factor () const
| 1= perfectly balanced, >1: imbalanced
void | print_stats () const
| display some stats about the inverted lists
Public Member Functions inherited from faiss::Index
| Index (idx_t d=0, MetricType metric=METRIC_INNER_PRODUCT)
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)
void | compute_residual (const float *x, float *residual, idx_t key) const
void | display () const

## Public Attributes
ProductQuantizer | refine_pq
| 3rd level quantizer
std::vector< uint8_t > | refine_codes
| corresponding codes
float | k_factor
| factor between k requested in search and the k requested from the IVFPQ
Public Attributes inherited from faiss::IndexIVFPQ
bool | by_residual
| Encode residual or plain vector?
int | use_precomputed_table
| if by_residual, build precompute tables
ProductQuantizer | pq
| produces the codes
bool | do_polysemous_training
| reorder PQ centroids after training?
PolysemousTraining * | polysemous_training
| if NULL, use default
size_t | scan_table_threshold
| use table computation or on-the-fly?
size_t | max_codes
| max nb of codes to visit to do a query
int | polysemous_ht
| Hamming thresh for polysemous filtering.
std::vector< float > | precomputed_table
Public Attributes inherited from faiss::IndexIVF
size_t | nlist
| number of possible key values
size_t | nprobe
| number of probes at query time
Index * | quantizer
| quantizer that maps vectors to inverted lists
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
std::vector< std::vector< long > > | ids
| Inverted lists for indexes.
size_t | code_size
| code size per vector in bytes
std::vector< std::vector < uint8_t > > | codes
bool | maintain_direct_map
| map for direct access to the elements. Enables reconstruct().
std::vector< long > | 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

## Additional Inherited Members
Public Types inherited from faiss::Index
typedef long | idx_t
| all indices are this type

## Detailed Description

Index with an additional level of PQ refinement

Definition at line 168 of file IndexIVFPQ.h.

## Member Function Documentation

void faiss::IndexIVFPQR::add_with_ids | ( | idx_t | n,
|  | const float * | x,
|  | const long * | xids
| ) |  |
| overridevirtual

Same as add, but stores xids instead of sequential ids.

The default implementation fails with an assertion, as it is not supported by all indexes.

Parameters

  xids | if non-null, ids to store for the vectors (size n)

Reimplemented from faiss::IndexIVFPQ.

Definition at line 1189 of file IndexIVFPQ.cpp.

void faiss::IndexIVFPQR::merge_from | ( | IndexIVF & | other,
|  | idx_t | add_id
| ) |  |
| overridevirtual

moves the entries from another dataset to self. On output, other is empty. add_id is added to all moved ids (for sequential ids, this would be this->ntotal

Reimplemented from faiss::IndexIVF.

Definition at line 1320 of file IndexIVFPQ.cpp.

void faiss::IndexIVFPQR::reconstruct_n | ( | idx_t | i0,
|  | idx_t | ni,
|  | float * | recons
| ) |  | const
| overridevirtual

Reconstruct a subset of the indexed vectors

Parameters

  i0 | first vector to reconstruct
  ni | nb of vectors to reconstruct
  recons | output array of reconstructed vectors, size ni * d

Reimplemented from faiss::IndexIVFPQ.

Definition at line 1301 of file IndexIVFPQ.cpp.

void faiss::IndexIVFPQR::search | ( | idx_t | n,
|  | const float * | x,
|  | idx_t | k,
|  | float * | distances,
|  | idx_t * | labels
| ) |  | const
| overridevirtual

assign the vectors, then call search_preassign

Reimplemented from faiss::IndexIVF.

Definition at line 1212 of file IndexIVFPQ.cpp.

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

- /data/users/matthijs/github_faiss/faiss/IndexIVFPQ.h
- /data/users/matthijs/github_faiss/faiss/IndexIVFPQ.cpp