@@ -82,7 +82,7 @@ Get the nearest neighbors by L2 distance
82
82
SELECT * FROM items ORDER BY embedding < - > ' [3,1,2]' LIMIT 5 ;
83
83
```
84
84
85
- Also supports inner product (` <#> ` ), cosine distance (` <=> ` ), and L1 distance (` <+> ` , added in 0.7.0 )
85
+ Also supports inner product (` <#> ` ), cosine distance (` <=> ` ), and L1 distance (` <+> ` )
86
86
87
87
Note: ` <#> ` returns the negative inner product since Postgres only supports ` ASC ` order index scans on operators
88
88
@@ -146,9 +146,9 @@ Supported distance functions are:
146
146
- ` <-> ` - L2 distance
147
147
- ` <#> ` - (negative) inner product
148
148
- ` <=> ` - cosine distance
149
- - ` <+> ` - L1 distance (added in 0.7.0)
150
- - ` <~> ` - Hamming distance (binary vectors, added in 0.7.0 )
151
- - ` <%> ` - Jaccard distance (binary vectors, added in 0.7.0 )
149
+ - ` <+> ` - L1 distance
150
+ - ` <~> ` - Hamming distance (binary vectors)
151
+ - ` <%> ` - Jaccard distance (binary vectors)
152
152
153
153
Get the nearest neighbors to a row
154
154
@@ -235,19 +235,19 @@ Cosine distance
235
235
CREATE INDEX ON items USING hnsw (embedding vector_cosine_ops);
236
236
```
237
237
238
- L1 distance - added in 0.7.0
238
+ L1 distance
239
239
240
240
``` sql
241
241
CREATE INDEX ON items USING hnsw (embedding vector_l1_ops);
242
242
```
243
243
244
- Hamming distance - added in 0.7.0
244
+ Hamming distance
245
245
246
246
``` sql
247
247
CREATE INDEX ON items USING hnsw (embedding bit_hamming_ops);
248
248
```
249
249
250
- Jaccard distance - added in 0.7.0
250
+ Jaccard distance
251
251
252
252
``` sql
253
253
CREATE INDEX ON items USING hnsw (embedding bit_jaccard_ops);
@@ -256,9 +256,9 @@ CREATE INDEX ON items USING hnsw (embedding bit_jaccard_ops);
256
256
Supported types are:
257
257
258
258
- ` vector ` - up to 2,000 dimensions
259
- - ` halfvec ` - up to 4,000 dimensions (added in 0.7.0)
260
- - ` bit ` - up to 64,000 dimensions (added in 0.7.0)
261
- - ` sparsevec ` - up to 1,000 non-zero elements (added in 0.7.0)
259
+ - ` halfvec ` - up to 4,000 dimensions
260
+ - ` bit ` - up to 64,000 dimensions
261
+ - ` sparsevec ` - up to 1,000 non-zero elements
262
262
263
263
### Index Options
264
264
@@ -312,7 +312,7 @@ Note: Do not set `maintenance_work_mem` so high that it exhausts the memory on t
312
312
313
313
Like other index types, it’s faster to create an index after loading your initial data
314
314
315
- Starting with 0.6.0, you can also speed up index creation by increasing the number of parallel workers (2 by default)
315
+ You can also speed up index creation by increasing the number of parallel workers (2 by default)
316
316
317
317
``` sql
318
318
SET max_parallel_maintenance_workers = 7 ; -- plus leader
@@ -365,7 +365,7 @@ Cosine distance
365
365
CREATE INDEX ON items USING ivfflat (embedding vector_cosine_ops) WITH (lists = 100 );
366
366
```
367
367
368
- Hamming distance - added in 0.7.0
368
+ Hamming distance
369
369
370
370
``` sql
371
371
CREATE INDEX ON items USING ivfflat (embedding bit_hamming_ops) WITH (lists = 100 );
@@ -374,8 +374,8 @@ CREATE INDEX ON items USING ivfflat (embedding bit_hamming_ops) WITH (lists = 10
374
374
Supported types are:
375
375
376
376
- ` vector ` - up to 2,000 dimensions
377
- - ` halfvec ` - up to 4,000 dimensions (added in 0.7.0)
378
- - ` bit ` - up to 64,000 dimensions (added in 0.7.0)
377
+ - ` halfvec ` - up to 4,000 dimensions
378
+ - ` bit ` - up to 64,000 dimensions
379
379
380
380
### Query Options
381
381
@@ -547,8 +547,6 @@ Note: If this is lower than `ivfflat.probes`, `ivfflat.probes` will be used
547
547
548
548
## Half-Precision Vectors
549
549
550
- * Added in 0.7.0*
551
-
552
550
Use the ` halfvec ` type to store half-precision vectors
553
551
554
552
``` sql
@@ -557,8 +555,6 @@ CREATE TABLE items (id bigserial PRIMARY KEY, embedding halfvec(3));
557
555
558
556
## Half-Precision Indexing
559
557
560
- * Added in 0.7.0*
561
-
562
558
Index vectors at half precision for smaller indexes
563
559
564
560
``` sql
@@ -580,24 +576,16 @@ CREATE TABLE items (id bigserial PRIMARY KEY, embedding bit(3));
580
576
INSERT INTO items (embedding) VALUES (' 000' ), (' 111' );
581
577
```
582
578
583
- Get the nearest neighbors by Hamming distance (added in 0.7.0)
579
+ Get the nearest neighbors by Hamming distance
584
580
585
581
``` sql
586
582
SELECT * FROM items ORDER BY embedding < ~> ' 101' LIMIT 5 ;
587
583
```
588
584
589
- Or (before 0.7.0)
590
-
591
- ``` sql
592
- SELECT * FROM items ORDER BY bit_count(embedding # '101') LIMIT 5;
593
- ```
594
-
595
585
Also supports Jaccard distance (` <%> ` )
596
586
597
587
## Binary Quantization
598
588
599
- * Added in 0.7.0*
600
-
601
589
Use expression indexing for binary quantization
602
590
603
591
``` sql
@@ -620,8 +608,6 @@ SELECT * FROM (
620
608
621
609
## Sparse Vectors
622
610
623
- * Added in 0.7.0*
624
-
625
611
Use the ` sparsevec ` type to store sparse vectors
626
612
627
613
``` sql
@@ -655,8 +641,6 @@ You can use [Reciprocal Rank Fusion](https://github.com/pgvector/pgvector-python
655
641
656
642
## Indexing Subvectors
657
643
658
- * Added in 0.7.0*
659
-
660
644
Use expression indexing to index subvectors
661
645
662
646
``` sql
@@ -1171,6 +1155,12 @@ cd pgvector
1171
1155
docker build --pull --build-arg PG_MAJOR=17 -t myuser/pgvector .
1172
1156
```
1173
1157
1158
+ If you increase ` maintenance_work_mem ` , make sure ` --shm-size ` is at least that size to avoid an error with parallel HNSW index builds.
1159
+
1160
+ ``` sh
1161
+ docker run --shm-size=1g ...
1162
+ ```
1163
+
1174
1164
### Homebrew
1175
1165
1176
1166
With Homebrew Postgres, you can use:
@@ -1258,36 +1248,6 @@ You can check the version in the current database with:
1258
1248
SELECT extversion FROM pg_extension WHERE extname = ' vector' ;
1259
1249
```
1260
1250
1261
- ## Upgrade Notes
1262
-
1263
- ### 0.6.0
1264
-
1265
- #### Postgres 12
1266
-
1267
- If upgrading with Postgres 12, remove this line from ` sql/vector--0.5.1--0.6.0.sql ` :
1268
-
1269
- ``` sql
1270
- ALTER TYPE vector SET (STORAGE = external);
1271
- ```
1272
-
1273
- Then run ` make install ` and ` ALTER EXTENSION vector UPDATE; ` .
1274
-
1275
- #### Docker
1276
-
1277
- The Docker image is now published in the ` pgvector ` org, and there are tags for each supported version of Postgres (rather than a ` latest ` tag).
1278
-
1279
- ``` sh
1280
- docker pull pgvector/pgvector:pg16
1281
- # or
1282
- docker pull pgvector/pgvector:0.6.0-pg16
1283
- ```
1284
-
1285
- Also, if you’ve increased ` maintenance_work_mem ` , make sure ` --shm-size ` is at least that size to avoid an error with parallel HNSW index builds.
1286
-
1287
- ``` sh
1288
- docker run --shm-size=1g ...
1289
- ```
1290
-
1291
1251
## Thanks
1292
1252
1293
1253
Thanks to:
0 commit comments