pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: zthhhhh (@zthhhhh) <noreply+zthhhhh@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #1003: Support RabitQ in pgvector
Date: Wed, 29 Jul 2026 09:07:56 +0000
Message-ID: <gh-pgvector-pgvector-1003-c5115510396@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-1003@github.com>
References: <gh-pgvector-pgvector-1003@github.com>

## Query
I used this query to process benchmark with `dbpedia-openai-1000k-angular` dataset.

```sql
SELECT id FROM
(SELECT id, embedding FROM items
ORDER BY binary_quantize(embedding)::bit(1536) <~> binary_quantize(${query_vector}::halfvec(1536))
LIMIT ${rerank_candidates}) candidates 
ORDER BY embedding <=> ${query_vector}::halfvec(1536) LIMIT ${topk};

```

Add a benchmark parameter `rerank_candidate` for binary quantization experimental group, and it is swept in a full Cartesian product with the search parameter (probes in IVFFlat, ef_search in HNSW).

## Benchmark Configuration
- IVF configuration
	- lists = 1000
	- probes = 1, 2, 5, 10, 20, 50, 100, 200, 300, 500
	- rerank_candidate = 20, 40, 80, 100, 200, 500, 1000, 2000

- HNSW configuration
	- m = 16
	- ef_construction = 64
	- ef_search = 10, 20, 40, 80, 100, 200
	- rerank_candidate = 20, 40, 80, 100, 200


## Results and Analysis

Due to the large number of parameter combinations in the binary quantization experimental group, QPS-recall curves are used below
to visually compare RaBitQ against the binary quantization approach.

### IVF

<img width="1252" height="783" alt="Image" src="https://github.com/user-attachments/assets/e2062f22-87a0-4af8-8158-e65a98cd1b2e"; />

At the same `probes` setting, IVF RaBitQ achieves higher QPS than the binary quantization approach. In the binary quantization
IndexScan executor node, all vectors from the probed lists must be sorted by Hamming distance, which significantly increases query latency.

In contrast, RaBitQ leverages the theoretical error bound on its distance estimates (Formula 16 in the RaBitQ paper).
After computing distances via Algorithm 2, RaBitQ uses this bound to quickly eliminate vectors that cannot appear in the top-K results,
substantially reducing the number of vectors that need to be sorted.

### HNSW

<img width="1249" height="783" alt="Image" src="https://github.com/user-attachments/assets/e8fea191-b38d-47bf-bffe-af7272e560c6"; />

At the same `ef_search` setting, the binary quantization approach achieves lower recall than HNSW RaBitQ. In the HNSW search layer phase, a candidate set `W` is maintained based on computed distances, and these distances determine which vectors the search
visits next. With binary quantization, the inaccurate distance computation affects the selection of vectors in subsequent iterations, 
degrading recall. RaBitQ mitigates this with an unbiased distance estimator whose theoretical error bound keeps the search path
closer to that of exact distance, yielding higher recall at the same `ef_search`.


view thread (12+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-1003-c5115510396@github.com>
Permalink:  ../gh-pgvector-pgvector-1003-c5115510396@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox