pgvector.git / summary / log / commit / refs
commit d28b2cfccf56efca5a187fe2d51fa81025db0756
Author: Andrew Kane <andrew@ankane.org>
Date: Thu Apr 04 06:23:52 2024 +0000
Added binary vectors section [skip ci]
README.md | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/README.md b/README.md
index 2a665b77..cac98d60 100644
--- a/README.md
+++ b/README.md
@@ -419,6 +419,25 @@ Use [partitioning](https://www.postgresql.org/docs/current/ddl-partitioning.html
CREATE TABLE items (embedding vector(3), category_id int) PARTITION BY LIST(category_id);
```
+## Binary Vectors
+
+*Unreleased*
+
+Use the `bit` type to store binary vectors
+
+```sql
+CREATE TABLE items (id bigserial PRIMARY KEY, embedding bit(3));
+INSERT INTO items (embedding) VALUES ('000'), ('111');
+```
+
+Get the nearest neighbors by Hamming distance
+
+```sql
+SELECT * FROM items ORDER BY embedding <~> '101' LIMIT 5;
+```
+
+Also supports Jaccard distance (`<%>`)
+
## Binary Quantization
*Unreleased*
[parent: 6c4a115ebfdb]