更新已训练模型部署 API
编辑更新已训练模型部署 API
编辑更新已训练模型部署的某些属性。
请求
编辑POST _ml/trained_models/<deployment_id>/deployment/_update
先决条件
编辑需要 manage_ml
集群权限。此权限包含在 machine_learning_admin
内置角色中。
描述
编辑您可以更新 assignment_state
为 started
的已训练模型部署。您可以启用自适应分配,以便根据进程的实际资源需求自动向上或向下扩展模型分配。或者,您可以手动增加或减少模型部署的分配数量。
路径参数
编辑-
<deployment_id>
- (必需,字符串)模型部署的唯一标识符。
请求正文
编辑-
adaptive_allocations
-
(可选,对象)自适应分配配置对象。如果启用,则根据进程的当前负载设置模型的分配数量。当负载较高时,会自动创建一个新的模型分配(如果设置了
max_number_of_allocations
的值,则会遵守该值)。当负载较低时,会自动删除一个模型分配(如果设置了min_number_of_allocations
的值,则会遵守该值)。如果启用了adaptive_allocations
,请勿手动设置分配数量。-
enabled
- (可选,布尔值)如果为
true
,则启用adaptive_allocations
。默认为false
。 -
max_number_of_allocations
- (可选,整数)指定要扩展到的最大分配数量。如果设置,则必须大于或等于
min_number_of_allocations
。 -
min_number_of_allocations
- (可选,整数)指定要扩展到的最小分配数量。如果设置,则必须大于或等于
0
。如果未定义,则部署将缩放到0
。
-
-
number_of_allocations
- (可选,整数)此模型在机器学习节点上分配的总数。增加此值通常会提高吞吐量。如果启用了
adaptive_allocations
,请勿设置此值,因为它会自动设置。
示例
编辑以下示例更新 elastic__distilbert-base-uncased-finetuned-conll03-english
已训练模型的部署,使其具有 4 个分配
resp = client.ml.update_trained_model_deployment( model_id="elastic__distilbert-base-uncased-finetuned-conll03-english", number_of_allocations=4, ) print(resp)
response = client.ml.update_trained_model_deployment( model_id: 'elastic__distilbert-base-uncased-finetuned-conll03-english', body: { number_of_allocations: 4 } ) puts response
const response = await client.ml.updateTrainedModelDeployment({ model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english", number_of_allocations: 4, }); console.log(response);
POST _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_update { "number_of_allocations": 4 }
API 返回以下结果
{ "assignment": { "task_parameters": { "model_id": "elastic__distilbert-base-uncased-finetuned-conll03-english", "model_bytes": 265632637, "threads_per_allocation" : 1, "number_of_allocations" : 4, "queue_capacity" : 1024 }, "routing_table": { "uckeG3R8TLe2MMNBQ6AGrw": { "current_allocations": 1, "target_allocations": 4, "routing_state": "started", "reason": "" } }, "assignment_state": "started", "start_time": "2022-11-02T11:50:34.766591Z" } }
以下示例更新 elastic__distilbert-base-uncased-finetuned-conll03-english
已训练模型的部署,以启用自适应分配,最小分配数量为 3,最大分配数量为 10
resp = client.ml.update_trained_model_deployment( model_id="elastic__distilbert-base-uncased-finetuned-conll03-english", adaptive_allocations={ "enabled": True, "min_number_of_allocations": 3, "max_number_of_allocations": 10 }, ) print(resp)
const response = await client.ml.updateTrainedModelDeployment({ model_id: "elastic__distilbert-base-uncased-finetuned-conll03-english", adaptive_allocations: { enabled: true, min_number_of_allocations: 3, max_number_of_allocations: 10, }, }); console.log(response);
POST _ml/trained_models/elastic__distilbert-base-uncased-finetuned-conll03-english/deployment/_update { "adaptive_allocations": { "enabled": true, "min_number_of_allocations": 3, "max_number_of_allocations": 10 } }