pg.ddx.io  pgvector/pgvector GitHub issues and pull requests  
help / color / mirror / Atom feed
[pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
61+ messages / 29 participants
[nested] [flat]

* [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-02-16 09:37  "VincentEggerling (@VincentEggerling)" <noreply+VincentEggerling@github.com>
  0 siblings, 0 replies; 61+ messages in thread

From: VincentEggerling (@VincentEggerling) @ 2024-02-16 09:37 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hello ! I'm wondering what are the reasons for the maximal dimension limit for indexes HNSW and IVFFlat.
Checking _really quickly_ the code, I see those `HNSW_MAX_DIM` and `IVFFLAT_MAX_DIM` constants set to 2000 which seem arbitrary to me, as a non-educated user. 

- Why do we have these limits ?
- How would performance scale if the limited were, say, doubled ? 
- Is there a plan to increase the limits, considering other vector database products offer up to 32768 dimensions (or even more) for indexed vector ?

Thank you !

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-02-16 15:35  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-02-16 15:35 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@VincentEggerling

> Why do we have these limits ?

There's been quite a bit of discussion on this topic -- the primary limitation is due to the default size of the PostgreSQL page (8KB), which is not adjustable, which constrains the number of 4-byte floats you can store on a page. There are some branches that address this (e.g. the `tiny` and `half` branch) that lets you store vectors with more dimensions but a smaller attribute value. There's also an open idea on implementing quantization, particularly product quantization (https://github.com/pgvector/pgvector/issues/27).

> How would performance scale if the limited were, say, doubled ?

Just increasing the limit would not decrease performance 😉 For storing and searching over vectors with more dimensions, it depends on a variety of factors, including the size of the dimensions or if any additional storage techniques are used.

> Is there a plan to increase the limits, considering other vector database products offer up to 32768 dimensions (or even more) for indexed vector 

Yes, but part of that will drive that is  understanding what use cases require that increase, and the different tradeoffs that come with increasing the indexable dimensionality. 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-04 09:59  "kevintanhongann (@kevintanhongann)" <noreply+kevintanhongann@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: kevintanhongann (@kevintanhongann) @ 2024-03-04 09:59 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

I wish it can be increased to 4096 or more than that, based on what i have tested. No matter when it's the string of question answer pairs or even an extracted text from the a PDF document. I was mentioning BRIN or GIN before, but that was just based on the result of researching using Microsoft Copilot. Do let me know if there is a way to workaround this. Thanks. 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-08 11:00  "HectorBst (@HectorBst)" <noreply+HectorBst@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: HectorBst (@HectorBst) @ 2024-03-08 11:00 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

It would be very interesting to be able to increase this limit beyond 2000. The new mistral-derivative embedding models (4096 dims) and OpenAI’s new text-embedding-3-large model (3072 dims) offer very good performances, but are not yet compatible with pgvector. We're likely to see more and more good models with an increasing number of dimensions.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-08 12:21  "yashukla47 (@yashukla47)" <noreply+yashukla47@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: yashukla47 (@yashukla47) @ 2024-03-08 12:21 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Yes, we are also using a text-embedding-3-large model (3072 dims) and it'll be really helpful if the limit is increased to somewhere around 3072 or 4096. @jkatz  what do you think by when can we expect it ? 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-09 05:47  "brpy (@brpy)" <noreply+brpy@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: brpy (@brpy) @ 2024-03-09 05:47 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

This would enable us to use newer OpenAI embedding models, that support upto (3072 dims).

The newer models seems to outperform the older ada002 embedding model, even with compressed to 256 dims. This feature would enable us to try out the newer model with full dimensions on postgres.

Thank you!

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-13 01:49  "GPF199541 (@GPF199541)" <noreply+GPF199541@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: GPF199541 (@GPF199541) @ 2024-03-13 01:49 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

+1

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-18 12:54  "AnonymousBoy (@AnonymousBoy)" <noreply+AnonymousBoy@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: AnonymousBoy (@AnonymousBoy) @ 2024-03-18 12:54 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

pgvecto.rs could support up to 65535 dimensions, could pgvector also support it?

https://github.com/tensorchord/pgvecto.rs

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-18 17:26  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-03-18 17:26 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> pgvecto.rs could support up to 65535 dimensions, could pgvector also support it?

Are there examples of use cases with vectors of that high dimensionality that are being used with vector databases? I know there are some cases in the "up to 4,096 dimension" range (such as the cited ada003 model above), but I'm curious what is being used beyond that.

Unless something has changed since I last checked, pgvecto.rs bypasses the PostgreSQL storage system, which makes it easier to index vectors that are larger than 8KB, with the tradeoff that you're losing [ACID](https://en.wikipedia.org/wiki/ACID) (especially the "[D](https://en.wikipedia.org/wiki/Durability_(database_systems))";) guarantees. Based on what you're doing with your application, that may be an acceptable tradeoff and allows you to index larger vectors in PostgreSQL today, though I'd advise that the PostgreSQL storage system provides a lot of infrastructure around data management that's easy to take for granted (and I certainly have while going on this vector journey!).

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-29 01:43  "shao-shuai (@shao-shuai)" <noreply+shao-shuai@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: shao-shuai (@shao-shuai) @ 2024-03-29 01:43 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

<img width="1200" alt="image" src="https://github.com/pgvector/pgvector/assets/28980017/4565f6b6-e10f-475d-b516-0cf3e495e64a";
some of the latest embedding models have dimension over 2000, if we can increase the limit to at least 4096, that would be super helpful to get pgvector involved in the development and test of embedding models.
https://huggingface.co/spaces/mteb/leaderboard

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-29 04:28  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-03-29 04:28 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Per https://github.com/pgvector/pgvector/issues/326#issuecomment-2024106976 and https://github.com/pgvector/pgvector/issues/395#issuecomment-2024089498 there are now proposed patches that would allow for the increasing of max dimension.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-30 12:00  "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: wmwsagara (@wmwsagara) @ 2024-03-30 12:00 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

**TL;DR:** 
This is a proposal for pgvector to support lot more than 2000 fp32 vector dimensions without modifying PostgreSQL or lower the accuracy of vector embeddings.

It is not possible to support more than 2000 vector dimensions! See @jkatz  first post: "the primary limitation is due to the default size of the PostgreSQL page (8KB), which is not adjustable ...". 

8K, 8192/4 = 2048. 
floating point 32bit (fp32) or float is 4 bytes.
Max dimensions: 2000
Allocation for Overhead: 48


There are 3 solutions available:
1. Modify PostgreSQL
Ask the PostgreSQL developers to offer an option configure PostgreSQL page size at PostgreSQL server start time. This has the possible negative consequences for PostgreSQL IO pipeline. It's may be too risky and may require extensive testing. Therefore, to the most probability, PostgreSQL developers may turn down this request, or may take quite long to get developed.


2. Go for lower accuracy
fp16:
8000/2 = 4000
Max dimensions: 4000
Still 4096 dimensions cannot support!
Require to go even lower accuracy to support 4096. How about 8K dimensions? It might hit 8K by next year.

There can be some application domains lowering accuracy may be bearable. There can be domains, cannot risk to lower the accuracy.


**3. Proposal - split the document table**

Text part is in the document table, embeddings are in a separate embedding table. There may be one or more records in the embedding table for a one document, each embedding record support up to max 2000 dimensions. 

The document table record layout:
document_reference - string
content - text

The embedding table record layout:
document_reference - string
seq_no - number
embedding [] - array

Indexed by: document_reference+seq_no

To support 3072 dimensions, you need two (2) records in the embedding table. 
To support 4096 dimensions, you need three (3) records in the embedding table. 

When build the index (eg. HNSW), read all embedding records for a document and reconstruct the original dimensions required (eg. 4096) for the document just by append them sequentially. Rest are all in memory operations.

To build the index, pgvector has to read only the embedding table in document_reference+seq_no order.

The document_reference can be a UUID or any other string.

Advantageous:
a) No need to modify PostgreSQL.
b) Fully ACID compliant.
c) No maximum limit for number of fp32 vector dimensions can be supported.
d) Straight away can be implemented without depending on any third party.

disadvantageous:
a) Require to restructure pgvector.

I think, it is possible to offer a hybrid version. That is, no change to user's code up to 2000 dimensions. That is, text and embedding can reside in one table record.

But if the user require more than 2000 dimensions, all embeddings are read from embedding table.

Best regards
Sagara

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-30 12:38  "KnightMurloc (@KnightMurloc)" <noreply+KnightMurloc@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: KnightMurloc (@KnightMurloc) @ 2024-03-30 12:38 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> Modify PostgreSQL

The size of Postgres pages can be increased via the compilation parameter (--with-blocksize) up to 32 KB. Which should allow to create vectors up to 8192 dim.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-30 16:10  "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: wmwsagara (@wmwsagara) @ 2024-03-30 16:10 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Thank you @KnightMurloc for the insight. 

The --with-blocksize is defined here: https://www.postgresql.org/docs/16/install-make.html

I think @jkatz is a PostgreSQL developer, I'm not. @jkatz could you enlighten us why the --with-blocksize cannot be used? 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-30 16:50  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-03-30 16:50 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@wmwsagara For your proposals, if we look at the tests in https://github.com/pgvector/pgvector/issues/326#issuecomment-2027930516 we see that the fp16 quantization proposal that allows for increasing dims to 4,000 has almost no impact on recall.

While the PostgreSQL table ("heap") block size is adjustable, the index block size isn't. [This thread](https://www.postgresql.org/message-id/flat/CAAjvh2Q6MVRip0AJuWe0TyHjhujmpJHFAmWtXZMefCVnZDJ17w%40mai...) outlines where the restriction is, and the effort it'd take to adjust.

At [PGConf.dev 2024](https://2024.pgconf.dev/), I'm planning to [discuss this topic and some proposals to better address this upstream](https://www.pgevents.ca/events/pgconfdev2024/schedule/session/1-vectors-how-to-better-support-a-nast...).

"Proposal 3" is somewhat similar to HOT chaining, which I [lightly discussed in 2023](https://www.slideshare.net/jkatz05/vectors-are-the-new-json-in-postgresql). While this would allow for storing larger dimensions, it itself has tradeoffs as index lookups require fetching multiple pages per comparison. We would likely want some methodology where we could fetch pages in parallel, but the overhead of that could be too much at the moment and requires more research.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-03-31 12:10  "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: wmwsagara (@wmwsagara) @ 2024-03-31 12:10 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@jkatz 
Wish you good luck for your lecture at the PGConf.dev 2024. Hopefully it may leads to development of an acceptable solution this issue. Please try to video record your presentation and release on YouTube, so that we all can see it.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-04-01 09:03  "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: wmwsagara (@wmwsagara) @ 2024-04-01 09:03 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Dear @jkatz, GPT4 and Gemini both says "--with-blocksize parameter controls the size of both the table (heap) blocks and the index blocks in PostgreSQL". 

![Screenshot from 2024-04-01 16-54-31](https://github.com/pgvector/pgvector/assets/94213268/b5e1cb64-67bd-4f40-86ac-57abfa532958)

![Screenshot from 2024-04-01 16-56-30](https://github.com/pgvector/pgvector/assets/94213268/845f2745-bb3d-4ff3-8799-808f5fdff9ef)



^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-04-01 14:25  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-04-01 14:25 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@wmwsagara Both are wrong. While that would increase the page size, it doesn't increase the index tuple size, which is fixed at 8K. Please see this [thread (which I'm reposting)](https://www.postgresql.org/message-id/flat/2270943.1705592806%40sss.pgh.pa.us#3099a59ad6176e5880327f...).

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-04-03 10:41  "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: wmwsagara (@wmwsagara) @ 2024-04-03 10:41 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@jkatz 

1. Agree "GPT4 kind of sucks" :)
2. Looks IndexTupleSize(itup) macro in src/include/access/itup.h, if exclusive use to get the index tuple size, then this macro together with --with-blocksize are sufficient to solve this issue. Since anyway, require to recompile PostgreSQL, let the macro return 32K or conditionally 32K. And do not use this modified instance of PostgreSQL for anything other than AI/ML. 
3. People can give it a try to above, if pgvector devs can develop a patch to pgvector itself to support vector dimensions up to 8000.

Any thoughts from anyone?




^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-04-05 04:33  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-04-05 04:33 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

I think the `halfvec` (4K dims), `intvec` (8K dims), and the `bit` vector (64K dims) provide a lot of options for supporting vectors with larger dimensions. The largest embedding models I've seen that are used in databases have been 4K dims, so I'd like to see more use-cases for supporting indexing vectors with 4-byte float dimensions where we really need to store more info than a 2-byte float et al.

For what it's worth, I do think we should work to support indexing larger vectors, but current evidence shows that we can get equivalent recall between fp32 / fp16 indexes, which allows us to spend more time figuring out how to better support the case where the data goes beyond the 8KB limit.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-05-06 00:22  "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: t-zuehlsdorff (@t-zuehlsdorff) @ 2024-05-06 00:22 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Just as a question from another point of view (and a total amateur): shouldn't it be possible to use GIN (or Gist) Indizes for higher dimensions? Full Text Search and JsonB are implemented like this- and i believe the 8 KB limit does not apply there? Just a guess.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-05-07 02:30  "MMeent (@MMeent)" <noreply+MMeent@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: MMeent (@MMeent) @ 2024-05-07 02:30 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> We would likely want some methodology where we could fetch pages in parallel, but the overhead of that could be too much at the moment and requires more research.

FYI, starting with PG17 (assuming it won't be reverted) there are [new APIs](https://github.com/postgres/postgres/commit/210622c60e1a9db2e2730140b8106ab57d259d15) that allow more efficient reading of sequential data from disk, using read sizes of multiple pages at a time.

I'm not sure how accessible it is yet, nor whether it's good enough for e.g. index AMs to use yet, but it seems like it might help with the performance picture.


^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-05-13 13:52  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-05-13 13:52 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> > We would likely want some methodology where we could fetch pages in parallel, but the overhead of that could be too much at the moment and requires more research.
> 
> FYI, starting with PG17 (assuming it won't be reverted) there are [new APIs](https://github.com/postgres/postgres/commit/210622c60e1a9db2e2730140b8106ab57d259d15) that allow more efficient reading of sequential data from disk, using read sizes of multiple pages at a time.
> 
> I'm not sure how accessible it is yet, nor whether it's good enough for e.g. index AMs to use yet, but it seems like it might help with the performance picture.

It'd at least be worth the experimentation, though I'd still recommend prioritizing the work around index scans that include filters, as pgvector is currently holding its own on performance.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-08-01 09:17  "legaltextai (@legaltextai)" <noreply+legaltextai@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: legaltextai (@legaltextai) @ 2024-08-01 09:17 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

As many have said already, with new longer context embedding models -> higher dimensions -> it 'd be really great if pgvector could support those. +1 to this idea. 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-10 10:11  "sandys (@sandys)" <noreply+sandys@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: sandys (@sandys) @ 2024-09-10 10:11 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

is there a way to write a trigger to automatically split a 3072 column into two smaller columns ? this is specifically to solve the indexing problem. however, vector doesnt allow subscripting, so the triggers arent working. has anyone gotten this to work ?

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-10 11:31  "touhi99 (@touhi99)" <noreply+touhi99@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: touhi99 (@touhi99) @ 2024-09-10 11:31 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

+1 , any workaround specially when dealing with text-embedding-3-large embedding?

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-10 17:01  "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: t-zuehlsdorff (@t-zuehlsdorff) @ 2024-09-10 17:01 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@sandys @touhi99 I have a nearly finished, a little bit absurd, workaround for this issue, but it works even for 65K dimensions. I hesitate to share it online because of its absurdity, but if you like, i can share it with you in private for some feedback. [I am currently very booked, so it can take a while, but feel free to contact me]

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-10 19:12  "sandys (@sandys)" <noreply+sandys@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: sandys (@sandys) @ 2024-09-10 19:12 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@t-zuehlsdorff would love to see a solution (even though it is absurd). i dont see ur email, but here's mine - http://scr.im/2ezk

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-10 19:40  "touhi99 (@touhi99)" <noreply+touhi99@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: touhi99 (@touhi99) @ 2024-09-10 19:40 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> @sandys @touhi99 I have a nearly finished, a little bit absurd, workaround for this issue, but it works even for 65K dimensions. I hesitate to share it online because of its absurdity, but if you like, i can share it with you in private for some feedback. [I am currently very booked, so it can take a while, but feel free to contact me]

would love to know, essentially im stuck in a project and will try if some solution works!

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-21 02:50  "lmaddox (@lmaddox)" <noreply+lmaddox@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: lmaddox (@lmaddox) @ 2024-09-21 02:50 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

How to use pgvectorestore with ollama embeddings? So far as I can tell, embed dims must be 4096.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-21 12:19  "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: t-zuehlsdorff (@t-zuehlsdorff) @ 2024-09-21 12:19 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@lmaddox You can use the operators on this vectors. But you can't use the indices sadly. I am also using Ollama.

BTW to the rest: I am currently doing a test run of my solution to measure the recall. If it's acceptable i will give you my email for a first preview of the idea. :) 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-21 14:51  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-09-21 14:51 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@lmaddox @t-zuehlsdorff This isn't entirely accurate, though the indexing portion will come with a tradeoff of losing precision (and possibly recall).

With pgvector 0.7.0, you can use [binary quantization](https://jkatz05.com/post/postgres/pgvector-scalar-binary-quantization/) to store vectors over 2K/4K dimensions, e.g., though you will almost definitely need to re-rank, e.g.:

```sql
CREATE TABLE your_table (
    -- ...
    embedding vector(4096)
    -- ...
);

CREATE INDEX ON your_table
    USING hnsw ((binary_quantize(embedding)::bit(4096)) bit_hamming_ops);

-- query
SELECT i.id
FROM (
    SELECT id, embedding <=> $1 AS distance
    FROM items
    ORDER BY binary_quantize(embedding)::bit(4096) <~> binary_quantize($1)
    LIMIT 100 -- in v0.7.x, recommend setting to your value of `hnsw.ef_search`
) i
ORDER BY i.distance
LIMIT 10;
```

(With some of the work in [hnsw-streaming](https://github.com/pgvector/pgvector/tree/hnsw-streaming), the guidance may change on the `LIMIT`/`hnsw.ef_search` ratio in the subquery).

But this will at least help you benefit from using the index, though you likely have to use a higher `hnsw.ef_search` to get acceptable recall.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-22 06:06  "ThomasVitale (@ThomasVitale)" <noreply+ThomasVitale@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: ThomasVitale (@ThomasVitale) @ 2024-09-22 06:06 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

In case it's useful to people, here's a temporary tip to use Ollama for embeddings paired with PGVector.

The multi-purpose models in the Ollama library (like `mistral` and `llama3.1`) seem to have been all configured with 4096 dimensionality, which cannot be changed as of now on the Ollama side, and therefore doesn't work with PGVector out of the box.

However, dedicated embedding models like `nomic-embed-text` (full list here: https://ollama.com/search?q=&c=embedding) are configured with different dimensionality. In many cases, it's lower than 2000, so they all can be used with PGVector.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-22 06:54  "sandys (@sandys)" <noreply+sandys@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: sandys (@sandys) @ 2024-09-22 06:54 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ThomasVitale @jkatz like a lot of people here, we use MTEB embedding models or OpenAI text-embedding-3-large (which is 3072).

I'm doing this right now, do u see a problem in this versus quantization ? which one do u think is better ?

```
-- Step 1: Create HNSW indexes on both vector columns
CREATE INDEX idx_embeddings_part1_hnsw ON llmmodel_schema.da_sceinaptic_chunks_embeddings_v1 
USING hnsw (embeddings_part1 vector_cosine_ops) 
WITH (m = 16, ef_construction = 64);

CREATE INDEX idx_embeddings_part2_hnsw ON llmmodel_schema.da_sceinaptic_chunks_embeddings_v1 
USING hnsw (embeddings_part2 vector_cosine_ops) 
WITH (m = 16, ef_construction = 64);

-- Step 2: Create a custom similarity search function
CREATE OR REPLACE FUNCTION search_similar_vectors_split(
    query_vector1 vector(2000),
    query_vector2 vector(1072),
    n integer,
    ef_search integer DEFAULT 40
)
RETURNS TABLE(
    id bigint,
    url text,
    docket text,
    similarity float
) AS $$
BEGIN
    -- Set HNSW ef_search parameter
    EXECUTE format('SET hnsw.ef_search = %s', ef_search);

    RETURN QUERY
    SELECT 
        t.id,
        t.url,
        t.docket,
        (1 - (t.embeddings_part1 <=> query_vector1) * 2000 / 3072) + 
        (1 - (t.embeddings_part2 <=> query_vector2) * 1072 / 3072) AS similarity
    FROM llmmodel_schema.da_sceinaptic_chunks_embeddings_v1 t
    ORDER BY 
        t.embeddings_part1 <-> query_vector1 + 
        t.embeddings_part2 <-> query_vector2
    LIMIT n;
END;
$$ LANGUAGE plpgsql;

-- Example usage:
-- SELECT * FROM search_similar_vectors_split(
--     '[0.1, 0.2, ..., 0.1]'::vector(2000),  -- Replace with actual 2000-dim vector
--     '[0.3, 0.4, ..., 0.2]'::vector(1072),  -- Replace with actual 1072-dim vector
--     10,  -- number of results
--     100  -- ef_search
-- );
```

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-22 07:12  "ankane (@ankane)" <noreply+ankane@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: ankane (@ankane) @ 2024-09-22 07:12 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@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;
```

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-22 18:43  "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: t-zuehlsdorff (@t-zuehlsdorff) @ 2024-09-22 18:43 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@jkatz I know about the quantification, but the lost precision is unacceptable in my use case. Basically, we are paid by the quality of our results and having even slightly worse results is very costly for us. :D  

My solutions is fast, but currently only gets a recall of about 50. That is a little bit annoying, but a step forward. I basically recreated the idea of the index in plain SQL. Not as fast as using PG itself, but it has a consistent result-timing.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-25 06:46  "jayong-sv (@jayong-sv)" <noreply+jayong-sv@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jayong-sv (@jayong-sv) @ 2024-09-25 06:46 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane  It works well, Thank you so much!

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-27 04:22  "MSWinds (@MSWinds)" <noreply+MSWinds@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: MSWinds (@MSWinds) @ 2024-09-27 04:22 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

I used llamaindex's PGVectorStore.from_params() function, changing embed_dim from 1536 to 3072 and hnsw_kwargs to None. It should be fine, right? Just lost the ability to utilize the algorithms.


^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-30 20:09  "nathan-vo810 (@nathan-vo810)" <noreply+nathan-vo810@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: nathan-vo810 (@nathan-vo810) @ 2024-09-30 20:09 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Out of curiosity, I've recently learned that the limit for pgvector dimensions is 2000. However, I've been using Langchain with pgvector and the text-embedding-3-large model, which has 3072 values in its embeddings. When I manage the database with pgAdmin, I can still see all 3072 values.

Is this a bug, or am I missing something?

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-09-30 20:27  "ankane (@ankane)" <noreply+ankane@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: ankane (@ankane) @ 2024-09-30 20:27 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

The limit for the `vector` type is 16,000 dimensions ([docs](https://github.com/pgvector/pgvector?tab=readme-ov-file#vector-type)). 2,000 is the limit for indexing it (you'll see an error if you try).

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-10-01 12:22  "nathan-vo810 (@nathan-vo810)" <noreply+nathan-vo810@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: nathan-vo810 (@nathan-vo810) @ 2024-10-01 12:22 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

I have one more question. Does the 2,000 limit for index also affect the
vector search? As currently, I can still perform the hybrid search (
https://github.com/pgvector/pgvector-python/blob/master/examples/hybrid_search/rrf.py
) on that.

On Mon, Sep 30, 2024 at 10:28 PM Andrew Kane ***@***.***>
wrote:

> The limit for the vector type is 16,000 dimensions (docs
> <https://github.com/pgvector/pgvector?tab=readme-ov-file#vector-type;).
> 2,000 is the limit for indexing it (you'll see an error if you try).
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/pgvector/pgvector/issues/461#issuecomment-2384086468;,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ADLF2AR4Q7UPFQJKKRTRVZLZZGX5LAVCNFSM6AAAAABDLXA3EK...;
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>


^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-10-01 15:33  "ankane (@ankane)" <noreply+ankane@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: ankane (@ankane) @ 2024-10-01 15:33 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

The limit only applies to vector indexes. You can perform exact nearest neighbor search without a vector index (like in the example).

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-10-01 17:34  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-10-01 17:34 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> @jkatz I know about the quantification, but the lost precision is unacceptable in my use case. Basically, we are paid by the quality of our results and having even slightly worse results is very costly for us. :D
> 
> My solutions is fast, but currently only gets a recall of about 50. That is a little bit annoying, but a step forward. I basically recreated the idea of the index in plain SQL. Not as fast as using PG itself, but it has a consistent result-timing.

Have you tried re-ranking as part of quantization? If so, I'm curious on your results.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-11-11 08:45  "orentet (@orentet)" <noreply+orentet@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: orentet (@orentet) @ 2024-11-11 08:45 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

This dimension limitation is a critical blocker that prevents our organization from using pgvector, forcing us to maintain a separate vector database instead of leveraging our existing PostgreSQL infrastructure. We've evaluated the proposed workarounds like halfvec and quantization, but the reduction in accuracy is unacceptable for our use case. The ability to index higher-dimensional vectors (3072+ dimensions) while maintaining full precision would be transformative for our ability to consolidate on PostgreSQL.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-11-11 09:34  "rohitghatol (@rohitghatol)" <noreply+rohitghatol@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: rohitghatol (@rohitghatol) @ 2024-11-11 09:34 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

What is the difference between this and pgvecto.rs and this ? How come pgvecto.rs supports dimension size of 65k?

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-11-11 11:15  "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: t-zuehlsdorff (@t-zuehlsdorff) @ 2024-11-11 11:15 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> What is the difference between this and pgvecto.rs and this ? How come pgvecto.rs supports dimension size of 65k?

Youf find the difference explained here:
https://github.com/tensorchord/pgvecto.rs?tab=readme-ov-file#comparison-with-pgvector

They handle the indexing outside of PostgreSQL. So the can support more dimensions but currently have no WAL Support for Indexing.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-11-11 14:33  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-11-11 14:33 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

I think there are a few things - first, that comparison chart linked above is not accurate as of this writing, and I'd state things a little differently.

"WAL support" is directly tied to durability (the `D` of [ACID](https://en.wikipedia.org/wiki/ACID)), meaning that if a transaction is committed, the data is guaranteed to be stored regardless of a system failure. That's a very powerful (if not the most important) guarantee when working with data in a database. As the pgvecto.rs authors demonstrate, there's write-overhead to using that, but that's up to you to decide on what tradeoffs are more important (e.g. I need to store higher dimensional vectors and understand the risks associated to bypassing the PostgreSQL durability mechanism - there are cases where that tradeoff is acceptable). I haven't looked at pgvecto.rs in depth in awhile, so I'm not sure what other ACID tradeoffs there are.

I don't really want to do a "this-or-that" comparison between the two projects, but I'll clarify a few points related to pgvector:

* **Filtering** - [pgvector v0.8.0](https://github.com/pgvector/pgvector/blob/master/CHANGELOG.md#080-2024-10-30) changed a lot around [filtering](https://github.com/pgvector/pgvector?tab=readme-ov-file#filtering) (I'll personally be writing / presenting more about this topic int he coming weeks), and now has the appropriate mechanisms to avoid the "overfiltering" problem.
* **SIMD** - pgvector has supported SIMD through compilation since at least I started with the project almost 2 years ago, primarily through the use of autovectorization and other compiler flags. The v0.7.0 work was on explicit dispatching for x86-64 architecture, but SIMD was already supported
* **Data types** - pgvector introduced `vector`, `halfvec` (fp16), and `sparsevec`, and leverages the upstream data type binary vectors ([`bit`](https://www.postgresql.org/docs/current/datatype-bit.html)). There are branches open for a few others ([`intvec`](https://github.com/pgvector/pgvector/tree/intvec), [`minivec`](https://github.com/pgvector/pgvector/tree/minivec)), with supported dependent on a variety factors (such as your use cases!)

So this comes into the question at hand - what about maximizing limits? Today, while you can use, for example, a cast from `vector` to `halfvec`, yes that can certainly lose information as part of the search and return less than ideal results. However, to understand the best path forward, where it's an existing solution for further development, it'd help to unpack this:

> This dimension limitation is a critical blocker that prevents our organization from using pgvector, forcing us to maintain a separate vector database instead of leveraging our existing PostgreSQL infrastructure. We've evaluated the proposed workarounds like halfvec and quantization, but the reduction in accuracy is unacceptable for our use case. The ability to index higher-dimensional vectors (3072+ dimensions) while maintaining full precision would be transformative for our ability to consolidate on PostgreSQL.

@orentet For example, what is your recall target? What are you currently achieving? How much data are you storing in your index? What does your schema look like? What query patterns do you have? Are you doing any reranking (e.g. searching over the `halfvec` index, then doing a final reordering on the full vector in the table?). Do you have any filters on the data? Understanding details helps to guide what next steps may be.

That said, at [PGConf.eu 2024](https://2024.pgconf.eu/) I had a long discussion with one of the PostgreSQL committers around expanding the buffer/page size for indexes and potential paths forward. First, this would be a very big project (at least what we were discussing), and, at least as discussed, it would create additional configurations on the PostgreSQL side to support embeddings that go past 8KB. But, it would allow for continuance of relying on PostgreSQL storage mechanisms (e.g. durability) for these larger vector types.

Additionally, there may be ways shorter term to achieve storing larger vectors (e.g. page chaining), but that could potentially lead to performance crunches that may make it unsuitable, but it's likely worth the experiment  to try.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-11-29 07:08  "rohitghatol (@rohitghatol)" <noreply+rohitghatol@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: rohitghatol (@rohitghatol) @ 2024-11-29 07:08 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Let’s say I have a dimension limit of 6000 for example but I use a sparse vector with say 20 non zero values at most.

“Does the 2,000-dimension limit for indexing in pgvector apply to sparse vectors as well, or is the limit determined by the number of non-zero elements in the sparse vector?”

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-12-12 10:26  "jjanczur (@jjanczur)" <noreply+jjanczur@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jjanczur (@jjanczur) @ 2024-12-12 10:26 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Is there any update on this matter? Native support for 3k (or preferably 4k) dimensions in pgvector would be a game-changer. It would eliminate the need for hacky workarounds that compromise accuracy or the overall quality of search results. I completely agree with @orentet  on this point - other workarounds are unacceptable for us too and we have to use other dbs.

In our case, we’ve observed a significant improvement in handling multilingual documents when using models with dimensions greater than 3k (OpenAI large and Mistral with 4k dimensions)

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-12-12 19:08  "jkatz (@jkatz)" <noreply+jkatz@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jkatz (@jkatz) @ 2024-12-12 19:08 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

> In our case, we’ve observed a significant improvement

Can you please define what "significant improvement" means here? Do you have any recall or other measurements to show how much this increased?

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-12-12 21:57  "jjanczur (@jjanczur)" <noreply+jjanczur@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jjanczur (@jjanczur) @ 2024-12-12 21:57 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hi, sure!

We began by reviewing results from well known benchmarks such as MTEB and MIRACL and their results.

Following this, we conducted an internal evaluation using our own dataset. This involved testing various embedding models and experimenting with different chunk sizes and overlaps, primarily on German, Dutch, and French legal texts, including court decisions and patents.
(We had mainly German court decisions and contracts in German and Dutch)

Our initial focus was on optimizing the chunk size and overlap settings to suit our specific use case.

We designed tests using texts, questions and pre-identified chunks. These texts were complex, with questions heavily relying on intricate legal nuances. While we experimented with metrics like NDCG@10 and MAP@10, consolidating the results into meaningful insights was more challenging than anticipated.  😅

Ultimately, we applied RAGAS benchmarks to a similar set of test questions and answers within a standard RAG setup.

Although I don’t recall the precise metrics, higher-dimensional models consistently outperformed others on this type of complex documents. For our use case, even a 20% performance improvement was significant, and as I recall, the results exceeded that threshold. (At least in our internal test, on our internal data, that was close to the production use case)

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-12-12 22:17  "ankane (@ankane)" <noreply+ankane@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: ankane (@ankane) @ 2024-12-12 22:17 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Can you share more about why half-precision indexing (for vectors up to 4k dimensions) or binary quantization with re-ranking (for larger vectors) isn't sufficient for this (including the recall numbers, index build options, and search options)?

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-12-12 22:54  "jjanczur (@jjanczur)" <noreply+jjanczur@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jjanczur (@jjanczur) @ 2024-12-12 22:54 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

We ended up with reranking being absolutely best solution - qualitywise + pinecone where we could just keep full embedding. We could do there as well namespace search and metadata filtering which was crucial for the usecase. 

I don’t like pinecone because they are closed source but they are easy to use and have absolutely fantastic docs. We evaluated a few other solutions as well. 

As I mentioned we wanted to use pgvector but ended up with pinecone never tested the impact of 2000 out of 3k dimensions mostly because of the 2k restriction. 

edit: 2k out of 3k i have in mind not truncating the vector ofc. But just using larger model with less dimensions. 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2024-12-12 23:06  "jjanczur (@jjanczur)" <noreply+jjanczur@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: jjanczur (@jjanczur) @ 2024-12-12 23:06 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

For solutions where speed and low latency are critical reranking adds yet another part that just takes time 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2025-02-01 02:17  "markthepixel (@markthepixel)" <noreply+markthepixel@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: markthepixel (@markthepixel) @ 2025-02-01 02:17 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

It would seem this has all but been resolved?

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2025-02-24 10:30  "FaediMichele (@FaediMichele)" <noreply+FaediMichele@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: FaediMichele (@FaediMichele) @ 2025-02-24 10:30 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

I'm using a workaround for cosine distance.
You can split the vector in two half and simply order by the sum the dot product between the two vectors.
This works only if the vectors are normed (the full vector, not the half) before storing and querying.
Remember to change the index for dot product.

Don't know much about efficiency though

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2025-02-25 01:17  "ankane (@ankane)" <noreply+ankane@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: ankane (@ankane) @ 2025-02-25 01:17 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@ankane closed this.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2025-02-25 01:17  "ankane (@ankane)" <noreply+ankane@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: ankane (@ankane) @ 2025-02-25 01:17 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

This was largely addressed with 0.7.0 (released at the end of April 2024), which added the ability to index up to 4,000 dimensions with the `halfvec` type and 64,000 dimensions with the `bit` type.

If there are situations where someone is seeing significantly worse recall with half-precision indexing or binary quantization with re-ranking, please create a new issue with the details.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2025-03-26 08:59  "BobLamarley (@BobLamarley)" <noreply+BobLamarley@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: BobLamarley (@BobLamarley) @ 2025-03-26 08:59 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

Hello everyone,
Sorry for being the nooby of this thread:
I'm currently facing this error : "index row requires 12304 bytes, maximum size is 8191" because i'm trying to store an embedding of 3072 dimensions coming from **_text-embedding-3-large_** of OpenAI
From what i've read, the only solutions at this moment are:

-  switch to **_text-embedding-3-small_** ? 
- stay with **_text-embedding-3-large_** but use _max_dimensions_ parameters to 1536 ?

Which is preconised ?

There's no tricks to store a 3072 dimension vector as of now ?

Thanks 

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2025-03-26 09:19  "ankane (@ankane)" <noreply+ankane@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: ankane (@ankane) @ 2025-03-26 09:19 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

It sounds like you're using either a modified version of pgvector or a different extension (pgvector should show a different error message). Please avoid commenting on long, closed threads to avoid notifying everyone.

^ permalink  raw  [nested|flat] 61+ messages in thread

* Re: [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index
@ 2025-03-26 09:19  "pgvector (@pgvector)" <noreply+pgvector@github.com>
  59 siblings, 0 replies; 61+ messages in thread

From: pgvector (@pgvector) @ 2025-03-26 09:19 UTC (permalink / raw)
  To: pgvector/pgvector <noreply+pgvector-pgvector@github.com>

@pgvector locked this.

^ permalink  raw  [nested|flat] 61+ messages in thread


end of thread, other threads:[~2025-03-26 09:19 UTC | newest]

Thread overview: 61+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-02-16 09:37 [pgvector/pgvector] issue #461: Increase max vectors dimension limit for index "VincentEggerling (@VincentEggerling)" <noreply+VincentEggerling@github.com>
2024-02-16 15:35 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-03-04 09:59 ` "kevintanhongann (@kevintanhongann)" <noreply+kevintanhongann@github.com>
2024-03-08 11:00 ` "HectorBst (@HectorBst)" <noreply+HectorBst@github.com>
2024-03-08 12:21 ` "yashukla47 (@yashukla47)" <noreply+yashukla47@github.com>
2024-03-09 05:47 ` "brpy (@brpy)" <noreply+brpy@github.com>
2024-03-13 01:49 ` "GPF199541 (@GPF199541)" <noreply+GPF199541@github.com>
2024-03-18 12:54 ` "AnonymousBoy (@AnonymousBoy)" <noreply+AnonymousBoy@github.com>
2024-03-18 17:26 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-03-29 01:43 ` "shao-shuai (@shao-shuai)" <noreply+shao-shuai@github.com>
2024-03-29 04:28 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-03-30 12:00 ` "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
2024-03-30 12:38 ` "KnightMurloc (@KnightMurloc)" <noreply+KnightMurloc@github.com>
2024-03-30 16:10 ` "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
2024-03-30 16:50 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-03-31 12:10 ` "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
2024-04-01 09:03 ` "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
2024-04-01 14:25 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-04-03 10:41 ` "wmwsagara (@wmwsagara)" <noreply+wmwsagara@github.com>
2024-04-05 04:33 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-05-06 00:22 ` "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
2024-05-07 02:30 ` "MMeent (@MMeent)" <noreply+MMeent@github.com>
2024-05-13 13:52 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-08-01 09:17 ` "legaltextai (@legaltextai)" <noreply+legaltextai@github.com>
2024-09-10 10:11 ` "sandys (@sandys)" <noreply+sandys@github.com>
2024-09-10 11:31 ` "touhi99 (@touhi99)" <noreply+touhi99@github.com>
2024-09-10 17:01 ` "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
2024-09-10 19:12 ` "sandys (@sandys)" <noreply+sandys@github.com>
2024-09-10 19:40 ` "touhi99 (@touhi99)" <noreply+touhi99@github.com>
2024-09-21 02:50 ` "lmaddox (@lmaddox)" <noreply+lmaddox@github.com>
2024-09-21 12:19 ` "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
2024-09-21 14:51 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-09-22 06:06 ` "ThomasVitale (@ThomasVitale)" <noreply+ThomasVitale@github.com>
2024-09-22 06:54 ` "sandys (@sandys)" <noreply+sandys@github.com>
2024-09-22 07:12 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-09-22 18:43 ` "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
2024-09-25 06:46 ` "jayong-sv (@jayong-sv)" <noreply+jayong-sv@github.com>
2024-09-27 04:22 ` "MSWinds (@MSWinds)" <noreply+MSWinds@github.com>
2024-09-30 20:09 ` "nathan-vo810 (@nathan-vo810)" <noreply+nathan-vo810@github.com>
2024-09-30 20:27 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-10-01 12:22 ` "nathan-vo810 (@nathan-vo810)" <noreply+nathan-vo810@github.com>
2024-10-01 15:33 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-10-01 17:34 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-11-11 08:45 ` "orentet (@orentet)" <noreply+orentet@github.com>
2024-11-11 09:34 ` "rohitghatol (@rohitghatol)" <noreply+rohitghatol@github.com>
2024-11-11 11:15 ` "t-zuehlsdorff (@t-zuehlsdorff)" <noreply+t-zuehlsdorff@github.com>
2024-11-11 14:33 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-11-29 07:08 ` "rohitghatol (@rohitghatol)" <noreply+rohitghatol@github.com>
2024-12-12 10:26 ` "jjanczur (@jjanczur)" <noreply+jjanczur@github.com>
2024-12-12 19:08 ` "jkatz (@jkatz)" <noreply+jkatz@github.com>
2024-12-12 21:57 ` "jjanczur (@jjanczur)" <noreply+jjanczur@github.com>
2024-12-12 22:17 ` "ankane (@ankane)" <noreply+ankane@github.com>
2024-12-12 22:54 ` "jjanczur (@jjanczur)" <noreply+jjanczur@github.com>
2024-12-12 23:06 ` "jjanczur (@jjanczur)" <noreply+jjanczur@github.com>
2025-02-01 02:17 ` "markthepixel (@markthepixel)" <noreply+markthepixel@github.com>
2025-02-24 10:30 ` "FaediMichele (@FaediMichele)" <noreply+FaediMichele@github.com>
2025-02-25 01:17 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-02-25 01:17 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-03-26 08:59 ` "BobLamarley (@BobLamarley)" <noreply+BobLamarley@github.com>
2025-03-26 09:19 ` "ankane (@ankane)" <noreply+ankane@github.com>
2025-03-26 09:19 ` "pgvector (@pgvector)" <noreply+pgvector@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