Skip to content
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

[DOCS] Drafts trained model deployment APIs #75497

Merged
merged 4 commits into from
Jul 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/reference/ml/df-analytics/apis/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,12 @@ include::get-dfanalytics.asciidoc[leveloffset=+2]
include::get-dfanalytics-stats.asciidoc[leveloffset=+2]
include::get-trained-models.asciidoc[leveloffset=+2]
include::get-trained-models-stats.asciidoc[leveloffset=+2]
//INFER
include::infer-trained-model-deployment.asciidoc[leveloffset=+2]
//PREVIEW
include::preview-dfanalytics.asciidoc[leveloffset=+2]
//SET/START/STOP
include::start-dfanalytics.asciidoc[leveloffset=+2]
include::start-trained-model-deployment.asciidoc[leveloffset=+2]
include::stop-dfanalytics.asciidoc[leveloffset=+2]
include::stop-trained-model-deployment.asciidoc[leveloffset=+2]
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[role="xpack"]
[testenv="basic"]
[[infer-trained-model-deployment]]
= Infer trained model deployment API
[subs="attributes"]
++++
<titleabbrev>Infer trained model deployment</titleabbrev>
++++

Evaluates a trained model.

[[infer-trained-model-deployment-request]]
== {api-request-title}

`POST _ml/trained_models/<model_id>/deployment/_infer`

////
[[infer-trained-model-deployment-prereq]]
== {api-prereq-title}

////
////
[[infer-trained-model-deployment-desc]]
== {api-description-title}

////

[[infer-trained-model-deployment-path-params]]
== {api-path-parms-title}

`<model_id>`::
(Required, string)
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]

[[infer-trained-model-deployment-query-params]]
== {api-query-parms-title}

`timeout`::
(Optional, time)
Controls the amount of time to wait for {infer} results. Defaults to 10 seconds.

[[infer-trained-model-request-body]]
== {api-request-body-title}

`input`::
(Required,string)
The input text for evaluation.

////
[[infer-trained-model-deployment-results]]
== {api-response-body-title}
////
////
[[ml-get-trained-models-response-codes]]
== {api-response-codes-title}

////

[[infer-trained-model-deployment-example]]
== {api-examples-title}

The response depends on the task the model is trained for. If it is a
sentiment analysis task, the response is the score. For example:

[source,console]
--------------------------------------------------
POST _ml/trained_models/model2/deployment/_infer
{
"input": "The movie was awesome!!"
}
--------------------------------------------------
// TEST[skip:TBD]

The API returns scores in this case, for example:

[source,console-result]
----
{
"positive" : 0.9998062667902223,
"negative" : 1.9373320977752957E-4
}
----
// NOTCONSOLE

For named entity recognition (NER) tasks, the response contains the recognized
lcawl marked this conversation as resolved.
Show resolved Hide resolved
entities and their type. For example:

[source,console]
--------------------------------------------------
POST _ml/trained_models/model2/deployment/_infer
{
"input": "Hi my name is Josh and I live in Berlin"
}
--------------------------------------------------
// TEST[skip:TBD]

The API returns scores in this case, for example:

[source,console-result]
----
{
"entities" : [
{
"label" : "person",
"score" : 0.9988716330253505,
"word" : "Josh"
},
{
"label" : "location",
"score" : 0.9980872542990656,
"word" : "Berlin"
}
]
}
----
// NOTCONSOLE
26 changes: 14 additions & 12 deletions docs/reference/ml/df-analytics/apis/ml-df-analytics-apis.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,36 @@
[[ml-df-analytics-apis]]
= {ml-cap} {dfanalytics} APIs

You can use the following APIs to perform {ml} {dfanalytics} activities.
You can use the following APIs to perform {ml} {dfanalytics} activities:

* <<preview-dfanalytics,Preview {dfanalytics}>>
* <<put-dfanalytics,Create {dfanalytics-jobs}>>
* <<update-dfanalytics,Update {dfanalytics-jobs}>>
* <<delete-dfanalytics,Delete {dfanalytics-jobs}>>
* <<get-dfanalytics,Get {dfanalytics-jobs} info>>
* <<get-dfanalytics-stats,Get {dfanalytics-jobs} statistics>>
* <<start-dfanalytics,Start {dfanalytics-jobs}>>
* <<stop-dfanalytics,Stop {dfanalytics-jobs}>>
* <<evaluate-dfanalytics,Evaluate {dfanalytics}>>
* <<explain-dfanalytics,Explain {dfanalytics}>>
* <<preview-dfanalytics,Preview {dfanalytics}>>
* <<start-dfanalytics,Start {dfanalytics-jobs}>>
* <<stop-dfanalytics,Stop {dfanalytics-jobs}>>
* <<update-dfanalytics,Update {dfanalytics-jobs}>>


You can use the following APIs to perform {infer} operations.
You can use the following APIs to perform {infer} operations:

* <<put-trained-models>>
* <<get-trained-models>>
* <<get-trained-models-stats>>
* <<delete-trained-models>>
* <<put-trained-models-aliases>>
* <<delete-trained-models>>
* <<delete-trained-models-aliases>>
* <<get-trained-models>>
* <<get-trained-models-stats>>

You can deploy a trained model to make predictions in an ingest pipeline or in
an aggregation. Refer to the following documentation to learn more.
an aggregation. Refer to the following documentation to learn more:

* <<inference-processor,{infer-cap} processor>>
* <<search-aggregations-pipeline-inference-bucket-aggregation,{infer-cap} bucket aggregation>>
* <<inference-processor,{infer-cap} processor>>
* <<infer-trained-model-deployment>>
* <<start-trained-model-deployment>>
* <<stop-trained-model-deployment>>


See also <<ml-apis>>.
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
[role="xpack"]
[testenv="basic"]
[[start-trained-model-deployment]]
= Start trained model deployment API
[subs="attributes"]
++++
<titleabbrev>Start trained model deployment</titleabbrev>
++++

lcawl marked this conversation as resolved.
Show resolved Hide resolved
[[start-trained-model-deployment-request]]
== {api-request-title}

`POST _ml/trained_models/<model_id>/deployent/_start`
////
[[start-trained-model-deployment-prereq]]
== {api-prereq-title}

////
////
[[start-trained-model-deployment-desc]]
== {api-description-title}

////

[[start-trained-model-deployment-path-params]]
== {api-path-parms-title}

`<model_id>`::
(Required, string)
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]

[[start-trained-model-deployment-query-params]]
== {api-query-parms-title}

`timeout`::
(Optional, time)
Controls the amount of time to wait for the model to deploy. Defaults
to 20 seconds.
////
[role="child_attributes"]
[[start-trained-model-deployment-results]]
== {api-response-body-title}

////
////
[[ml-get-trained-models-response-codes]]
== {api-response-codes-title}

////
////
[[start-trained-model-deployment-example]]
== {api-examples-title}

////
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
[role="xpack"]
[testenv="basic"]
[[stop-trained-model-deployment]]
= Stop trained model deployment API
[subs="attributes"]
++++
<titleabbrev>Stop trained model deployment</titleabbrev>
++++

lcawl marked this conversation as resolved.
Show resolved Hide resolved
[[stop-trained-model-deployment-request]]
== {api-request-title}

`POST _ml/trained_models/<model_id>/deployment/_stop`

////
[[stop-trained-model-deployment-prereq]]
== {api-prereq-title}
////
////
[[stop-trained-model-deployment-desc]]
== {api-description-title}
////
[[stop-trained-model-deployment-path-params]]
== {api-path-parms-title}

`<model_id>`::
(Required, string)
include::{es-repo-dir}/ml/ml-shared.asciidoc[tag=model-id]

////
[[stop-trained-model-deployment-query-params]]
== {api-query-parms-title}
////
////
[role="child_attributes"]
[[stop-trained-model-deployment-results]]
== {api-response-body-title}
////
////
[[ml-get-trained-models-response-codes]]
== {api-response-codes-title}
////

////
[[stop-trained-model-deployment-example]]
== {api-examples-title}
////
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ml.infer_trained_model_deployment":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-df-analytics-apis.html",
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/infer-trained-model-deployment.html",
"description":"Evaluate a trained model."
},
"stability":"experimental",
Expand All @@ -20,7 +20,8 @@
"parts":{
"model_id":{
"type":"string",
"description":"The ID of the model to perform inference on"
"description":"The unique identifier of the trained model.",
"required":true
}
}
}
Expand All @@ -30,8 +31,13 @@
"timeout":{
"type":"time",
"required":false,
"description":"Controls the time to wait for the inference result"
"description":"Controls the amount of time to wait for inference results.",
"default":"10s"
}
},
"body":{
"description":"The input text to be evaluated.",
"required":true
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ml.start_trained_model_deployment":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-df-analytics-apis.html",
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/start-trained-model-deployment.html",
"description":"Start a trained model deployment."
},
"stability":"experimental",
Expand All @@ -20,7 +20,8 @@
"parts":{
"model_id":{
"type":"string",
"description":"The ID of the model to deploy"
"description":"The unique identifier of the trained model.",
"required":true
}
}
}
Expand All @@ -30,7 +31,8 @@
"timeout":{
"type":"time",
"required":false,
"description":"Controls the time to wait until the model is deployed"
"description":"Controls the amount of time to wait for the model to deploy.",
"default": "20s"
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"ml.stop_trained_model_deployment":{
"documentation":{
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/current/ml-df-analytics-apis.html",
"url":"https://www.elastic.co/guide/en/elasticsearch/reference/master/stop-trained-model-deployment.html",
"description":"Stop a trained model deployment."
},
"stability":"experimental",
Expand All @@ -20,7 +20,8 @@
"parts":{
"model_id":{
"type":"string",
"description":"The ID of the model to undeploy"
"description":"The unique identifier of the trained model.",
"required":true
}
}
}
Expand Down