Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
99f648c
merging
Sep 9, 2024
bc9c7d3
copy elser service files into elasticsearch service
Sep 19, 2024
103e5f6
Add deprecation log message for elser service
Sep 19, 2024
6951cb2
improve deprecation warning
Sep 19, 2024
99d9e84
change elasticsearch internal service elser case to use elser model
Sep 19, 2024
f9da1bd
switch elasticsearch elser tests to use elasticsearch elser
Sep 19, 2024
2362d7e
Update docs/changelog/113216.yaml
maxhniebergall Sep 19, 2024
118519c
alias elser service to elasticsearch
Sep 20, 2024
1e4ec6a
delete elser service package now that elasticsearch service supports …
Sep 20, 2024
9352a30
Add deprecation warning to infer API for elser
Sep 23, 2024
f994af3
Fix accidentally introduced NPE and retain BWC support for null model…
Sep 23, 2024
18b1ed0
change "area" to "REST API" because "Machine Learning" isn't an optio…
maxhniebergall Sep 23, 2024
749edc6
change elser literals to static variable
Sep 23, 2024
4811955
change Put and Elasticsearch Internal service
Sep 23, 2024
8b88ece
fix up tests to match new elasticsearch service semantics regarding e…
Sep 23, 2024
ed4c6f6
Move passing of service name
Sep 23, 2024
b5d6a9f
add persistence for elser models in elasticsearch
Sep 23, 2024
49c9863
copy elser service files into elasticsearch service
Sep 19, 2024
d02e44e
Add deprecation log message for elser service
Sep 19, 2024
ed234c7
Add deprecation warning to infer API for elser
Sep 23, 2024
0a0e3c5
fix merge conflicts
Sep 27, 2024
0d23a1e
Merge branch 'main' of github.com:elastic/elasticsearch into mergeEls…
Oct 2, 2024
703bc91
fix merge
Oct 2, 2024
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
10 changes: 10 additions & 0 deletions docs/changelog/113216.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
pr: 113216
summary: "[Inference API] Deprecate elser service"
area: Machine Learning
type: deprecation
issues: []
deprecation:
title: "[Inference API] Deprecate elser service"
area: REST API
details: The `elser` service of the inference API will be removed in an upcoming release. Please use the elasticsearch service instead.
impact: In the current version there is no impact. In a future version, users of the `elser` service will no longer be able to use it, and will be required to use the `elasticsearch` service to access elser through the inference API.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@ public Map<String, InferenceService> getServices() {
}

public Optional<InferenceService> getService(String serviceName) {
return Optional.ofNullable(services.get(serviceName));

if ("elser".equals(serviceName)) { // ElserService.NAME before removal
// here we are aliasing the elser service to use the elasticsearch service instead
return Optional.ofNullable(services.get("elasticsearch")); // ElasticsearchInternalService.NAME
} else {
return Optional.ofNullable(services.get(serviceName));
}
}

public List<NamedWriteableRegistry.Entry> getNamedWriteables() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,10 @@
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xpack.inference.InferencePlugin;
import org.elasticsearch.xpack.inference.registry.ModelRegistry;
import org.elasticsearch.xpack.inference.services.elser.ElserInternalModel;
import org.elasticsearch.xpack.inference.services.elser.ElserInternalService;
import org.elasticsearch.xpack.inference.services.elser.ElserInternalServiceSettingsTests;
import org.elasticsearch.xpack.inference.services.elser.ElserInternalServiceTests;
import org.elasticsearch.xpack.inference.services.elser.ElserMlNodeTaskSettingsTests;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalService;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElserInternalModel;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElserInternalServiceSettingsTests;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElserMlNodeTaskSettingsTests;
import org.junit.Before;

