Skip to content

Commit

Permalink
MB-60029 - Add index types for tuning for recall/latency. (#46)
Browse files Browse the repository at this point in the history
Extends VectorField interface for optimizing for either recall/latency.

---------

Co-authored-by: Abhinav Dangeti <[email protected]>
  • Loading branch information
metonymic-smokey and abhinavdangeti authored Jan 16, 2024
1 parent b4f4f58 commit 54ca226
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions vector.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

// -----------------------------------------------------------------------------
Expand All @@ -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,
}

0 comments on commit 54ca226

Please sign in to comment.