pgvector.git / summary / log / commit / refs

commit    31e41b3ba96a0b8e94062e4f78ea33dee483fd50
Author:   Andrew Kane <andrew@ankane.org>
Date:     Sun Mar 24 18:07:34 2024 +0000

    Added FAQ about binary vectors [skip ci]


README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 8c54ed54..ff4de3a2 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: [parent: 903a925662f8]