Align ML Commons FunctionName with registered model configuration - #1885
Conversation
PR Reviewer Guide 🔍(Review updated until commit 487be63)Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Latest suggestions up to 487be63 Explore these optional code suggestions:
Previous suggestionsSuggestions up to commit 90f0ae4
Suggestions up to commit 90f0ae4
Suggestions up to commit 58dde36
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1885 +/- ##
============================================
- Coverage 83.46% 83.43% -0.03%
Complexity 3893 3893
============================================
Files 291 291
Lines 13835 13848 +13
Branches 2300 2301 +1
============================================
+ Hits 11547 11554 +7
- Misses 1455 1458 +3
- Partials 833 836 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Please update changelog. |
Signed-off-by: Venkateshwaran Shanmugham <venkateshwaracholan@gmail.com>
4006cd9 to
90f0ae4
Compare
|
Persistent review updated to latest commit 90f0ae4 |
1 similar comment
|
Persistent review updated to latest commit 90f0ae4 |
Signed-off-by: venkateshwaran shanmugham <venkateshwaracholan@gmail.com>
|
Persistent review updated to latest commit 487be63 |
|
Is there a known case where the current hardcoded If ML Commons actually requires the The hardcoded |
Spent some time tracing this end-to-end in ml-commons. The FunctionName neural-search sends on _predict is effectively a no-op today where the caller's FunctionName is discarded. TransportPredictionTaskAction unconditionally overwrites MLInput.algorithm with the registered model's algorithm before dispatch: The REST API already supports omitting it. RestMLPredictionAction registers a route that doesn't require algorithm in the path and falls back to modelManager.getOptionalModelFunctionName(modelId): So ml-commons already treats algorithm as a derivable-from-model field at the REST boundary. Why neural-search still has to pass something: That's the only reason we have to put a value here. Whatever it is gets overwritten ~1 hop later. What this means for the PR:
Real fix is in ml-commons. Relax MLInput.validate() to allow null algorithm on predict (train still needs it) so callers don't have to pass it at all. @heemin32 Let's create an issue in ml-commons to explore this further. |
|
@pyek-bot Does it mean, even this inference processor does not need to pass function name? https://docs.opensearch.org/latest/ingest-pipelines/processors/ml-inference/ |
No, function_name is still needed on the ml_inference processor, just not on our neural-search path. The processor accepts any JSON from user config, so ml-commons needs function_name to know how to parse that JSON into the right input type (text docs vs. similarity pair vs. remote passthrough, etc.). Neural-search doesn't have that issue because you are constructing the MLInput class yourselves: |
|
@mingshl Would like you to chip in here from ml inference processor pov and if function_name can be derived from model metadata? |
|
I think we should keep the current approach. Fetching model metadata would introduce latency we'd prefer to avoid. It looks like the function name is used for local models but not for remote ones. Since we already know which model we're calling, we should hardcode the function name rather than reading it from model metadata to avoids the unnecessary overhead. |
|
Closing the PR |
Description
Align the FunctionName used in ML Commons inference requests with the algorithm configured in the registered ML Commons model.
Previously, several inference paths in NeuralSearchMLInputBuilder and MLCommonsClientAccessor used hardcoded FunctionName values (for example, TEXT_EMBEDDING) regardless of the model's registered algorithm. Although ML Commons currently accepts these requests, the resulting MLInput did not accurately reflect the model configuration.
This change updates inference request construction to use the model's registered algorithm consistently across supported inference paths.
Changes Made
Production Changes
Added logic to resolve FunctionName from the registered model configuration.
Updated NeuralSearchMLInputBuilder to construct MLInput using the model's configured algorithm.
Updated MLCommonsClientAccessor to propagate model algorithm information when building inference requests.
Aligned FunctionName handling for:
Local models
Remote symmetric models
Remote asymmetric models
Sparse encoding models
Text similarity inference
Semantic highlighting inference
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.