From 54ca226af16a12a7e53e6cc90c6b3bed57856524 Mon Sep 17 00:00:00 2001 From: Aditi Ahuja <48997495+metonymic-smokey@users.noreply.github.com> Date: Wed, 17 Jan 2024 01:41:22 +0530 Subject: [PATCH] MB-60029 - Add index types for tuning for recall/latency. (#46) Extends VectorField interface for optimizing for either recall/latency. --------- Co-authored-by: Abhinav Dangeti --- vector.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/vector.go b/vector.go index d98ba7e..12c5433 100644 --- a/vector.go +++ b/vector.go @@ -23,6 +23,8 @@ type VectorField interface { Dims() int // Similarity metric to be used for scoring the vectors Similarity() string + // nlist/nprobe config (recall/latency) the index is optimized for + IndexOptimizedFor() string } // ----------------------------------------------------------------------------- @@ -45,3 +47,23 @@ var SupportedSimilarityMetrics = map[string]struct{}{ EuclideanDistance: {}, CosineSimilarity: {}, } + +// ----------------------------------------------------------------------------- + +const ( + IndexOptimizedForRecall = "recall" + IndexOptimizedForLatency = "latency" +) + +const DefaultIndexOptimization = IndexOptimizedForRecall + +var SupportedVectorIndexOptimizations = map[string]int{ + IndexOptimizedForRecall: 0, + IndexOptimizedForLatency: 1, +} + +// Reverse maps vector index optimizations': int -> string +var VectorIndexOptimizationsReverseLookup = map[int]string{ + 0: IndexOptimizedForRecall, + 1: IndexOptimizedForLatency, +}