From 31e41b3ba96a0b8e94062e4f78ea33dee483fd50 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Sun, 24 Mar 2024 11:07:34 -0700 Subject: [PATCH] Added FAQ about binary vectors [skip ci] --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 8c54ed5..ff4de3a 100644 --- a/README.md +++ b/README.md @@ -604,6 +604,18 @@ and query with: SELECT * FROM items ORDER BY embedding::vector(3) <-> '[3,1,2]' LIMIT 5; ``` +#### Are binary vectors supported? + +You can store binary vectors and perform exact nearest neighbor search by Hamming distance in Postgres without an extension ([example](https://github.com/pgvector/pgvector-python/blob/master/examples/hash_image_search.py)). + +```tsql +CREATE TABLE items (id bigserial PRIMARY KEY, embedding bit(3)); +INSERT INTO items (embedding) VALUES (B'000'), (B'111'); +SELECT * FROM items ORDER BY bit_count(embedding # B'101') LIMIT 5; +``` + +Indexing is not currently supported. + #### Do indexes need to fit into memory? No, but like other index types, you’ll likely see better performance if they do. You can get the size of an index with: