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: Tue, 12 Sep 2023 18:57:09 +0000
Message-ID: <gh-pgvector-pgvector-259-c1716258158@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-259@github.com>
References: <gh-pgvector-pgvector-259@github.com>
I'm not suggesting a B-tree (though perhaps we need some semantics like that at the top layer?), but rather, when we compute the distances between vectors, we compute two sets:
1. Just by `embedding` (and we maintain M links)
2. By `embedding` and `category_id` where we find all vectors that have the same `category_id` and maintain `M` links between these items
The thought process is that we want to reduce the number of embeddings we have to scan, but we want to ensure that our search is efficient. If we just keep the value in an `INCLUDE` column, we may not see the best available embeddings for a particularly `category_id` (or whatever the column is), or we may have to perform a more exhaustive search.
What I'm attempting to propose is a method to ensure our search is efficient and finds the best embeddings for a particular `category_id`, though at the cost of keeping additional info in the index and build time.