Skip to content

Commit

Permalink
Correct step 2 of custom local models (#7600)
Browse files Browse the repository at this point in the history
* Update custom-local-models.md

Signed-off-by: kolchfa-aws <[email protected]>

* Correct response function

Signed-off-by: Fanit Kolchina <[email protected]>

* More changes

Signed-off-by: Fanit Kolchina <[email protected]>

* Fix rag cluster setting

Signed-off-by: Fanit Kolchina <[email protected]>

---------

Signed-off-by: kolchfa-aws <[email protected]>
Signed-off-by: Fanit Kolchina <[email protected]>
  • Loading branch information
kolchfa-aws authored Jul 2, 2024
1 parent c521450 commit 0f889fe
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion _ml-commons-plugin/api/model-apis/register-model.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Field | Data type | Required/Optional | Description
`name`| String | Required | The model name. |
`version` | String | Required | The model version. |
`model_format` | String | Required | The portable format of the model file. Valid values are `TORCH_SCRIPT` and `ONNX`. |
`function_name` | String | Required | For text embedding models, set this parameter to `TEXT_EMBEDDING`. For sparse encoding models, set this parameter to `SPARSE_ENCODING` or `SPARSE_TOKENIZE`. For cross-encoder models, set this parameter to `TEXT_SIMILARITY`.
`function_name` | String | Required | For text embedding models, set this parameter to `TEXT_EMBEDDING`. For sparse encoding models, set this parameter to `SPARSE_ENCODING` or `SPARSE_TOKENIZE`. For cross-encoder models, set this parameter to `TEXT_SIMILARITY`. For question answering models, set this parameter to `QUESTION_ANSWERING`.
`model_content_hash_value` | String | Required | The model content hash generated using the SHA-256 hashing algorithm.
`url` | String | Required | The URL that contains the model. |
`description` | String | Optional| The model description. |
Expand Down
2 changes: 1 addition & 1 deletion _ml-commons-plugin/cluster-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ When set to `true`, this setting enables the search processors for retrieval-aug
### Setting
```
plugins.ml_commons.agent_framework_enabled: true
plugins.ml_commons.rag_pipeline_feature_enabled: true
```
### Values
Expand Down
18 changes: 10 additions & 8 deletions _ml-commons-plugin/custom-local-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ To learn more about model groups, see [Model access control]({{site.url}}{{site.

## Step 2: Register a local model

To register a remote model to the model group created in step 1, provide the model group ID from step 1 in the following request:
To register a local model to the model group created in step 1, send a Register Model API request. For descriptions of Register Model API parameters, see [Register a model]({{site.url}}{{site.baseurl}}/ml-commons-plugin/api/model-apis/register-model/).

The `function_name` corresponds to the model type. For text embedding models, set this parameter to `TEXT_EMBEDDING`. For sparse encoding models, set this parameter to `SPARSE_ENCODING` or `SPARSE_TOKENIZE`. For cross-encoder models, set this parameter to `TEXT_SIMILARITY`. For question answering models, set this parameter to `QUESTION_ANSWERING`. In this example, set `function_name` to `TEXT_EMBEDDING` because you're registering a text embedding model.

Provide the model group ID from step 1 and send the following request:

```json
POST /_plugins/_ml/models/_register
Expand All @@ -118,7 +122,7 @@ POST /_plugins/_ml/models/_register
"version": "1.0.1",
"model_group_id": "wlcnb4kBJ1eYAeTMHlV6",
"description": "This is a port of the DistilBert TAS-B Model to sentence-transformers model: It maps sentences & paragraphs to a 768 dimensional dense vector space and is optimized for the task of semantic search.",
"model_task_type": "TEXT_EMBEDDING",
"function_name": "TEXT_EMBEDDING",
"model_format": "TORCH_SCRIPT",
"model_content_size_in_bytes": 266352827,
"model_content_hash_value": "acdc81b652b83121f914c5912ae27c0fca8fabf270e6f191ace6979a19830413",
Expand All @@ -143,7 +147,7 @@ POST /_plugins/_ml/models/_register
"version": "1.0.1",
"model_group_id": "wlcnb4kBJ1eYAeTMHlV6",
"description": "This is a port of the DistilBert TAS-B Model to sentence-transformers model: It maps sentences & paragraphs to a 768 dimensional dense vector space and is optimized for the task of semantic search.",
"model_task_type": "TEXT_EMBEDDING",
"function_name": "TEXT_EMBEDDING",
"model_format": "TORCH_SCRIPT",
"model_content_size_in_bytes": 266352827,
"model_content_hash_value": "acdc81b652b83121f914c5912ae27c0fca8fabf270e6f191ace6979a19830413",
Expand All @@ -159,8 +163,6 @@ POST /_plugins/_ml/models/_register
```
{% include copy.html %}

For descriptions of Register API parameters, see [Register a model]({{site.url}}{{site.baseurl}}/ml-commons-plugin/api/model-apis/register-model/). The `model_task_type` corresponds to the model type. For text embedding models, set this parameter to `TEXT_EMBEDDING`. For sparse encoding models, set this parameter to `SPARSE_ENCODING` or `SPARSE_TOKENIZE`. For cross-encoder models, set this parameter to `TEXT_SIMILARITY`. For question answering models, set this parameter to `QUESTION_ANSWERING`.

OpenSearch returns the task ID of the register operation:

```json
Expand All @@ -183,7 +185,7 @@ When the operation is complete, the state changes to `COMPLETED`:
{
"model_id": "cleMb4kBJ1eYAeTMFFg4",
"task_type": "REGISTER_MODEL",
"function_name": "REMOTE",
"function_name": "TEXT_EMBEDDING",
"state": "COMPLETED",
"worker_node": [
"XPcXLV7RQoi5m8NI_jEOVQ"
Expand Down Expand Up @@ -229,7 +231,7 @@ When the operation is complete, the state changes to `COMPLETED`:
{
"model_id": "cleMb4kBJ1eYAeTMFFg4",
"task_type": "DEPLOY_MODEL",
"function_name": "REMOTE",
"function_name": "TEXT_EMBEDDING",
"state": "COMPLETED",
"worker_node": [
"n-72khvBTBi3bnIIR8FTTw"
Expand Down Expand Up @@ -379,4 +381,4 @@ The response provides the answer based on the context:
}
}
}
```
```
6 changes: 3 additions & 3 deletions _ml-commons-plugin/pretrained-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ To learn more about model groups, see [Model access control]({{site.url}}{{site.

## Step 2: Register a local OpenSearch-provided model

To register a remote model to the model group created in step 1, provide the model group ID from step 1 in the following request.
To register an OpenSearch-provided model to the model group created in step 1, provide the model group ID from step 1 in the following request.

Because pretrained models originate from the ML Commons model repository, you only need to provide the `name`, `version`, `model_group_id`, and `model_format` in the register API request:

Expand Down Expand Up @@ -163,7 +163,7 @@ When the operation is complete, the state changes to `COMPLETED`:
{
"model_id": "cleMb4kBJ1eYAeTMFFg4",
"task_type": "REGISTER_MODEL",
"function_name": "REMOTE",
"function_name": "TEXT_EMBEDDING",
"state": "COMPLETED",
"worker_node": [
"XPcXLV7RQoi5m8NI_jEOVQ"
Expand Down Expand Up @@ -209,7 +209,7 @@ When the operation is complete, the state changes to `COMPLETED`:
{
"model_id": "cleMb4kBJ1eYAeTMFFg4",
"task_type": "DEPLOY_MODEL",
"function_name": "REMOTE",
"function_name": "TEXT_EMBEDDING",
"state": "COMPLETED",
"worker_node": [
"n-72khvBTBi3bnIIR8FTTw"
Expand Down

0 comments on commit 0f889fe

Please sign in to comment.