You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "benwtrent (via GitHub)" <gi...@apache.org> on 2023/03/06 19:49:33 UTC
[GitHub] [lucene] benwtrent opened a new pull request, #12191: Increase KnnByteVectorField limit on dimensions to 2048
benwtrent opened a new pull request, #12191:
URL: https://github.com/apache/lucene/pull/12191
This increases the vector size limit only for ByteVectors only.
Byte vectors use much less memory than float (less than half required to store float vectors). Additionally, dot-products between two byte vectors are faster than between two float vectors (about 1.5x faster).
Here are some micro-benchmark (the dot-product methods used were the same from the `VectorSimilarity` class):
```
VectorMultiplicationBenchmark.byteDotProducts 64 avgt 7 119207.749 ± 87.092 ns/op
VectorMultiplicationBenchmark.byteDotProducts 1024 avgt 7 1615737.126 ± 955.261 ns/op
VectorMultiplicationBenchmark.byteDotProducts 2048 avgt 7 3283335.169 ± 1624.888 ns/op
VectorMultiplicationBenchmark.floatDotProductsUnwrapped 64 avgt 7 197209.288 ± 191.285 ns/op
VectorMultiplicationBenchmark.floatDotProductsUnwrapped 1024 avgt 7 2844926.617 ± 10232.337 ns/op
VectorMultiplicationBenchmark.floatDotProductsUnwrapped 2048 avgt 7 5544835.569 ± 2476.568 ns/op
```
Consequently, it makes sense to me to allow larger vectors for `byte` vectors, but still enforce the current limitation for float. Thus ensuring that callers with larger vectors will:
- Have to quantize their input
- Do dimensionality reduction
- Some combination of both
At least until we can get hardware accelerated vector multiplication (on its 5th!!!!!! incubator at the time of this PR): https://openjdk.org/jeps/438
This PR is a continuation of various other previous work and discussion:
- https://github.com/apache/lucene/pull/874
- https://github.com/apache/lucene/issues/11507
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] rmuir commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1484135459
> @rmuir Ah, I thought your main concern was performance.
I have multiple concerns:
* HNSW doesn't scale at all (time, memory space) and there seems to be no plan to look into alternative
* HNSW especially horribly slow with higher dimensions
* i fear we are slowly locking lucene permanently into this horrible HNSW and it may already be too late, can a codec implementing another algorithm even be added at this point?
I'm -1 to increasing this dimension count. i don't care how many PRs get opened to do it. I will be the bad guy.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] rmuir commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1484133375
> As for performance issues, this is why I am only suggesting the increase for byte encoded vectors as their size & performance improvements are just as reasonable at 2048 as float is at 1024.
reasonable? I'm not sure this word can be applied here. How long does it take for me to index 50 million documents?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] jimczi commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "jimczi (via GitHub)" <gi...@apache.org>.
jimczi commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1485046957
I think that's fair @rmuir . I am also sharing some of these concerns. Although I don't think it's true to say that "HNSW doesn't scale at all (time, memory space) and there seems to be no plan to look into alternative".
The memory constraints for HNSW alone are not gigantic. For each vector we need: M * 4 * 2 bytes where M is the number of links per vector (we default to 16). That's 128 bytes per vector that can be reduced easily at the cost of relevancy by reducing M.
Regarding the number of dimensions, the fact that we need to compute the similarity is not inherent to hnsw. A coarse quantizer would also require to compute the similarity on the entire vector space to reach a good recall. The nice property about hnsw is that it reduces the number of comparisons at indexing and query time to a minimum at any scale.
So regarding the alternative, I think one direction could be to look at product quantization that would allow to reduce the number of dimensions and provide a similarity function on the reduced space. Something like https://hal.inria.fr/inria-00514462v2/document could be "easily" implemented on top of the hnsw indexing and querying to reduce the memory needed for high dimensions use cases. Any quantization that reduces the number of dimension in fact. We should have options here and the hard limit of 1024 could stay as a hard limit at when quantization should be preferred.
Another direction would be to look at ivf, a coarse quantizer that fits well in the inverted list design. The main advantage here would be to get ride of the graph and its associated memory. But again the number of dimensions would still be a constrained since it requires to compute the final score on the entire vector space. Product quantization would still be needed to reduce the constraints at the cost of relevancy.
There's also the problem of merges. A merge is single threaded so we're limited when it comes to build bigger graphs.
There's way to mitigate this issue, we can increase the index buffer size to create bigger graphs, we can also limit the size of segments to ensure that we don't rebuild passed a certain size. The fact that we build a graph per segment can have benefits though. With concurrent segment search, it should be possible to run a single request in parallel on each graph/segment. We could also investigate using multiple threads when merging a single segment. The other solutions that implement hnsw uses multiple threads to index in a single graph.
Today we store these vectors on file and access them through MMAP. That's a differentiator compared to other solutions that requires them to be fully in memory. Considering the access pattern of hnsw (random) I am not sure that it's a real advantage but on the other hand the number of comparisons for indexing and querying is reduced to a minimum. 1024 dimensions is already quite a lot, there are benchmarks with 768 dimensions and more in the ann-benchmarks so it should be interesting to run those on a machine with restricted RAM. With the right setup, I'd assume that Lucene would not crash but the indexing would be really slow.
> How long does it take for me to index 50 million documents?
That's a good question, I am also interested to understand what's the memory requirements associated with it.
With 1024 dimensions and M set to 16, the entire graph would take 6GB and the vectors 190GB!
Assuming that we have enough RAM, it would take almost 14 hours if we can achieve 1000 docs/s. The current solution can index faster than that but I don't think it was ever tested with constrained memory.
I think we need a test benchmarks to check our assumptions. There's nothing in the Lucene's doc (or ES/Solr) that warns against these constraints and we don't know how the solution degrades.
Today we store these vectors on file and access them through MMAP. That's a differentiator compared to other solutions that requires them to be fully in memory. Considering the access pattern of hnsw (random) I am not sure that it's a real advantage but on the other hand the number of comparisons for indexing and querying is reduced to a minimum so a good SSD could mitigate this? We need tests.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] msokolov commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "msokolov (via GitHub)" <gi...@apache.org>.
msokolov commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1492966278
Thanks for raising these interesting possible directions. I spent some time tinkering with ivf/pq-like solution - implement simple k-means, indexed using normal postings and doc-values and ran a bunch of tests. I found that I was able to get high recall without pq., at much lower indexing cost than hnsw, but with a substantially higher query cost. Then I tried working on pq to improve the speed, but was never able to get decent recall with any configuration that I tried. It seems that others have had good results though. Maybe we should start some kind of sandbox branch for trying these out. I'd be happy to share what I have, although the results are not great
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] benwtrent commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "benwtrent (via GitHub)" <gi...@apache.org>.
benwtrent commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1481641849
> So I'm still challenging the use-case for this. "because users ask for it" is not enough for me, given the maturity level of these technologies.
@rmuir Ah, I thought your main concern was performance.
The only use case I can see is image based search (things better than ResNet-esque models). There are "off the shelf" models that work quite well in the e-commerce space (searching image embedded space along with typical search queries). I will see about getting some numbers.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] benwtrent commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "benwtrent (via GitHub)" <gi...@apache.org>.
benwtrent commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1456862771
Persons of interest on this change: @rmuir, @uschindler
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1456873031
> At least until we can get hardware accelerated vector multiplication (on its 5th!!!!!! incubator at the time of this PR): https://openjdk.org/jeps/438
Haha. When it gets into preview phase I have the solution ready: #12188 😊
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] javanna commented on a diff in pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "javanna (via GitHub)" <gi...@apache.org>.
javanna commented on code in PR #12191:
URL: https://github.com/apache/lucene/pull/12191#discussion_r1126971780
##########
lucene/core/src/test/org/apache/lucene/document/TestField.java:
##########
@@ -689,6 +690,55 @@ public void testIndexedBinaryField() throws Exception {
dir.close();
}
+ public void testKnnVectorFieldLimits() {
+ if (Codec.getDefault().getName().equals("SimpleText")) {
Review Comment:
you could use an assume for this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] benwtrent closed pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "benwtrent (via GitHub)" <gi...@apache.org>.
benwtrent closed pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
URL: https://github.com/apache/lucene/pull/12191
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] rmuir commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1494081086
I don't feel this is a research problem to fix, like i said, go look at https://big-ann-benchmarks.com/ and you can see DiskANN as baseline, if you read the papers it seems to be a perfect fit for lucene.
the problem is that here, ppl spend too much time looking at toys (http://ann-benchmarks.com/).
If you are upset about my veto against raising this limit, i'd ask you to first actually try indexing datasets of 756 or 1024 dimensions and get the experience for yourself before complaining to me that the limit should be raised. Please: experience the horror for yourself. Otherwise complaining at me that you can't use some ChatGPT garbage dataset isn't going to accomplish anything or change my mind in any way, please realize that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] rmuir commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "rmuir (via GitHub)" <gi...@apache.org>.
rmuir commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1456913229
My issue is still the concern about supporting such large dimension counts, it seems people want to just "use some off the shelf model" which is not necessarily geared at scalable search. But I think this is non-usecase, it never really gives good performance for your corpus right?
I have a problem bumping limits without clear use-cases because we can't undo raising the limit really without pissing off users, as old indexes wouldn't be able to be read.
So I'm still challenging the use-case for this. "because users ask for it" is not enough for me, given the maturity level of these technologies.
When i look at the datasets for https://big-ann-benchmarks.com/, the most dimensions is 256.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] benwtrent commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "benwtrent (via GitHub)" <gi...@apache.org>.
benwtrent commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1522103756
Closing this PR as further conversation has proved this is currently at a stand still.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] uschindler commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "uschindler (via GitHub)" <gi...@apache.org>.
uschindler commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1456900471
> @uschindler I cannot express how excited I am over this thing finally getting out of incubator. Its getting kind of ridiculous!!!
I don't know if it goes out if incubator, but we have a solution once it goes.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] benwtrent commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "benwtrent (via GitHub)" <gi...@apache.org>.
benwtrent commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1456883519
@uschindler I cannot express how excited I am over this thing finally getting out of incubator. Its getting kind of ridiculous!!!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org
[GitHub] [lucene] benwtrent commented on pull request #12191: Increase KnnByteVectorField limit on dimensions to 2048
Posted by "benwtrent (via GitHub)" <gi...@apache.org>.
benwtrent commented on PR #12191:
URL: https://github.com/apache/lucene/pull/12191#issuecomment-1482823550
@rmuir
I have some text embedding & search numbers.
Here are some initial numbers based on the BEIR dataset. This dataset is a variety of datasets ranging from question & answering to domain specific scientific.
The following numbers are with zero additional configuration. Tuning for relevance makes it not zero-shot. Once you start tuning for relevance, dense retrieval can get much much better than BM25 as you can transfer learn your model. So, to make the comparison fair, this is just zero-shot out of domain performance.
`text-embedding-ada-002` which encodes as `1536` dims has NDGC@10 on average `53.4`
BM25 has NDGC@10 of `41.6` over BEIR.
I would imagine combining the two would significantly boost the NDGC@10 for `text-embedding-ada-002` as you get the best of both worlds.
I can try and find additional numbers.
Do you have an idea of a performance threshold that is adequate?
I agree that we shouldn't chase every new model that is released, but the retrieval and re-ranking performance of these LLM is getting really good.
As for performance issues, this is why I am only suggesting the increase for byte encoded vectors as their size & performance improvements are just as reasonable at 2048 as float is at 1024.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org