blockingpy.controls.controls_ann

blockingpy.controls.controls_ann(controls, **kwargs)[source]

Create configuration dictionary for Approximate Nearest Neighbor algorithms.

This function provides a centralized configuration for multiple ANN algorithms, with sensible defaults and easy override capabilities.

Parameters:
  • controls (dict) – Dictionary of control parameters to override defaults

  • **kwargs (dict) – Additional keyword arguments for direct parameter updates

Returns:

Configuration dictionary with the following structure: {

’random_seed’: int, ‘nnd’: {

’metric’: str, ‘k_search’: int, ‘metric_kwds’: dict or None, ‘n_threads’: int or None, …

}, ‘hnsw’: {

’distance’: str, ‘n_threads’: int, ‘M’: int, …

}, ‘lsh’: {…}, ‘kd’: {…}, ‘annoy’: {…}, ‘voyager’: {…}, ‘faiss’: {…}, ‘gpu_faiss’: {…}, ‘algo’: str [‘lsh’ or ‘kd’]

}

Return type:

dict

Notes

Supported algorithms and their documentation: - NND: https://github.com/lmcinnes/pynndescent - HNSW: https://github.com/nmslib/hnswlib - Annoy: https://github.com/spotify/annoy - LSH and KD: https://github.com/mlpack/mlpack - Voyager: https://github.com/spotify/voyager - FAISS: https://github.com/facebookresearch/faiss

Examples

>>> config = controls_ann(hnsw={"M": 30, "ef_c": 300})