Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix pgvectorivfflat reranking key bug #401

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions vectordb_bench/backend/clients/pgvector/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
from vectordb_bench.backend.clients import DB



def set_default_quantized_fetch_limit(ctx, param, value):
if ctx.params.get("reranking") and value is None:
# ef_search is the default value for quantized_fetch_limit as it's bound by ef_search.
return ctx.params["ef_search"]
# 100 is default value for quantized_fetch_limit for IVFFlat.
default_value = ctx.params["ef_search"] if ctx.command.name == "pgvectorhnsw" else 100
return default_value
return value

class PgVectorTypedDict(CommonTypedDict):
Expand Down Expand Up @@ -136,6 +137,9 @@ def PgVectorIVFFlat(
lists=parameters["lists"],
probes=parameters["probes"],
quantization_type=parameters["quantization_type"],
reranking=parameters["reranking"],
reranking_metric=parameters["reranking_metric"],
quantized_fetch_limit=parameters["quantized_fetch_limit"],
),
**parameters,
)
Expand Down
6 changes: 6 additions & 0 deletions vectordb_bench/backend/clients/pgvector/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@ class PgVectorIVFFlatConfig(PgVectorIndexConfig):
maintenance_work_mem: Optional[str] = None
max_parallel_workers: Optional[int] = None
quantization_type: Optional[str] = None
reranking: Optional[bool] = None
quantized_fetch_limit: Optional[int] = None
reranking_metric: Optional[str] = None

def index_param(self) -> PgVectorIndexParam:
index_parameters = {"lists": self.lists}
Expand All @@ -187,6 +190,9 @@ def index_param(self) -> PgVectorIndexParam:
def search_param(self) -> PgVectorSearchParam:
return {
"metric_fun_op": self.parse_metric_fun_op(),
"reranking": self.reranking,
"reranking_metric_fun_op": self.parse_reranking_metric_fun_op(),
"quantized_fetch_limit": self.quantized_fetch_limit,
}

def session_param(self) -> PgVectorSessionCommands:
Expand Down
2 changes: 1 addition & 1 deletion vectordb_bench/cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class HNSWBaseRequiredTypedDict(TypedDict):

class HNSWFlavor1(HNSWBaseTypedDict):
ef_search: Annotated[
Optional[int], click.option("--ef-search", type=int, help="hnsw ef-search")
Optional[int], click.option("--ef-search", type=int, help="hnsw ef-search", is_eager=True)
]


Expand Down