Skip to content

Commit

Permalink
[ML] Explicitly set chunking settings in preconfigured endpoints (ela…
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkyle committed Nov 25, 2024
1 parent 4536d66 commit 4f587a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public void tearDown() throws Exception {
super.tearDown();
}

public void testGet() throws IOException {
var elserModel = getModel(ElasticsearchInternalService.DEFAULT_ELSER_ID);
assertDefaultElserConfig(elserModel);

var e5Model = getModel(ElasticsearchInternalService.DEFAULT_E5_ID);
assertDefaultE5Config(e5Model);
}

@SuppressWarnings("unchecked")
public void testInferDeploysDefaultElser() throws IOException {
var model = getModel(ElasticsearchInternalService.DEFAULT_ELSER_ID);
Expand Down Expand Up @@ -71,6 +79,7 @@ private static void assertDefaultElserConfig(Map<String, Object> modelConfig) {
adaptiveAllocations,
Matchers.is(Map.of("enabled", true, "min_number_of_allocations", 0, "max_number_of_allocations", 32))
);
assertDefaultChunkingSettings(modelConfig);
}

@SuppressWarnings("unchecked")
Expand Down Expand Up @@ -105,6 +114,17 @@ private static void assertDefaultE5Config(Map<String, Object> modelConfig) {
adaptiveAllocations,
Matchers.is(Map.of("enabled", true, "min_number_of_allocations", 0, "max_number_of_allocations", 32))
);
assertDefaultChunkingSettings(modelConfig);
}

@SuppressWarnings("unchecked")
private static void assertDefaultChunkingSettings(Map<String, Object> modelConfig) {
var chunkingSettings = (Map<String, Object>) modelConfig.get("chunking_settings");
assertThat(
modelConfig.toString(),
chunkingSettings,
Matchers.is(Map.of("strategy", "sentence", "max_chunk_size", 250, "sentence_overlap", 1))
);
}

public void testMultipleInferencesTriggeringDownloadAndDeploy() throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ public void updateModelsWithDynamicFields(List<Model> models, ActionListener<Lis
);
}

@Override
public void defaultConfigs(ActionListener<List<Model>> defaultsListener) {
preferredModelVariantFn.accept(defaultsListener.delegateFailureAndWrap((delegate, preferredModelVariant) -> {
if (PreferredModelVariant.LINUX_X86_OPTIMIZED.equals(preferredModelVariant)) {
Expand Down Expand Up @@ -891,7 +892,7 @@ private List<Model> defaultConfigs(boolean useLinuxOptimizedModel) {
new AdaptiveAllocationsSettings(Boolean.TRUE, 0, 32)
),
ElserMlNodeTaskSettings.DEFAULT,
null // default chunking settings
ChunkingSettingsBuilder.DEFAULT_SETTINGS
);
var defaultE5 = new MultilingualE5SmallModel(
DEFAULT_E5_ID,
Expand All @@ -903,7 +904,7 @@ private List<Model> defaultConfigs(boolean useLinuxOptimizedModel) {
useLinuxOptimizedModel ? MULTILINGUAL_E5_SMALL_MODEL_ID_LINUX_X86 : MULTILINGUAL_E5_SMALL_MODEL_ID,
new AdaptiveAllocationsSettings(Boolean.TRUE, 0, 32)
),
null // default chunking settings
ChunkingSettingsBuilder.DEFAULT_SETTINGS
);
return List.of(defaultElser, defaultE5);
}
Expand Down

0 comments on commit 4f587a0

Please sign in to comment.