Skip to content

[ML] Elasticsearch inference service does not validate the model against the task type #122249

@davidkyle

Description

@davidkyle

Elasticsearch Version

8.17

Installed Plugins

No response

Java Version

bundled

OS Version

any

Problem Description

It is possible to create an inference endpoint with task_type == sparse_embedding but using the reranker model. The inference service should validate the model matches the task type by calling inference on the model before the endpoint is created.

Steps to Reproduce

# Create a sparse embedding endpoint with the reranker model

PUT _inference/sparse_embedding/oops
{
  "service": "elasticsearch",
  "service_settings": {
    "num_allocations": 1,
    "num_threads": 1,
    "model_id": ".rerank-v1" 
  }
}

# Then try to use it
POST _inference/oops 
{
  "input": "but this is the reranker"
}

{
  "error": {
    "root_cause": [
      {
        "type": "status_exception",
        "reason": "Trained model [.rerank-v1] is configured for task [text_similarity] but called with task [text_expansion]"
      }
    ],
    "type": "status_exception",
    "reason": "Trained model [.rerank-v1] is configured for task [text_similarity] but called with task [text_expansion]"
  },
  "status": 403
}

Logs (if relevant)

No response

Metadata

Metadata

Labels

:mlMachine learning>bugFeature:GenAIFeatures around GenAITeam:MLMeta label for the ML team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions