From: jkatz (@jkatz) <noreply+jkatz@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #665: Question: Performance gain in using halfvec datatype
Date: Tue, 03 Sep 2024 14:24:45 +0000
Message-ID: <gh-pgvector-pgvector-665-c2326664899@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-665@github.com>
References: <gh-pgvector-pgvector-665@github.com>
@bbkgh At the risk of a slightly unsatisfying answer, it depends on a few things, including:
1. Your access pattern (e.g., full table scans vs. index scans) and ultimately how many pages (units of storage) / vectors need to be compared.
1. Your chosen embedding model and how the data is ultimately clustered together in the vector index
1. How pgvector is compiled and on what architecture, as some architectures contain SIMD instructions that can speed up fp16 (`halfvec`) computations.
1. What your search parameters / recall targets are, which impact total number of vectors compared
In my own testing with a variety of embedding models on architectures that supported fp16 SIMD acceleration, with smaller numbers of vectors (low millions), I've seen either no performance difference, or `halfvec` edging out `vector` under high concurrency. However, in quantization cases, as the number of embeddings increased, I would need to increase `hnsw.ef_search` to get the same level of recall for `halfvec` compared to `vector`, though often I'd see both have comparable performance. I haven't tried doing comparisons yet with fixed recall on 100MM+ datasets, so I can't comment to far beyond that, but this is why my answer is a "it depends." :smile: