Skip to content

Annie.io

Blazingly fast Approximate Nearest Neighbors in Rust

Installation

# Stable release
pip install rust-annie

# With GPU support (requires CUDA Toolkit)
pip install rust-annie[gpu]

Basic Usage

import numpy as np
from rust_annie import AnnIndex, Distance

# Create index
index = AnnIndex(128, Distance.EUCLIDEAN)

# Add data
data = np.random.rand(1000, 128).astype(np.float32)
ids = np.arange(1000, dtype=np.int64)
index.add(data, ids)

# Search
query = np.random.rand(128).astype(np.float32)
neighbor_ids, distances = index.search(query, k=5)
print(f"Top 5 neighbors: {neighbor_ids}")
print(f"Distances: {distances}")

Key Features

  • Multiple Backends:
  • Brute-force (exact) with SIMD acceleration for guaranteed accuracy
  • HNSW (approximate) for large-scale datasets with near-constant memory
  • Multiple Distance Metrics: Euclidean, Cosine, Manhattan, Chebyshev
  • Batch Queries for efficient processing of multiple vectors
  • Thread-safe indexes with concurrent access patterns
  • Zero-copy NumPy integration for minimal memory overhead
  • On-disk Persistence with serialization/deserialization
  • Filtered Search with custom Python callbacks and metadata
  • GPU Acceleration for brute-force calculations on NVIDIA GPUs
  • Multi-platform support (Linux, Windows, macOS)
  • Automated CI/CD with benchmarking and performance tracking