结构体 faiss::IndexIVFInterface
-
struct IndexIVFInterface : public faiss::Level1Quantizer
被 faiss::IndexIVF, faiss::gpu::GpuIndexIVF 继承
公共函数
-
inline explicit IndexIVFInterface(Index *quantizer = nullptr, size_t nlist = 0)
-
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, IndexIVFStats *stats = nullptr) const = 0
搜索一组向量,这些向量已通过 IVF 量化器进行预量化。 使用查询结果填充相应的堆。 默认实现使用 InvertedListScanners 进行搜索。
- 参数:
n – 要查询的向量数
x – 查询向量,大小为 nx * d
assign – 粗量化索引,大小为 nx * nprobe
centroid_dis – 到粗糙质心的距离,大小为 nx * nprobe
distance – 输出距离,大小为 n * k
labels – 输出标签,大小为 n * k
store_pairs – 在结果的 upper/lower 32 位中存储 inv list 索引 + inv list 偏移量,而不是 id(用于重新排序)。
params – 用于覆盖对象的搜索参数
stats – 要更新的搜索统计信息(可以为空)
-
virtual void range_search_preassigned(idx_t nx, const float *x, float radius, const idx_t *keys, const float *coarse_dis, RangeSearchResult *result, bool store_pairs = false, const IVFSearchParameters *params = nullptr, IndexIVFStats *stats = nullptr) const = 0
范围搜索一组向量,这些向量已通过 IVF 量化器进行预量化。 填写 RangeSearchResults 结果。 默认实现使用 InvertedListScanners 进行搜索。
- 参数:
n – 要查询的向量数
x – 查询向量,大小为 nx * d
assign – 粗量化索引,大小为 nx * nprobe
centroid_dis – 到粗糙质心的距离,大小为 nx * nprobe
result – 输出结果
store_pairs – 在结果的 upper/lower 32 位中存储 inv list 索引 + inv list 偏移量,而不是 id(用于重新排序)。
params – 用于覆盖对象的搜索参数
stats – 要更新的搜索统计信息(可以为空)
-
inline virtual ~IndexIVFInterface()
-
void train_q1(size_t n, const float *x, bool verbose, MetricType metric_type)
训练量化器并调用 train_residual 来训练子量化器。
-
size_t coarse_code_size() const
计算存储列表 ID 所需的字节数
-
void encode_listno(idx_t list_no, uint8_t *code) const
-
idx_t decode_listno(const uint8_t *code) const
公共成员
-
size_t nprobe = 1
查询时的探测数量
-
size_t max_codes = 0
执行查询时要访问的最大代码数量
-
Index *quantizer = nullptr
将向量映射到倒排列表的量化器
-
size_t nlist = 0
倒排列表的数量
-
char quantizer_trains_alone = 0
>= 0:在kmeans训练中使用量化器作为索引 = 1:仅将训练集传递给量化器的train() = 2:在平面索引上进行kmeans训练+将质心添加到量化器
-
bool own_fields = false
对象是否拥有量化器
-
ClusteringParameters cp
覆盖默认聚类参数
-
Index *clustering_index = nullptr
覆盖聚类期间使用的索引
-
inline explicit IndexIVFInterface(Index *quantizer = nullptr, size_t nlist = 0)