Skip to content

9. Custom Distance Metrics

Estimated time: 12 minutes

Learn how to define and use custom distance metrics in Annie.

Steps

  1. Define a custom metric:
  2. Subclass or configure as per API.
  3. Use with AnnIndex:
  4. Pass your metric to the index constructor.

Example

from rust_annie import AnnIndex, Distance
index = AnnIndex(128, Distance.COSINE)

Next: GPU Acceleration