autofaiss.external.quantize.tune_index
- autofaiss.external.quantize.tune_index(index_path, index_key, index_param=None, output_index_path='tuned_knn.index', save_on_disk=True, min_nearest_neighbors_to_retrieve=20, max_index_query_time_ms=10.0, use_gpu=False, verbose=20)[source]
Set hyperparameters to the given index.
If an index_param is given, set this hyperparameters to the index, otherwise perform a greedy heusistic to make the best out or the max_index_query_time_ms constraint
- Parameters:
index_path (Union[str, faiss.Index]) – Path to .index file Can also be an index
index_key (str) – String to give to the index factory in order to create the index.
index_param (Optional(str)) – Optional string with hyperparameters to set to the index. If None, the hyper-parameters are chosen based on an heuristic.
output_index_path (str) – Path to the newly created .index file
save_on_disk (bool) – Whether to save the index on disk, default to True.
min_nearest_neighbors_to_retrieve (int) – Minimum number of nearest neighbors to retrieve when querying the index.
max_index_query_time_ms (float) – Query speed constraint for the index to create.
use_gpu (bool) – Experimental, gpu training is faster, not tested so far.
verbose (int) – set verbosity of outputs via logging level, default is logging.INFO
- Returns:
The faiss index
- Return type:
index