pg.ddx.io pgvector/pgvector GitHub issues and pull requestshelp / color / mirror / Atom feed
[pgvector/pgvector] issue #735: Compression rate with BQ and HNSW 3+ messages / 2 participants [nested] [flat]
* [pgvector/pgvector] issue #735: Compression rate with BQ and HNSW @ 2024-12-13 12:07 "xcu (@xcu)" <noreply+xcu@github.com> 0 siblings, 0 replies; 3+ messages in thread From: xcu (@xcu) @ 2024-12-13 12:07 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> I'm trying to test recall and speed for different BQ setups with HNSW indexes because the cost of the DB host for big-ish datasets becomes too high. I have noticed that reducing m parameter to construct the HNSW index results in a more compressed index that takes less space, and as a result I have to increase ef_construction to keep recall more or less at an acceptable level. For m=8, ef_search=512 and embeddings of 512 dimensions I am getting a 10:1 compression rate (as in, if the dataset required 100GB with HNSW flat, now it takes 10GB). I was wondering if you guys have any tips to get the best possible compression rate without affecting recall too much. I guess the best rate in theory would be 32:1 (4 bytes compressed into a bit), but when it comes to real life implementation the rate actually decreases. What would be the actual limits? Are there some docs giving an overview of how the indexes are built and what takes the extra space? ^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #735: Compression rate with BQ and HNSW @ 2024-12-13 15:56 ` "ankane (@ankane)" <noreply+ankane@github.com> 1 sibling, 0 replies; 3+ messages in thread From: ankane (@ankane) @ 2024-12-13 15:56 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> Hi @xcu, I don't have any additional advice (it sounds like you have a good understanding of the index options). HNSW element tuples take `72 + sizeof(vector)` bytes ([breakdown](https://github.com/pgvector/pgvector/blob/v0.8.0/src/hnsw.h#L328-L338)) and neighbor tuples take `4 + 6 * m * (level + 2)` bytes ([breakdown](https://github.com/pgvector/pgvector/blob/v0.8.0/src/hnsw.h#L342-L348)). There's also overhead for the Postgres [page layout](https://www.postgresql.org/docs/current/storage-page-layout.html) (and free space since tuples won't fit exactly on pages). ^ permalink raw [nested|flat] 3+ messages in thread
* Re: [pgvector/pgvector] issue #735: Compression rate with BQ and HNSW @ 2024-12-13 15:56 ` "ankane (@ankane)" <noreply+ankane@github.com> 1 sibling, 0 replies; 3+ messages in thread From: ankane (@ankane) @ 2024-12-13 15:56 UTC (permalink / raw) To: pgvector/pgvector <noreply+pgvector-pgvector@github.com> @ankane closed this. ^ permalink raw [nested|flat] 3+ messages in thread
end of thread, other threads:[~2024-12-13 15:56 UTC | newest] Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2024-12-13 12:07 [pgvector/pgvector] issue #735: Compression rate with BQ and HNSW "xcu (@xcu)" <noreply+xcu@github.com> 2024-12-13 15:56 ` "ankane (@ankane)" <noreply+ankane@github.com> 2024-12-13 15:56 ` "ankane (@ankane)" <noreply+ankane@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