我要评分
获取效率
正确性
完整性
易理解

create_searcher

API Definition

def create_searcher(db: numpy.ndarray, scann_config: str, training_threads: int, docids: numpy.ndarray, kmopt_pq_iter: int, kmopt_pq_sample: int, kmopt_pq_init: int, kmopt_ivf_iter: int, kmopt_ivf_sample: int, kmopt_ivf_init: int, filter_thr: float, filter_type: int) -> scann.scann_ops.ScannSearcher

Function

Builds an index based on the input parameters and returns the ScannSearcher (filter_thr and filter_type are KScaNN-specific parameters).

Parameters

Parameter

Data Type

Description

Value Range

db

numpy.ndarray

Base library vector.

The value cannot be null.

scann_config

Character string

Configuration file required for creating the index, containing all configuration parameters.

-

training_threads

int

Number of threads used for index construction.

[0, MAXINT]. The default value is 0.

docids

numpy.ndarray

Document ID.

The default value is None.

kmopt_pq_iter

int

Number of K-means iterations in PQ.

[0, MAXINT]. The default value is 0.

kmopt_pq_sample

int

Sample size for PQ K-means clustering.

[0, MAXINT]. The default value is 0.

kmopt_pq_init

int

K-means initialization type in PQ.

{0, 1, 2, 3}. The default value is 0.

  • 1: initialization based on the average distance.
  • 2: initialization based on the K-means++ algorithm.
  • 3: random initialization.
  • 0: Do not enable K-means optimization in PQ.

kmopt_ivf_iter

int

Number of K-means iterations in IVF.

[0, MAXINT]. The default value is 0.

kmopt_ivf_sample

int

Sample size for IVF K-means clustering.

[0, MAXINT]. The default value is 0.

kmopt_ivf_init

int

IVF K-means initialization type.

{0, 1, 2, 3}. The default value is 0.

  • 1: initialization based on the average distance.
  • 2: initialization based on the K-means++ algorithm.
  • 3: random initialization.
  • 0: Do not enable K-means optimization in IVF.

filter_thr

float

Filter threshold.

[0, 1]. The default value is 0.

filter_type

int

Filter type.

The value is 0 or 1. The default value is 0.

  • 0: filtering based on the number of zero elements in the vector.
  • 1: filtering based on the deviation of elements from the mean value.

Return Value

Data Type

Description

scann.scann_ops.ScannSearcher

The build starts and the built ScannSearcher is returned.