import java.io.IOException;
Expand Down Expand Up @@ -117,8 +116,10 @@ public void testGetModel() throws Exception {

assertEquals(model.getConfigurations().getService(), modelHolder.get().service());

var elserService = new ElserInternalService(new InferenceServiceExtension.InferenceServiceFactoryContext(mock(Client.class)));
ElserInternalModel roundTripModel = elserService.parsePersistedConfigWithSecrets(
var elserService = new ElasticsearchInternalService(
new InferenceServiceExtension.InferenceServiceFactoryContext(mock(Client.class))
);
ElserInternalModel roundTripModel = (ElserInternalModel) elserService.parsePersistedConfigWithSecrets(
modelHolder.get().inferenceEntityId(),
modelHolder.get().taskType(),
modelHolder.get().settings(),
Expand Down Expand Up @@ -274,7 +275,17 @@ public void testGetModelWithSecrets() throws InterruptedException {
}

private Model buildElserModelConfig(String inferenceEntityId, TaskType taskType) {
return ElserInternalServiceTests.randomModelConfig(inferenceEntityId, taskType);
return switch (taskType) {
case SPARSE_EMBEDDING -> new org.elasticsearch.xpack.inference.services.elasticsearch.ElserInternalModel(
inferenceEntityId,
taskType,
ElasticsearchInternalService.NAME,
ElserInternalServiceSettingsTests.createRandom(),
ElserMlNodeTaskSettingsTests.createRandom()
);
default -> throw new IllegalArgumentException("task type " + taskType + " is not supported");
};

}

protected <T> void blockingCall(Consumer<ActionListener<T>> function, AtomicReference<T> response, AtomicReference<Exception> error)
Expand All @@ -297,7 +308,7 @@ private static Model buildModelWithUnknownField(String inferenceEntityId) {
new ModelWithUnknownField(
inferenceEntityId,
TaskType.SPARSE_EMBEDDING,
ElserInternalService.NAME,
ElasticsearchInternalService.NAME,
ElserInternalServiceSettingsTests.createRandom(),
ElserMlNodeTaskSettingsTests.createRandom()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
import org.elasticsearch.xpack.inference.services.elasticsearch.CustomElandInternalTextEmbeddingServiceSettings;
import org.elasticsearch.xpack.inference.services.elasticsearch.CustomElandRerankTaskSettings;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalServiceSettings;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElserInternalServiceSettings;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElserMlNodeTaskSettings;
import org.elasticsearch.xpack.inference.services.elasticsearch.MultilingualE5SmallInternalServiceSettings;
import org.elasticsearch.xpack.inference.services.elser.ElserInternalServiceSettings;
import org.elasticsearch.xpack.inference.services.elser.ElserMlNodeTaskSettings;
import org.elasticsearch.xpack.inference.services.googleaistudio.completion.GoogleAiStudioCompletionServiceSettings;
import org.elasticsearch.xpack.inference.services.googleaistudio.embeddings.GoogleAiStudioEmbeddingsServiceSettings;
import org.elasticsearch.xpack.inference.services.googlevertexai.GoogleVertexAiSecretSettings;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceFeature;
import org.elasticsearch.xpack.inference.services.elastic.ElasticInferenceServiceSettings;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalService;
import org.elasticsearch.xpack.inference.services.elser.ElserInternalService;
import org.elasticsearch.xpack.inference.services.googleaistudio.GoogleAiStudioService;
import org.elasticsearch.xpack.inference.services.googlevertexai.GoogleVertexAiService;
import org.elasticsearch.xpack.inference.services.huggingface.HuggingFaceService;
Expand Down Expand Up @@ -229,7 +228,6 @@ public void loadExtensions(ExtensionLoader loader) {

public List<InferenceServiceExtension.Factory> getInferenceServiceFactories() {
return List.of(
ElserInternalService::new,
context -> new HuggingFaceElserService(httpFactory.get(), serviceComponents.get()),
context -> new HuggingFaceService(httpFactory.get(), serviceComponents.get()),
context -> new OpenAiService(httpFactory.get(), serviceComponents.get()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import org.elasticsearch.action.ActionListener;
import org.elasticsearch.action.support.ActionFilters;
import org.elasticsearch.action.support.HandledTransportAction;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.util.concurrent.EsExecutors;
import org.elasticsearch.common.xcontent.ChunkedToXContent;
import org.elasticsearch.inference.InferenceService;
Expand All @@ -25,12 +27,14 @@
import org.elasticsearch.xpack.core.inference.action.InferenceAction;
import org.elasticsearch.xpack.inference.action.task.StreamingTaskManager;
import org.elasticsearch.xpack.inference.registry.ModelRegistry;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalService;
import org.elasticsearch.xpack.inference.telemetry.InferenceStats;

import java.util.Set;
import java.util.stream.Collectors;

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalService.OLD_ELSER_SERVICE_NAME;

public class TransportInferenceAction extends HandledTransportAction<InferenceAction.Request, InferenceAction.Response> {
private static final String STREAMING_INFERENCE_TASK_TYPE = "streaming_inference";
Expand All @@ -42,6 +46,7 @@ public class TransportInferenceAction extends HandledTransportAction<InferenceAc
private final InferenceServiceRegistry serviceRegistry;
private final InferenceStats inferenceStats;
private final StreamingTaskManager streamingTaskManager;
private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(TransportInferenceAction.class);

@Inject
public TransportInferenceAction(
Expand Down Expand Up @@ -75,6 +80,15 @@ protected void doExecute(Task task, InferenceAction.Request request, ActionListe
);
return;
}
if (service.get().name().equals(OLD_ELSER_SERVICE_NAME)) {
DEPRECATION_LOGGER.warn(
DeprecationCategory.API,
"inference_api_elser_service",
"The [{}] service is deprecated and will be removed in a future release. Use the [{}] service instead.",
OLD_ELSER_SERVICE_NAME,
ElasticsearchInternalService.NAME
);
}

if (request.getTaskType().isAnyOrSame(unparsedModel.taskType()) == false) {
// not the wildcard task type and not the model task type
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@
import org.elasticsearch.cluster.block.ClusterBlockLevel;
import org.elasticsearch.cluster.metadata.IndexNameExpressionResolver;
import org.elasticsearch.cluster.service.ClusterService;
import org.elasticsearch.common.logging.DeprecationCategory;
import org.elasticsearch.common.logging.DeprecationLogger;
import org.elasticsearch.common.settings.ClusterSettings;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.util.concurrent.EsExecutors;
Expand All @@ -45,18 +47,24 @@
import org.elasticsearch.xpack.core.ml.utils.MlPlatformArchitecturesUtil;
import org.elasticsearch.xpack.inference.InferencePlugin;
import org.elasticsearch.xpack.inference.registry.ModelRegistry;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalService;

import java.io.IOException;
import java.util.Map;
import java.util.Set;

import static org.elasticsearch.core.Strings.format;
import static org.elasticsearch.xpack.inference.services.elasticsearch.BaseElasticsearchInternalService.selectDefaultModelVariantBasedOnClusterArchitecture;
import static org.elasticsearch.xpack.inference.services.elasticsearch.ElasticsearchInternalService.OLD_ELSER_SERVICE_NAME;
import static org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels.ELSER_V2_MODEL;
import static org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels.ELSER_V2_MODEL_LINUX_X86;

public class TransportPutInferenceModelAction extends TransportMasterNodeAction<
PutInferenceModelAction.Request,
PutInferenceModelAction.Response> {

private static final Logger logger = LogManager.getLogger(TransportPutInferenceModelAction.class);
private static final DeprecationLogger DEPRECATION_LOGGER = DeprecationLogger.getLogger(PutInferenceModelAction.class);

private final ModelRegistry modelRegistry;
private final InferenceServiceRegistry serviceRegistry;
Expand Down Expand Up @@ -157,9 +165,31 @@ protected void masterOperation(
}

if (service.get().isInClusterService()) {

// required for BWC of elser service in elasticsearch service TODO remove when elser service deprecated
requestAsMap.put(ModelConfigurations.SERVICE, serviceName);

// Find the cluster platform as the service may need that
// information when creating the model
MlPlatformArchitecturesUtil.getMlNodesArchitecturesSet(listener.delegateFailureAndWrap((delegate, architectures) -> {
if (serviceName.equals(OLD_ELSER_SERVICE_NAME)) {
String modelId = selectDefaultModelVariantBasedOnClusterArchitecture(
architectures,
ELSER_V2_MODEL_LINUX_X86,
ELSER_V2_MODEL
);

DEPRECATION_LOGGER.warn(
DeprecationCategory.API,
"inference_api_elser_service",
"The [{}] service is deprecated and will be removed in a future release. Use the [{}] service instead, with"
+ " [model_id] set to [{}] in the [service_settings]",
OLD_ELSER_SERVICE_NAME,
ElasticsearchInternalService.NAME,
modelId
);
}

if (architectures.isEmpty() && clusterIsInElasticCloud(clusterService.getClusterSettings())) {
parseAndStoreModel(
service.get(),
Expand Down Expand Up @@ -224,7 +254,6 @@ private void parseAndStoreModel(
});

service.parseRequestConfig(inferenceEntityId, taskType, config, platformArchitectures, parsedModelListener);

}

private void putAndStartModel(InferenceService service, Model model, ActionListener<PutInferenceModelAction.Response> finalListener) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.elasticsearch.xpack.inference.external.action.ExecutableAction;
import org.elasticsearch.xpack.inference.external.action.elastic.ElasticInferenceServiceActionVisitor;
import org.elasticsearch.xpack.inference.services.ConfigurationParseContext;
import org.elasticsearch.xpack.inference.services.elser.ElserModels;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels;

import java.net.URI;
import java.net.URISyntaxException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.elasticsearch.inference.ServiceSettings;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xpack.inference.services.ConfigurationParseContext;
import org.elasticsearch.xpack.inference.services.elser.ElserModels;
import org.elasticsearch.xpack.inference.services.elasticsearch.ElserModels;
import org.elasticsearch.xpack.inference.services.settings.FilteredXContentObject;
import org.elasticsearch.xpack.inference.services.settings.RateLimitSettings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.elasticsearch.xpack.core.ml.inference.TrainedModelInput;
import org.elasticsearch.xpack.core.ml.inference.TrainedModelPrefixStrings;
import org.elasticsearch.xpack.core.ml.inference.trainedmodel.InferenceConfigUpdate;
import org.elasticsearch.xpack.inference.services.elser.ElserInternalModel;

import java.io.IOException;
import java.util.EnumSet;
Expand Down
Loading
Loading