diff --git a/bench/bench-vector.py b/bench/bench-vector.py index 8a7a1d8f..fbf13ede 100755 --- a/bench/bench-vector.py +++ b/bench/bench-vector.py @@ -250,11 +250,14 @@ class QdrantClient_(VectorClient): def __init__(self, host: str = "127.0.0.1", port: int = 6333): from qdrant_client import QdrantClient as _QC - from qdrant_client.models import Distance, VectorParams, PointStruct + from qdrant_client.models import ( + Distance, VectorParams, PointStruct, HnswConfigDiff, + ) self._qc = _QC(host=host, port=port) self._PointStruct = PointStruct self._Distance = Distance self._VectorParams = VectorParams + self._HnswConfigDiff = HnswConfigDiff self.collection_name = "bench_vectors" def setup(self, dim: int, metric: str = "cosine"): @@ -269,10 +272,10 @@ def setup(self, dim: int, metric: str = "cosine"): size=dim, distance=self._Distance.COSINE, ), - hnsw_config={ - "m": 16, - "ef_construct": 64, - }, + hnsw_config=self._HnswConfigDiff( + m=16, + ef_construct=64, + ), ) def insert_batch(self, ids: list, vectors: np.ndarray): @@ -290,14 +293,14 @@ def insert_batch(self, ids: list, vectors: np.ndarray): ) def query(self, vector: np.ndarray, k: int) -> list: - results = self._qc.search( + response = self._qc.query_points( collection_name=self.collection_name, - query_vector=vector.tolist(), + query=vector.tolist(), limit=k, ) return [ r.payload.get("name", str(r.id)) if r.payload else str(r.id) - for r in results + for r in response.points ] def teardown(self): diff --git a/bench/bench-vector.sh b/bench/bench-vector.sh index 517a35c7..b4b899ec 100755 --- a/bench/bench-vector.sh +++ b/bench/bench-vector.sh @@ -531,7 +531,17 @@ fi echo "hnsw: M=16, ef_construction=64, cosine similarity, k=$K" echo "" -if [[ "$EMBER_ONLY" == "true" ]]; then +if [[ "$EMBER_ONLY" == "true" ]] && [[ "$QDRANT" == "true" ]]; then + fmt="%-24s %14s %14s" + printf "$fmt\n" "metric" "ember" "qdrant" + printf "$fmt\n" "------" "-----" "------" + printf "$fmt\n" "insert (vectors/sec)" "$E_INSERT" "$Q_INSERT" + printf "$fmt\n" "query (queries/sec)" "$E_QUERY" "$Q_QUERY" + printf "$fmt\n" "query p50 (ms)" "$E_P50" "$Q_P50" + printf "$fmt\n" "query p95 (ms)" "$E_P95" "$Q_P95" + printf "$fmt\n" "query p99 (ms)" "$E_P99" "$Q_P99" + printf "$fmt\n" "memory (MB)" "$EMBER_RSS" "$QDRANT_RSS" +elif [[ "$EMBER_ONLY" == "true" ]]; then fmt="%-24s %14s" printf "$fmt\n" "metric" "ember" printf "$fmt\n" "------" "-----" @@ -586,7 +596,12 @@ if [[ "$SIFT_MODE" == "true" ]]; then E_RECALL=$(extract "$EMBER_JSON" "recall.recall_at_k") - if [[ "$EMBER_ONLY" == "true" ]]; then + if [[ "$EMBER_ONLY" == "true" ]] && [[ "$QDRANT" == "true" ]]; then + Q_RECALL=$(extract "$QDRANT_JSON" "recall.recall_at_k") + printf "%-24s %14s %14s\n" "metric" "ember" "qdrant" + printf "%-24s %14s %14s\n" "------" "-----" "------" + printf "%-24s %14s %14s\n" "recall@$K" "$E_RECALL" "$Q_RECALL" + elif [[ "$EMBER_ONLY" == "true" ]]; then printf "%-24s %14s\n" "metric" "ember" printf "%-24s %14s\n" "------" "-----" printf "%-24s %14s\n" "recall@$K" "$E_RECALL"