Skip to content

Commit

Permalink
Explicitly set default chunking settings
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkyle committed Nov 22, 2024
1 parent a1247b3 commit 4027642
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 @@ -51,6 +51,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 @@ -79,6 +87,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 @@ -113,6 +122,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 @@ -862,6 +862,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 @@ -892,7 +893,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 @@ -904,7 +905,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 4027642

Please sign in to comment.