diff --git a/_ml-commons-plugin/api/model-apis/update-model.md b/_ml-commons-plugin/api/model-apis/update-model.md index 3e9e92b4a7..0a4ce8bb94 100644 --- a/_ml-commons-plugin/api/model-apis/update-model.md +++ b/_ml-commons-plugin/api/model-apis/update-model.md @@ -130,3 +130,53 @@ PUT /_plugins/_ml/models/9uGdCJABjaMXYrp14YRj } ``` +#### Example request: Updating the model interface + +You can update a model's interface to define input and output schemas. This is useful for models that lack a default interface or require customization. + +The following example request specifies the output schema for an [AI21 Labs Jurassic model](https://aws.amazon.com/bedrock/ai21/) that was registered without a post-processing function: + +```json +PUT /_plugins/_ml/models/IMcNB5UB7judm8f45nXo +{ + "interface": { + "output": "{\n \"type\": \"object\",\n \"properties\": {\n \"inference_results\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"output\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"name\": {\n \"type\": \"string\"\n },\n \"dataAsMap\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"number\"\n },\n \"prompt\": {\n \"type\": \"object\",\n \"properties\": {\n \"text\": {\n \"type\": \"string\"\n },\n \"tokens\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"generatedToken\": {\n \"type\": \"object\",\n \"properties\": {\n \"token\": {\n \"type\": \"string\"\n },\n \"logprob\": {\n \"type\": \"number\"\n },\n \"raw_logprob\": {\n \"type\": \"number\"\n }\n }\n },\n \"textRange\": {\n \"type\": \"object\",\n \"properties\": {\n \"start\": {\n \"type\": \"number\"\n },\n \"end\": {\n \"type\": \"number\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"completions\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"data\": {\n \"type\": \"object\",\n \"properties\": {\n \"text\": {\n \"type\": \"string\"\n },\n \"tokens\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"object\",\n \"properties\": {\n \"generatedToken\": {\n \"type\": \"object\",\n \"properties\": {\n \"token\": {\n \"type\": \"string\"\n },\n \"logprob\": {\n \"type\": \"number\"\n },\n \"raw_logprob\": {\n \"type\": \"number\"\n }\n }\n },\n \"textRange\": {\n \"type\": \"object\",\n \"properties\": {\n \"start\": {\n \"type\": \"number\"\n },\n \"end\": {\n \"type\": \"number\"\n }\n }\n }\n }\n }\n }\n }\n },\n \"finishReason\": {\n \"type\": \"object\",\n \"properties\": {\n \"reason\": {\n \"type\": \"string\"\n },\n \"length\": {\n \"type\": \"number\"\n }\n }\n }\n }\n }\n }\n }\n }\n }\n }\n },\n \"status_code\": {\n \"type\": \"integer\"\n }\n }\n }\n }\n }\n}" + } +} +``` +{% include copy-curl.html %} + +If the model was registered using the [Amazon Bedrock AI21 Labs Jurassic blueprint](https://github.com/opensearch-project/ml-commons/blob/2.x/docs/remote_inference_blueprints/bedrock_connector_ai21labs_jurassic_blueprint.md), a default interface is applied automatically. +{: .note} + +If the model interface is no longer needed, you can remove both the input and output schemas in order to bypass model schema validation: + +```json +PUT /_plugins/_ml/models/IMcNB5UB7judm8f45nXo +{ + "interface": { + "input": null, + "output": null + } +} +``` +{% include copy-curl.html %} + +#### Example response + +```json +{ + "_index": ".plugins-ml-model", + "_id": "IMcNB5UB7judm8f45nXo", + "_version": 2, + "result": "updated", + "_shards": { + "total": 2, + "successful": 2, + "failed": 0 + }, + "_seq_no": 379, + "_primary_term": 5 +} +``` +