diff --git a/docs/examples/095e3f21941a9cc75f398389a075152d.asciidoc b/docs/examples/095e3f21941a9cc75f398389a075152d.asciidoc new file mode 100644 index 000000000..223e062c7 --- /dev/null +++ b/docs/examples/095e3f21941a9cc75f398389a075152d.asciidoc @@ -0,0 +1,22 @@ +// ml/trained-models/apis/infer-trained-model.asciidoc:1043 + +[source, python] +---- +resp = client.ml.infer_trained_model( + model_id="cross-encoder__ms-marco-tinybert-l-2-v2", + body={ + "docs": [ + { + "text_field": "Berlin has a population of 3,520,031 registered inhabitants in an area of 891.82 square kilometers." + }, + { + "text_field": "New York City is famous for the Metropolitan Museum of Art." + }, + ], + "inference_config": { + "text_similarity": {"text": "How many people live in Berlin?"} + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/0e5d25c7bb738c42d471020d678e2966.asciidoc b/docs/examples/0e5d25c7bb738c42d471020d678e2966.asciidoc new file mode 100644 index 000000000..d4550057e --- /dev/null +++ b/docs/examples/0e5d25c7bb738c42d471020d678e2966.asciidoc @@ -0,0 +1,12 @@ +// ml/trained-models/apis/start-trained-model-deployment.asciidoc:173 + +[source, python] +---- +resp = client.ml.start_trained_model_deployment( + model_id="my_model", + deployment_id="my_model_for_ingest", + wait_for="started", + timeout="1m", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/147d341cb212dcc015c129a9c5dcf9c9.asciidoc b/docs/examples/147d341cb212dcc015c129a9c5dcf9c9.asciidoc new file mode 100644 index 000000000..18e2e1d8a --- /dev/null +++ b/docs/examples/147d341cb212dcc015c129a9c5dcf9c9.asciidoc @@ -0,0 +1,10 @@ +// ml/trained-models/apis/put-trained-models-aliases.asciidoc:82 + +[source, python] +---- +resp = client.ml.put_trained_model_alias( + model_id="flight-delay-prediction-1574775339910", + model_alias="flight_delay_model", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/2d633b7f346b828d01f923ce9dbf6ad5.asciidoc b/docs/examples/2d633b7f346b828d01f923ce9dbf6ad5.asciidoc new file mode 100644 index 000000000..b2e874fd0 --- /dev/null +++ b/docs/examples/2d633b7f346b828d01f923ce9dbf6ad5.asciidoc @@ -0,0 +1,10 @@ +// ml/trained-models/apis/put-trained-model-vocabulary.asciidoc:63 + +[source, python] +---- +resp = client.ml.put_trained_model_vocabulary( + model_id="elastic__distilbert-base-uncased-finetuned-conll03-english", + body={"vocabulary": ["[PAD]", "[unused0]", ...]}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/35a272df8c919a12d7c3106a18245748.asciidoc b/docs/examples/35a272df8c919a12d7c3106a18245748.asciidoc new file mode 100644 index 000000000..9351c75e5 --- /dev/null +++ b/docs/examples/35a272df8c919a12d7c3106a18245748.asciidoc @@ -0,0 +1,16 @@ +// ml/trained-models/apis/infer-trained-model.asciidoc:849 + +[source, python] +---- +resp = client.ml.infer_trained_model( + model_id="lang_ident_model_1", + body={ + "docs": [ + { + "text": "The fool doth think he is wise, but the wise man knows himself to be a fool." + } + ] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/3c345feb7c52fd54bcb5d5505fd8bc3b.asciidoc b/docs/examples/3c345feb7c52fd54bcb5d5505fd8bc3b.asciidoc new file mode 100644 index 000000000..6e2840b65 --- /dev/null +++ b/docs/examples/3c345feb7c52fd54bcb5d5505fd8bc3b.asciidoc @@ -0,0 +1,15 @@ +// ml/trained-models/apis/infer-trained-model.asciidoc:1008 + +[source, python] +---- +resp = client.ml.infer_trained_model( + model_id="model2", + body={ + "docs": [{"text_field": ""}], + "inference_config": { + "question_answering": {"question": ""} + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/4c174e228b6b74497b73ef2be80de7ad.asciidoc b/docs/examples/4c174e228b6b74497b73ef2be80de7ad.asciidoc new file mode 100644 index 000000000..64d7ae76e --- /dev/null +++ b/docs/examples/4c174e228b6b74497b73ef2be80de7ad.asciidoc @@ -0,0 +1,7 @@ +// ml/trained-models/apis/get-trained-models.asciidoc:1460 + +[source, python] +---- +resp = client.ml.get_trained_models() +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/5837d5f50665ac0a26181d3aaeb3f204.asciidoc b/docs/examples/5837d5f50665ac0a26181d3aaeb3f204.asciidoc new file mode 100644 index 000000000..55b2e0e72 --- /dev/null +++ b/docs/examples/5837d5f50665ac0a26181d3aaeb3f204.asciidoc @@ -0,0 +1,10 @@ +// ml/trained-models/apis/start-trained-model-deployment.asciidoc:181 + +[source, python] +---- +resp = client.ml.start_trained_model_deployment( + model_id="my_model", + deployment_id="my_model_for_search", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/776b553df0e507c96dbdbaedecaca0cc.asciidoc b/docs/examples/776b553df0e507c96dbdbaedecaca0cc.asciidoc new file mode 100644 index 000000000..2246fd547 --- /dev/null +++ b/docs/examples/776b553df0e507c96dbdbaedecaca0cc.asciidoc @@ -0,0 +1,10 @@ +// ml/trained-models/apis/infer-trained-model.asciidoc:880 + +[source, python] +---- +resp = client.ml.infer_trained_model( + model_id="model2", + body={"docs": [{"text_field": "The movie was awesome!!"}]}, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/7e4cb3de3e3c75646b60f9f81ddc59cc.asciidoc b/docs/examples/7e4cb3de3e3c75646b60f9f81ddc59cc.asciidoc new file mode 100644 index 000000000..c150b3e98 --- /dev/null +++ b/docs/examples/7e4cb3de3e3c75646b60f9f81ddc59cc.asciidoc @@ -0,0 +1,9 @@ +// ml/trained-models/apis/clear-trained-model-deployment-cache.asciidoc:43 + +[source, python] +---- +resp = client.ml.clear_trained_model_deployment_cache( + model_id="elastic__distilbert-base-uncased-finetuned-conll03-english", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/821422f8a03dc98d024a15fc737fe9eb.asciidoc b/docs/examples/821422f8a03dc98d024a15fc737fe9eb.asciidoc new file mode 100644 index 000000000..7ebb1d83a --- /dev/null +++ b/docs/examples/821422f8a03dc98d024a15fc737fe9eb.asciidoc @@ -0,0 +1,10 @@ +// ml/trained-models/apis/delete-trained-models-aliases.asciidoc:51 + +[source, python] +---- +resp = client.ml.delete_trained_model_alias( + model_id="flight-delay-prediction-1574775339910", + model_alias="flight_delay_model", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/9225841fdcddaf83ebdb90c2b0399e20.asciidoc b/docs/examples/9225841fdcddaf83ebdb90c2b0399e20.asciidoc new file mode 100644 index 000000000..13ca7d4e0 --- /dev/null +++ b/docs/examples/9225841fdcddaf83ebdb90c2b0399e20.asciidoc @@ -0,0 +1,7 @@ +// ml/trained-models/apis/get-trained-models-stats.asciidoc:405 + +[source, python] +---- +resp = client.ml.get_trained_models_stats() +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/9cbb097e5498a9fde39e3b1d3b62a4d2.asciidoc b/docs/examples/9cbb097e5498a9fde39e3b1d3b62a4d2.asciidoc new file mode 100644 index 000000000..f8fde02c8 --- /dev/null +++ b/docs/examples/9cbb097e5498a9fde39e3b1d3b62a4d2.asciidoc @@ -0,0 +1,18 @@ +// ml/trained-models/apis/infer-trained-model.asciidoc:945 + +[source, python] +---- +resp = client.ml.infer_trained_model( + model_id="model2", + body={ + "docs": [{"text_field": "This is a very happy person"}], + "inference_config": { + "zero_shot_classification": { + "labels": ["glad", "sad", "bad", "rad"], + "multi_label": False, + } + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/aa6282d4bc92c753c4bd7a5b166abece.asciidoc b/docs/examples/aa6282d4bc92c753c4bd7a5b166abece.asciidoc new file mode 100644 index 000000000..cf00e978a --- /dev/null +++ b/docs/examples/aa6282d4bc92c753c4bd7a5b166abece.asciidoc @@ -0,0 +1,11 @@ +// ml/trained-models/apis/start-trained-model-deployment.asciidoc:133 + +[source, python] +---- +resp = client.ml.start_trained_model_deployment( + model_id="elastic__distilbert-base-uncased-finetuned-conll03-english", + wait_for="started", + timeout="1m", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/be6b0bfcdce1ef100af89f74da5d4748.asciidoc b/docs/examples/be6b0bfcdce1ef100af89f74da5d4748.asciidoc new file mode 100644 index 000000000..c917e5a53 --- /dev/null +++ b/docs/examples/be6b0bfcdce1ef100af89f74da5d4748.asciidoc @@ -0,0 +1,15 @@ +// ml/trained-models/apis/put-trained-model-definition-part.asciidoc:64 + +[source, python] +---- +resp = client.ml.put_trained_model_definition_part( + model_id="elastic__distilbert-base-uncased-finetuned-conll03-english", + part="0", + body={ + "definition": "...", + "total_definition_length": 265632637, + "total_parts": 64, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/cc90639f2e65bd89cb73296cac6135cf.asciidoc b/docs/examples/cc90639f2e65bd89cb73296cac6135cf.asciidoc new file mode 100644 index 000000000..f8c8da8cd --- /dev/null +++ b/docs/examples/cc90639f2e65bd89cb73296cac6135cf.asciidoc @@ -0,0 +1,9 @@ +// ml/trained-models/apis/delete-trained-models.asciidoc:54 + +[source, python] +---- +resp = client.ml.delete_trained_model( + model_id="regression-job-one-1574775307356", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/cee491dd0a8d10ed0cb11a2faa0c99f0.asciidoc b/docs/examples/cee491dd0a8d10ed0cb11a2faa0c99f0.asciidoc new file mode 100644 index 000000000..785bf070d --- /dev/null +++ b/docs/examples/cee491dd0a8d10ed0cb11a2faa0c99f0.asciidoc @@ -0,0 +1,19 @@ +// ml/trained-models/apis/infer-trained-model.asciidoc:1078 + +[source, python] +---- +resp = client.ml.infer_trained_model( + model_id="model2", + body={ + "docs": [ + { + "text_field": "The Amazon rainforest covers most of the Amazon basin in South America" + } + ], + "inference_config": { + "ner": {"tokenization": {"bert": {"truncate": "first"}}} + }, + }, +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/d50b030edfe6d1128eb76aa5ba9d4e27.asciidoc b/docs/examples/d50b030edfe6d1128eb76aa5ba9d4e27.asciidoc new file mode 100644 index 000000000..d16117294 --- /dev/null +++ b/docs/examples/d50b030edfe6d1128eb76aa5ba9d4e27.asciidoc @@ -0,0 +1,11 @@ +// ml/trained-models/apis/put-trained-models-aliases.asciidoc:94 + +[source, python] +---- +resp = client.ml.put_trained_model_alias( + model_id="flight-delay-prediction-1580004349800", + model_alias="flight_delay_model", + reassign="true", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/dbf93d02ab86a09929a21232b19709cc.asciidoc b/docs/examples/dbf93d02ab86a09929a21232b19709cc.asciidoc new file mode 100644 index 000000000..165dcd621 --- /dev/null +++ b/docs/examples/dbf93d02ab86a09929a21232b19709cc.asciidoc @@ -0,0 +1,9 @@ +// ml/trained-models/apis/stop-trained-model-deployment.asciidoc:67 + +[source, python] +---- +resp = client.ml.stop_trained_model_deployment( + model_id="my_model_for_search", +) +print(resp) +---- \ No newline at end of file diff --git a/docs/examples/ff776c0fccf93e1c7050f7cb7efbae0b.asciidoc b/docs/examples/ff776c0fccf93e1c7050f7cb7efbae0b.asciidoc new file mode 100644 index 000000000..864363aea --- /dev/null +++ b/docs/examples/ff776c0fccf93e1c7050f7cb7efbae0b.asciidoc @@ -0,0 +1,12 @@ +// ml/trained-models/apis/infer-trained-model.asciidoc:905 + +[source, python] +---- +resp = client.ml.infer_trained_model( + model_id="model2", + body={ + "docs": [{"text_field": "Hi my name is Josh and I live in Berlin"}] + }, +) +print(resp) +---- \ No newline at end of file diff --git a/utils/generate-examples.py b/utils/generate-examples.py index ce1262509..eb5e9061f 100644 --- a/utils/generate-examples.py +++ b/utils/generate-examples.py @@ -110,6 +110,20 @@ "inference/delete-inference.asciidoc", "inference/post-inference.asciidoc", "inference/put-inference.asciidoc", + "ml/trained-models/apis/clear-trained-model-deployment-cache.asciidoc", + "ml/trained-models/apis/delete-trained-models-aliases.asciidoc", + "ml/trained-models/apis/delete-trained-models.asciidoc", + "ml/trained-models/apis/get-trained-models-stats.asciidoc", + "ml/trained-models/apis/get-trained-models.asciidoc", + "ml/trained-models/apis/infer-trained-model-deployment.asciidoc", + "ml/trained-models/apis/infer-trained-model.asciidoc", + "ml/trained-models/apis/put-trained-model-definition-part.asciidoc", + "ml/trained-models/apis/put-trained-model-vocabulary.asciidoc", + "ml/trained-models/apis/put-trained-models-aliases.asciidoc", + "ml/trained-models/apis/put-trained-models.asciidoc", + "ml/trained-models/apis/start-trained-model-deployment.asciidoc", + "ml/trained-models/apis/stop-trained-model-deployment.asciidoc", + "ml/trained-models/apis/update-trained-model-deployment.asciidoc", ]