Perform sparse embedding inference on the service Generally available; Added in 8.11.0

POST /_inference/sparse_embedding/{inference_id}

Path parameters

  • inference_id string Required

    The inference Id

Query parameters

application/json

Body

Responses

  • 200 application/json
    Hide response attribute Show response attribute object
    • sparse_embedding array[object] Required
      Hide sparse_embedding attribute Show sparse_embedding attribute object
      • embedding object Required

        Sparse Embedding tokens are represented as a dictionary of string to double.

        Hide embedding attribute Show embedding attribute object
        • * number Additional properties
POST /_inference/sparse_embedding/{inference_id}
POST _inference/sparse_embedding/my-elser-model { "input": "The sky above the port was the color of television tuned to a dead channel." }
resp = client.inference.sparse_embedding( inference_id="my-elser-model", input="The sky above the port was the color of television tuned to a dead channel.", )
const response = await client.inference.sparseEmbedding({ inference_id: "my-elser-model", input: "The sky above the port was the color of television tuned to a dead channel.", });
response = client.inference.sparse_embedding( inference_id: "my-elser-model", body: { "input": "The sky above the port was the color of television tuned to a dead channel." } )
$resp = $client->inference()->sparseEmbedding([ "inference_id" => "my-elser-model", "body" => [ "input" => "The sky above the port was the color of television tuned to a dead channel.", ], ]);
curl -X POST -H "Authorization: ApiKey $ELASTIC_API_KEY" -H "Content-Type: application/json" -d '{"input":"The sky above the port was the color of television tuned to a dead channel."}' "$ELASTICSEARCH_URL/_inference/sparse_embedding/my-elser-model"
client.inference().sparseEmbedding(s -> s .inferenceId("my-elser-model") .input("The sky above the port was the color of television tuned to a dead channel.") ); 
Request example
Run `POST _inference/sparse_embedding/my-elser-model` to perform sparse embedding on the example sentence.
{ "input": "The sky above the port was the color of television tuned to a dead channel." }
Response examples (200)
An abbreviated response from `POST _inference/sparse_embedding/my-elser-model`.
{ "sparse_embedding": [ { "port": 2.1259406, "sky": 1.7073475, "color": 1.6922266, "dead": 1.6247464, "television": 1.3525393, "above": 1.2425821, "tuned": 1.1440028, "colors": 1.1218185, "tv": 1.0111054, "ports": 1.0067928, "poem": 1.0042328, "channel": 0.99471164, "tune": 0.96235967, "scene": 0.9020516 } ] }