Skip to content

[8.19] add default inference endpoint for Elastic Inference Service rerank (#129681) #129985

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

Merged
merged 6 commits into from
Jun 26, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,26 @@ private Iterable<String> providersFor(TaskType taskType) throws IOException {
}

public void testGetServicesWithRerankTaskType() throws IOException {
List<Object> services = getServices(TaskType.RERANK);
assertThat(services.size(), equalTo(11));

var providers = providers(services);

assertThat(
providersFor(TaskType.RERANK),
containsInAnyOrder(
List.of(
"alibabacloud-ai-search",
"amazon_sagemaker",
"cohere",
"custom",
"elastic",
"elasticsearch",
"googlevertexai",
"hugging_face",
"jinaai",
"test_reranking_service",
"voyageai",
"hugging_face",
"amazon_sagemaker"
"voyageai"
).toArray()
)
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void enqueueAuthorizeAllModelsResponse() {
"model_name": "multilingual-embed-v1",
"task_types": ["embed/text/dense"]
},
{
{
"model_name": "rerank-v1",
"task_types": ["rerank/text/text-similarity"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ public void testRemoves_DefaultChatCompletion_V1_WhenAuthorizationDoesNotReturnA
{
"model_name": "rerank-v1",
"task_types": ["rerank/text/text-similarity"]

},
{
"model_name": "multilingual-embed-v1",
Expand All @@ -299,28 +300,29 @@ public void testRemoves_DefaultChatCompletion_V1_WhenAuthorizationDoesNotReturnA

assertThat(service.supportedStreamingTasks(), is(EnumSet.noneOf(TaskType.class)));
assertThat(
service.defaultConfigIds(),
containsInAnyOrder(
new InferenceService.DefaultConfigId(
".elser-v2-elastic",
MinimalServiceSettings.sparseEmbedding(ElasticInferenceService.NAME),
service
),
new InferenceService.DefaultConfigId(
".multilingual-embed-v1-elastic",
MinimalServiceSettings.textEmbedding(
ElasticInferenceService.NAME,
ElasticInferenceService.DENSE_TEXT_EMBEDDINGS_DIMENSIONS,
ElasticInferenceService.defaultDenseTextEmbeddingsSimilarity(),
DenseVectorFieldMapper.ElementType.FLOAT
),
service
service.supportedTaskTypes(),
is(EnumSet.of(TaskType.TEXT_EMBEDDING, TaskType.SPARSE_EMBEDDING, TaskType.RERANK))
);
containsInAnyOrder(
new InferenceService.DefaultConfigId(
".elser-v2-elastic",
MinimalServiceSettings.sparseEmbedding(ElasticInferenceService.NAME),
service
),
new InferenceService.DefaultConfigId(
".multilingual-embed-v1-elastic",
MinimalServiceSettings.textEmbedding(
ElasticInferenceService.NAME,
ElasticInferenceService.DENSE_TEXT_EMBEDDINGS_DIMENSIONS,
ElasticInferenceService.defaultDenseTextEmbeddingsSimilarity(),
DenseVectorFieldMapper.ElementType.FLOAT
),
new InferenceService.DefaultConfigId(
".rerank-v1-elastic",
MinimalServiceSettings.rerank(ElasticInferenceService.NAME),
service
)
service
),
new InferenceService.DefaultConfigId(
".rerank-v1-elastic",
MinimalServiceSettings.rerank(ElasticInferenceService.NAME),
service
)
);
assertThat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ private static Map<String, DefaultModelConfig> initDefaultEndpoints(
DenseVectorFieldMapper.ElementType.FLOAT
)
),

DEFAULT_RERANK_MODEL_ID_V1,
new DefaultModelConfig(
new ElasticInferenceServiceRerankModel(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public URI uri() {
private URI createUri() throws ElasticsearchStatusException {
try {
// TODO, consider transforming the base URL into a URI for better error handling.
return new URI(elasticInferenceServiceComponents().elasticInferenceServiceUrl() + "/api/v1/rerank");
return new URI(elasticInferenceServiceComponents().elasticInferenceServiceUrl() + "/api/v1/rerank/text/text-similarity");
} catch (URISyntaxException e) {
throw new ElasticsearchStatusException(
"Failed to create URI for service ["
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,7 @@ public void testDefaultConfigs_Returns_DefaultEndpoints_WhenTaskTypeIsCorrect()
PlainActionFuture<List<Model>> listener = new PlainActionFuture<>();
service.defaultConfigs(listener);
var models = listener.actionGet(TIMEOUT);

assertThat(models.size(), is(4));
assertThat(models.get(0).getConfigurations().getInferenceEntityId(), is(".elser-v2-elastic"));
assertThat(models.get(1).getConfigurations().getInferenceEntityId(), is(".multilingual-embed-v1-elastic"));
Expand Down