Skip to content

Commit

Permalink
Add defaults for ivfflat
Browse files Browse the repository at this point in the history
  • Loading branch information
wahajali authored and alwayslove2013 committed Mar 25, 2024
1 parent 123ddaa commit 0ba0675
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions vectordb_bench/backend/clients/pgvector/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,29 @@ def to_dict(self) -> dict:
class PgVectorIndexConfig(BaseModel, DBCaseConfig):
metric_type: MetricType | None = None
index: IndexType
lists: int | None = 1000
probes: int | None = 10

def parse_metric(self) -> str:
def parse_metric(self) -> str:
if self.metric_type == MetricType.L2:
return "vector_l2_ops"
elif self.metric_type == MetricType.IP:
return "vector_ip_ops"
return "vector_cosine_ops"

def parse_metric_fun_op(self) -> str:
if self.metric_type == MetricType.L2:
return "<->"
elif self.metric_type == MetricType.IP:
return "<#>"
return "<=>"
def parse_metric_fun_str(self) -> str:

def parse_metric_fun_str(self) -> str:
if self.metric_type == MetricType.L2:
return "l2_distance"
elif self.metric_type == MetricType.IP:
return "max_inner_product"
return "cosine_distance"



class HNSWConfig(PgVectorIndexConfig):
M: int
Expand Down Expand Up @@ -79,8 +77,8 @@ def search_param(self) -> dict:


class IVFFlatConfig(PgVectorIndexConfig):
lists: int
probes: int | None = None
lists: int | None = 1000
probes: int | None = 10
index: IndexType = IndexType.IVFFlat

def index_param(self) -> dict:
Expand All @@ -99,4 +97,4 @@ def search_param(self) -> dict:
_pgvector_case_config = {
IndexType.HNSW: HNSWConfig,
IndexType.IVFFlat: IVFFlatConfig,
}
}

0 comments on commit 0ba0675

Please sign in to comment.