Skip to content
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

Add map result support in neural search for non text embedding models #258

Closed
wants to merge 2 commits into from

Conversation

zane-neo
Copy link
Collaborator

@zane-neo zane-neo commented Aug 22, 2023

Description

Neural search only support text embedding model result which are usually in List<List> structure, for other models that returns non vector list like OpenAI, SPLADE etc, there's no available functions to get extract the json object result. This PR is to add several new functions to support these cases, the response are in Map<String, ?> structure and upper layer can extract more information from the map based on their purpose.

Issues Resolved

#260

Check List

  • New functionality includes testing.
    • All tests pass
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed as per the DCO using --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.

@navneet1v
Copy link
Collaborator

@zane-neo lets not skip the change log.

Also, motivation is not clear for this change. Can you add a github issue and talk about why we need this change? Is there any new feature that we are building which is going to use the new responses?

}
List<ModelTensor> tensorList = tensorOutputList.get(0).getMlModelTensors();
if (CollectionUtils.isEmpty(tensorList)) {
log.error("No tensor found!");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this error message more understandable and with actions what happened wrong which resulted in this error

final ModelTensorOutput modelTensorOutput = (ModelTensorOutput) mlOutput;
final List<ModelTensors> tensorOutputList = modelTensorOutput.getMlModelOutputs();
if (CollectionUtils.isEmpty(tensorOutputList)) {
log.error("No tensor output found!");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this error message more understandable and with actions what happened wrong which resulted in this error

@@ -144,4 +174,19 @@ private List<List<Float>> buildVectorFromResponse(MLOutput mlOutput) {
return vector;
}

private Map<String, ?> buildMapResultFromResponse(MLOutput mlOutput) {
final ModelTensorOutput modelTensorOutput = (ModelTensorOutput) mlOutput;
Copy link
Member

@martin-gaievski martin-gaievski Aug 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we check the type of mlOutput before casting?

@zane-neo
Copy link
Collaborator Author

@zane-neo lets not skip the change log.

Also, motivation is not clear for this change. Can you add a github issue and talk about why we need this change? Is there any new feature that we are building which is going to use the new responses?

Sure, created this issue: #260. Yes, the SPLADE feature needs to use the new response.

@navneet1v
Copy link
Collaborator

@zane-neo as this is a new feature, and will probably go through multiple iterations before it is going to be released. Hence, for all new features let's not merge the changes directly in main. Lets merge keep reviewing the changes and merge them in a feature branch. Let me create a feature branch for this new feature.

So the process will go like this:

  1. Neural Search plugin maintainer will cut a feature branch from main branch.
  2. Contributors working on Sparse Vectors will raise the PR against the feature branch.
  3. Once the PR is reviewed it will go in the feature branch.
  4. Once all the changes are done and performance testing is done, commits of feature branch will be merged in the main branch.

Please let me know if there is any further questions.

cc: @vamshin

@navneet1v
Copy link
Collaborator

@zane-neo Feature branch for sparse vector support: https://github.com/opensearch-project/neural-search/tree/feature/sparseVectorSupport

Please use this branch for this and all future PRs related to SparseVector Support.

@zane-neo
Copy link
Collaborator Author

zane-neo commented Sep 1, 2023

Closing this PR since raised another PR to feature branch: #270

@zane-neo zane-neo closed this Sep 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants