-
Notifications
You must be signed in to change notification settings - Fork 138
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
support question answering model #2208
Conversation
@@ -269,7 +269,7 @@ public static MLInput parse(XContentParser parser, String inputAlgoName) throws | |||
} | |||
} | |||
MLInputDataset inputDataSet = null; | |||
if (algorithm == FunctionName.TEXT_EMBEDDING || algorithm == FunctionName.SPARSE_ENCODING || algorithm == FunctionName.SPARSE_TOKENIZE) { | |||
if (algorithm == FunctionName.TEXT_EMBEDDING || algorithm == FunctionName.SPARSE_ENCODING || algorithm == FunctionName.SPARSE_TOKENIZE || algorithm == FunctionName.QUESTION_ANSWERING) { |
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 add a map, this branch will get longer and longer....
|
||
@Log4j2 | ||
@Function(FunctionName.QUESTION_ANSWERING) | ||
public class QuestionAnsweringModel extends DLModel { |
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.
This model will also eventually use TextEmbeddingModelConfig
, which is not ideal. Let's create a separate model config for this type of 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 am trying to see what config fields we will need for QA model and add accordingly
...java/org/opensearch/ml/engine/algorithms/question_answering/QuestionAnsweringTranslator.java
Outdated
Show resolved
Hide resolved
...java/org/opensearch/ml/engine/algorithms/question_answering/QuestionAnsweringTranslator.java
Outdated
Show resolved
Hide resolved
.../java/org/opensearch/ml/engine/algorithms/question_answering/QuestionAnsweringModelTest.java
Outdated
Show resolved
Hide resolved
@HenryL27 could you please review the PR? |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2208 +/- ##
============================================
- Coverage 81.90% 81.70% -0.21%
- Complexity 5719 5755 +36
============================================
Files 547 552 +5
Lines 23075 23325 +250
Branches 2378 2409 +31
============================================
+ Hits 18900 19057 +157
- Misses 3230 3302 +72
- Partials 945 966 +21
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
@@ -25,7 +25,7 @@ | |||
* ML input class which supports a list fo text docs. | |||
* This class can be used for TEXT_EMBEDDING model. | |||
*/ | |||
@org.opensearch.ml.common.annotation.MLInput(functionNames = {FunctionName.TEXT_EMBEDDING, FunctionName.SPARSE_ENCODING, FunctionName.SPARSE_TOKENIZE}) | |||
@org.opensearch.ml.common.annotation.MLInput(functionNames = {FunctionName.TEXT_EMBEDDING, FunctionName.SPARSE_ENCODING, FunctionName.SPARSE_TOKENIZE, FunctionName.QUESTION_ANSWERING}) |
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 remember you plan to add new input/output type for QA model, will you add it in next commit?
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.
Yes pushing the new commit with the following input/out formats
// Input { "question": "What color is Apple", "context": "I like Apples. Because they are red" }
// output { "inference_results": [ { "output": [ { "result": "red" } ] } ] }
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.
Do we still needs to add FunctionName.QUESTION_ANSWERING
here?
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.
yeah good catch, we don't need it here anymore. Thanks @dhrubo-os will remove it
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.x 2.x
# Navigate to the new working tree
cd .worktrees/backport-2.x
# Create a new branch
git switch --create backport/backport-2208-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 c560fcca6ee2e413e7ebc2503a2e64ad691e6e2b
# Push it to GitHub
git push --set-upstream origin backport/backport-2208-to-2.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.x Then, create a pull request where the |
The backport to
To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-2.13 2.13
# Navigate to the new working tree
cd .worktrees/backport-2.13
# Create a new branch
git switch --create backport/backport-2208-to-2.13
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 c560fcca6ee2e413e7ebc2503a2e64ad691e6e2b
# Push it to GitHub
git push --set-upstream origin backport/backport-2208-to-2.13
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-2.13 Then, create a pull request where the |
* support question answering model Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit c560fcc)
* support question answering model Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit c560fcc)
* support question answering model Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit c560fcc)
* support question answering model Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit c560fcc)
* support question answering model Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit c560fcc)
* support question answering model Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit c560fcc)
* support question answering model Signed-off-by: Bhavana Ramaram <[email protected]> (cherry picked from commit c560fcc)
Description
support question answering model. This PR adds question answering model to the list of existing list of models supported by ml-commons. It expects question and context and gives the answer based on the context provides. Below is a sample predict API request to QA model and its expected output
Issues Resolved
#1873
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.