pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #259: Understanding HNSW + filtering
Date: Thu, 01 Aug 2024 14:33:02 +0000
Message-ID: <gh-pgvector-pgvector-259-c2263231645@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-259@github.com>
References: <gh-pgvector-pgvector-259@github.com>

@lucasgadams Thanks for sharing, this is very helpful! I wanted to call out one particular comment:

> Pre-filtering is a must for this sort of thing, as individual companies might have very similar documents which means post-filtered searches are not going to be very accurate. 

On a theoretical basis, I don't agree that "post-filtered" searches aren't going to be accurate. It comes down to implementation: the challenge with a post-filtered search is that you'll need to see enough vectors in the index that satisfy all of the filtered conditions. Currently (as of v0.7.3) in pgvector, you may not be able to return enough tuples at a value of `hnsw.ef_search` to be able to satisfy it - and possibly with your case, you may not be able to achieve that at max `hnsw.ef_search`.

The way for pgvector to handle that would be to expand the search to additional neighborhoods until we satisfy the `LIMIT`, but this comes at cost of increased query time. So it raises a good question - is it more important to (1) return enough tuples (rows) to satisfy the LIMIT at the tradeoff of query latency, or is (2) query latency more important even if recall suffers? I believe for your case it's (2), but would love to hear more from others.

view thread (90+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-259-c2263231645@github.com>
Permalink:  ../gh-pgvector-pgvector-259-c2263231645@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