pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
From: ankane (@ankane) <noreply+ankane@github.com>
To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>
Subject: Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
Date: Sun, 22 Sep 2024 07:12:06 +0000
Message-ID: <gh-pgvector-pgvector-461-c2365655349@github.com> (raw)
In-Reply-To: <gh-pgvector-pgvector-461@github.com>
References: <gh-pgvector-pgvector-461@github.com>

For vectors between 2k and 4k dimensions, the simplest approach is to use the `halfvec` type ([docs](https://github.com/pgvector/pgvector?tab=readme-ov-file#half-precision-vectors)).

```sql
CREATE TABLE items (id bigserial PRIMARY KEY, embedding halfvec(3072));
CREATE INDEX ON items USING hnsw (embedding halfvec_cosine_ops);
```

You can also store the full vectors in the table and use half-precision indexing ([docs](https://github.com/pgvector/pgvector?tab=readme-ov-file#half-precision-indexing)).

```sql
CREATE TABLE items (id bigserial PRIMARY KEY, embedding vector(3072));
CREATE INDEX ON items USING hnsw ((embedding::halfvec(3072)) halfvec_cosine_ops);

-- and query with
SELECT * FROM items ORDER BY embedding::halfvec(3072) <=> '[1,2,3]' LIMIT 5;
```

view thread (61+ messages)  latest in thread

Message-ID: <gh-pgvector-pgvector-461-c2365655349@github.com>
Permalink:  ../gh-pgvector-pgvector-461-c2365655349@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox