You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Increase max vectors dimension limit for index #461
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 !
Reacted by Bhargav v, Hector Basset, Juuso Vesanto, Gabriel Creti, fablerq, Taisei Yamamoto, Raghu Betina, Rajin, Tirion Prole, oguma and 23 more
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 (#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.
Reacted by VincentEggerling, thisissum, cclin, Mike Adelson, nolwennz, Kevin H.A Tan, Pierre Dulac, Hector Basset, Juuso Vesanto, Philip Kung and 6 more
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.
Reacted by nolwennz, Hector Basset, ਬ੍ਰਹ੍ਮ੍ਜੋਤ ਸਿੰਘ ਖਾਲਸਾ, Jacek Janczura, Dataztar, Pawan Bisht and bogdan-cb
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.
Reacted by Bhargav v, yashukla47, Pierre Dulac, Devran Cosmo Uenal, Juuso Vesanto, fablerq, Jonathan Hendler, ਬ੍ਰਹ੍ਮ੍ਜੋਤ ਸਿੰਘ ਖਾਲਸਾ, Thomas Cintra, loganamcnichols and 9 more
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 ?
Reacted by yashukla47, Pierre Dulac, Jonathan Hendler, ਬ੍ਰਹ੍ਮ੍ਜੋਤ ਸਿੰਘ ਖਾਲਸਾ, Adam Caviness and Dataztar
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!
Reacted by ਬ੍ਰਹ੍ਮ੍ਜੋਤ ਸਿੰਘ ਖਾਲਸਾ, Zack, Adam Caviness and Dataztar
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 (especially the "D") 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!).
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
Reacted by Matt Grosso, Raghu Betina, Tirion Prole, Adam Caviness and fedecompa
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:
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.
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.
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.
@wmwsagara For your proposals, if we look at the tests in #326 (comment) 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 outlines where the restriction is, and the effort it'd take to adjust.
"Proposal 3" is somewhat similar to HOT chaining, which I lightly discussed in 2023. 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.
@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.
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), 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 changed a lot around 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). There are branches open for a few others (intvec, 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 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.
Reacted by Olivier Le Moal, Corey Coto and Kyle M. Kovary
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?”
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)
Reacted by jo-al-ra, vikastiwari86, ankitsogani5, Fouad-maker, Thomas Vitale, macklinbuckler, Adam Caviness, Hector Basset, Jean Willian de Souza Ferreira, alexgrdev and 5 more
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)
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)?
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.
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.
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.
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 ?
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.
Activity
jkatz commentedon Feb 16, 2024
@VincentEggerling
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
tinyandhalfbranch) 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 (#27).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.
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.
kevintanhongann commentedon Mar 4, 2024
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.
HectorBst commentedon Mar 8, 2024
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.
yashukla47 commentedon Mar 8, 2024
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 ?
brpy commentedon Mar 9, 2024
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!
GPF199541 commentedon Mar 13, 2024
+1
AnonymousBoy commentedon Mar 18, 2024
pgvecto.rs could support up to 65535 dimensions, could pgvector also support it?
https://github.com/tensorchord/pgvecto.rs
jkatz commentedon Mar 18, 2024
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 (especially the "D") 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!).
shao-shuai commentedon Mar 29, 2024
jkatz commentedon Mar 29, 2024
Per #326 (comment) and #395 (comment) there are now proposed patches that would allow for the increasing of max dimension.
wmwsagara commentedon Mar 30, 2024
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:
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.
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
KnightMurloc commentedon Mar 30, 2024
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.
wmwsagara commentedon Mar 30, 2024
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?
jkatz commentedon Mar 30, 2024
@wmwsagara For your proposals, if we look at the tests in #326 (comment) 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 outlines where the restriction is, and the effort it'd take to adjust.
At PGConf.dev 2024, I'm planning to discuss this topic and some proposals to better address this upstream.
"Proposal 3" is somewhat similar to HOT chaining, which I lightly discussed in 2023. 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.
wmwsagara commentedon Mar 31, 2024
@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.
30 remaining items
jkatz commentedon Nov 11, 2024
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
Dof 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:
vector,halfvec(fp16), andsparsevec, and leverages the upstream data type binary vectors (bit). There are branches open for a few others (intvec,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
vectortohalfvec, 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:@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
halfvecindex, 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 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.
rohitghatol commentedon Nov 29, 2024
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?”
jjanczur commentedon Dec 12, 2024
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)
jkatz commentedon Dec 12, 2024
Can you please define what "significant improvement" means here? Do you have any recall or other measurements to show how much this increased?
jjanczur commentedon Dec 12, 2024
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)
ankane commentedon Dec 12, 2024
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)?
jjanczur commentedon Dec 12, 2024
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.
jjanczur commentedon Dec 12, 2024
For solutions where speed and low latency are critical reranking adds yet another part that just takes time
markthepixel commentedon Feb 1, 2025
It would seem this has all but been resolved?
FaediMichele commentedon Feb 24, 2025
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
ankane commentedon Feb 25, 2025
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
halfvectype and 64,000 dimensions with thebittype.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.
BobLamarley commentedon Mar 26, 2025
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:
Which is preconised ?
There's no tricks to store a 3072 dimension vector as of now ?
Thanks
ankane commentedon Mar 26, 2025
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.