Evaluate a trained model Added in 8.3.0
Path parameters
-
The unique identifier of the trained model.
Query parameters
-
timeout string
Controls the amount of time to wait for inference results.
Body Required
-
An array of objects to pass to the model for inference. The objects should contain a fields matching your configured trained model input. Typically, for NLP models, the field name is
text_field
. Currently, for NLP models, only a single value is allowed. -
inference_config object
Additional properties are allowed.
POST /_ml/trained_models/{model_id}/_infer
curl \
-X POST http://api.example.com/_ml/trained_models/{model_id}/_infer \
-H "Content-Type: application/json" \
-d '{"docs":[{"additionalProperty1":{},"additionalProperty2":{}}],"inference_config":{"regression":{"results_field":"string","num_top_feature_importance_values":42.0},"classification":{"num_top_classes":42.0,"num_top_feature_importance_values":42.0,"prediction_field_type":"string","results_field":"string","top_classes_results_field":"string"},"text_classification":{"num_top_classes":42.0,"tokenization":{"truncate":"first","span":42.0},"results_field":"string","classification_labels":["string"]},"zero_shot_classification":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string","multi_label":true,"labels":["string"]},"fill_mask":{"num_top_classes":42.0,"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"ner":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"pass_through":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"text_embedding":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"text_expansion":{"tokenization":{"truncate":"first","span":42.0},"results_field":"string"},"question_answering":{"question":"string","num_top_classes":42.0,"tokenization":{"truncate":"first","span":42.0},"results_field":"string","max_answer_length":42.0}}}'
Request examples
{
"docs": [
{
"additionalProperty1": {},
"additionalProperty2": {}
}
],
"inference_config": {
"regression": {
"results_field": "string",
"num_top_feature_importance_values": 42.0
},
"classification": {
"num_top_classes": 42.0,
"num_top_feature_importance_values": 42.0,
"prediction_field_type": "string",
"results_field": "string",
"top_classes_results_field": "string"
},
"text_classification": {
"num_top_classes": 42.0,
"tokenization": {
"truncate": "first",
"span": 42.0
},
"results_field": "string",
"classification_labels": [
"string"
]
},
"zero_shot_classification": {
"tokenization": {
"truncate": "first",
"span": 42.0
},
"results_field": "string",
"multi_label": true,
"labels": [
"string"
]
},
"fill_mask": {
"num_top_classes": 42.0,
"tokenization": {
"truncate": "first",
"span": 42.0
},
"results_field": "string"
},
"ner": {
"tokenization": {
"truncate": "first",
"span": 42.0
},
"results_field": "string"
},
"pass_through": {
"tokenization": {
"truncate": "first",
"span": 42.0
},
"results_field": "string"
},
"text_embedding": {
"tokenization": {
"truncate": "first",
"span": 42.0
},
"results_field": "string"
},
"text_expansion": {
"tokenization": {
"truncate": "first",
"span": 42.0
},
"results_field": "string"
},
"question_answering": {
"question": "string",
"num_top_classes": 42.0,
"tokenization": {
"truncate": "first",
"span": 42.0
},
"results_field": "string",
"max_answer_length": 42.0
}
}
}
Response examples (200)
{
"inference_results": [
{
"entities": [
{
"class_name": "string",
"class_probability": 42.0,
"entity": "string",
"start_pos": 42.0,
"end_pos": 42.0
}
],
"is_truncated": true,
"": 42.0,
"predicted_value_sequence": "string",
"prediction_probability": 42.0,
"prediction_score": 42.0,
"top_classes": [
{
"class_name": "string",
"class_probability": 42.0,
"class_score": 42.0
}
],
"warning": "string",
"feature_importance": [
{
"feature_name": "string",
"importance": 42.0,
"classes": [
{}
]
}
]
}
]
}