pgvector.git / summary / log / commit / refs
commit abd9963e66e6dfa7303b38e2ef1b43f26afcbec4
Author: Andrew Kane <andrew@ankane.org>
Date: Thu Apr 04 06:55:08 2024 +0000
Added half vectors section [skip ci]
README.md | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/README.md b/README.md
index ffc6dd65..a96c493b 100644
--- a/README.md
+++ b/README.md
@@ -419,6 +419,34 @@ 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);
```
+## Half Vectors
+
+*Unreleased*
+
+Note: Half vectors require compiler support to be performant
+
+Use the `halfvec` type to store half-precision vectors
+
+```sql
+CREATE TABLE items (id bigserial PRIMARY KEY, embedding halfvec(3));
+```
+
+## Half Indexing
+
+*Unreleased*
+
+Index vectors at half precision for smaller indexes and faster build times
+
+```sql
+CREATE INDEX ON items USING hnsw ((embedding::halfvec(3)) halfvec_l2_ops);
+```
+
+Get the nearest neighbors
+
+```sql
+SELECT * FROM items ORDER BY embedding::halfvec(3) <-> '[1,2,3]' LIMIT 5;
+```
+
## Binary Vectors
Use the `bit` type to store binary vectors ([example](https://github.com/pgvector/pgvector-python/blob/master/examples/hash_image_search.py))
[parent: 7e5df3c9fefb]