From d28b2cfccf56efca5a187fe2d51fa81025db0756 Mon Sep 17 00:00:00 2001 From: Andrew Kane Date: Wed, 3 Apr 2024 23:23:52 -0700 Subject: [PATCH] Added binary vectors section [skip ci] --- README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/README.md b/README.md index 2a665b7..cac98d6 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*