-
Couldn't load subscription status.
- Fork 104
Add support for asymmetric embedding models #1605
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
src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/query/NeuralQueryBuilder.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fen Q <[email protected]>
70795e0 to
204f5e8
Compare
Signed-off-by: Fen Q <[email protected]>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1605 +/- ##
============================================
- Coverage 79.79% 79.75% -0.04%
- Complexity 3461 3470 +9
============================================
Files 279 280 +1
Lines 12960 13024 +64
Branches 2076 2084 +8
============================================
+ Hits 10341 10387 +46
- Misses 1858 1866 +8
- Partials 761 771 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fen Q <[email protected]>
Signed-off-by: Fen Q <[email protected]>
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
| */ | ||
| private boolean isAsymmetricModel(MLModel model) { | ||
| MLModelConfig modelConfig = model.getModelConfig(); | ||
| if (!(modelConfig instanceof TextEmbeddingModelConfig textEmbeddingModelConfig)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does remote and local model has the same conditional check logic?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I reviewed the OpenSearch documentation about asymmetric semantic search here.
- The asymmetric model is registered using a local zip file
- The model_config for asymmetric models differs from symmetric models by requiring two additional parameters:
- query_prefix
- passage_prefix
- I couldn't find any pre-built remote models specifically for asymmetric search. Please let me know if you happen to know any remote use cases and examples.
POST /_plugins/_ml/models/_register
{
"name": "e5-small-onnx",
"version": "1.0.0",
"description": "Asymmetric multilingual-e5-small model",
"model_format": "ONNX",
"model_group_id": "your_group_id",
"model_content_hash_value": "your_model_zip_content_hash_value",
"model_config": {
"model_type": "bert",
"embedding_dimension": 384,
"framework_type": "sentence_transformers",
"query_prefix": "query: ",
"passage_prefix": "passage: ",
"all_config": "{ \"_name_or_path\": \"intfloat/multilingual-e5-small\", \"architectures\": [ \"BertModel\" ], \"attention_probs_dropout_prob\": 0.1, \"hidden_size\": 384, \"num_attention_heads\": 12, \"num_hidden_layers\": 12, \"tokenizer_class\": \"XLMRobertaTokenizer\" }"
},
"url": "http://localhost:8080/intfloat-multilingual-e5-small-onnx.zip"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make sure if there are remote model available to use in this feature. In some prod cases, users are encouraged to apply with remote model for better performance. So we need consider both local and remote cases to handle in the ml client accessor.
The function names could be different at here.
The model meta data(modelAsymmetry) check also need to be considered for both remote and local model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added customized remote sagemaker model for asymmetric use case
updated the PR to support both local and remote models
Signed-off-by: Fen Q <[email protected]>
9b4170d to
338019e
Compare
Signed-off-by: Fen Q <[email protected]>
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/opensearch/neuralsearch/ml/MLCommonsClientAccessor.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Fen Qin <[email protected]>
Signed-off-by: Fen Qin <[email protected]>
Description
Add two fields to InferenceRequest
LOCAL MODEL
REMOTE MODEL
host a remote sagemaker endpoint - add asymmetric customized e5 model opensearch-py-ml#587
Create connector
Related Issues
#620
Check List
--signoff.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.