-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Introduce lateInteractionScore Function #18727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
❌ Gradle check result for 454ff67: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
454ff67 to
302ad4c
Compare
Signed-off-by: Mingshi Liu <[email protected]>
302ad4c to
10d0ee6
Compare
|
❌ Gradle check result for 10d0ee6: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
|
@mingshl why we are using float arrays as vectors when there is a specific vector data type in OpenSearch provided via k-NN plugin. Should we not enable this via the k-NN plugin? |
I have similar questions. This doesn't seem to use the underlying Lucene implementation for Some concerns off the top of my head would be:
That being said, I'm not super familiar with painless scripting, and maybe this is part-1 of subsequently planned changes? @mingshl It would help if you could elaborate on the rationale behind doing it this way. |
+1 on this. |
|
@navneet1v we could also use knn field, but since the field is only used in rerank, it's not using in search, it's seem not necessary to set as a knn field in index mapping. |
I respectfully disagree on this point. If we do like this then it will block the future extension of the feature when we want to build late interaction with k-NN field.
If you look at script score based search in k-NN it doesn't need source. So if we use kNN Field then the ranking can work on with BDV or KNNVectorValues. Another thing is if I look at how you are calculating the score its not optimal since it is not using SIMD. K-NN plugin already provides different scoring functions like L2, L1, Cosine etc which are all SIMD optimized. Hence this implementation will be slow, and also conversion of the final vector scores to OpenSearch scores needs additional calculations which I don't see in the code. |
this lateInteractionScore Function can also support for nested knn field, oh I remembered when I try to write the unit test, because knn field depends on the knn plugin, so I cannot write the test in core, but I will test it offline. @navneet1v that's good callout for SIMD, I will try to implement SIMD function to make it accelerate, thanks!!! |
Signed-off-by: Mingshi Liu <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #18727 +/- ##
============================================
- Coverage 72.83% 72.80% -0.03%
- Complexity 68511 68554 +43
============================================
Files 5572 5573 +1
Lines 314750 314786 +36
Branches 45680 45688 +8
============================================
- Hits 229242 229177 -65
- Misses 66898 67008 +110
+ Partials 18610 18601 -9 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
@mingshl I am not sure if I was able to put my point earlier. So let me give it one more try.
I don't see currently any reason why this painless script should work on array field and be part of core. |
the main driving goal of this script function is that we don't have the new field type, the multi-field type in knn plugin yet, and we don't want to duplicate the effort of @vigyasharma 's change in lucene. While we wait for the lucene upgrade in core, we would like to develop some interim solution. I also love the idea from @vigyasharma that we can develop a new query type, call colbert query or late interation query that would do the rerank work for given multi-vector, before we have the new multi-vector type is ready, under the backend we can utilize the script score function first. and later we can smoothly adapt the new field type into the new query. In this way, we can keep the API and interface the same for the users. If the best place to host the new query type is knn, I can move the PR to knn plugin too. |
|
Thanks @mingshl . Right! I understand the desire to add some support early, rather than wait for Lucene 10.3 release. So designing it such that user interface remains the same, and we can "unfork" to Lucene's implementation under the hood will ensure users don't have to make changes in their applications. Creating an OpenSearch field and query type, that can later be changed to invoke Lucene's LateInteractionField and query could be a viable approach (happy to hear other ideas). It's true that users will have to reindex their data to migrate it from the field we create now, to the field Lucene is using. But upgrade and reindex are better understood operations that most production systems build mechanisms for (even if they don't upgrade right after the release is out). |
|
This PR is stalled because it has been open for 30 days with no activity. |
|
Proposal for rescoring with late interaction models using Lucene's |
Description
lateInteractionScore Function Summary
The
lateInteractionScorefunction is a specialized vector similarity function for Painless scripting in OpenSearch that enables ColBERT-style retrieval and reranking.##Sample interface
Function Signature
Description
This function calculates the maximum similarity between query vectors and document vectors using dot product. For each query vector, it finds the document vector with the highest dot product similarity and sums these maximum scores to produce a final similarity score.
Key Features
Please see the yaml test for the sample usage for thus new function
maxSimDotProductfunctionRelated Issues
address the rerank requirements from #18091
Check List
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.