Skip to content

Commit

Permalink
fix model id check
Browse files Browse the repository at this point in the history
  • Loading branch information
davidkyle committed Oct 14, 2024
1 parent 994bbc2 commit 859f6b1
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,12 @@ private void preferredVariantFromPlatformArchitecture(ActionListener<PreferredMo
// However, in Elastic cloud ml nodes run on Linux x86
delegate.onResponse(PreferredModelVariant.LINUX_X86_OPTIMIZED);
} else {
delegate.onResponse(PreferredModelVariant.PLATFORM_AGNOSTIC);
boolean homogenous = architectures.size() == 1;
if (homogenous && architectures.iterator().next().equals("linux-x86_64")) {
delegate.onResponse(PreferredModelVariant.LINUX_X86_OPTIMIZED);
} else {
delegate.onResponse(PreferredModelVariant.PLATFORM_AGNOSTIC);
}
}
}),
client,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,14 +388,6 @@ private void elserCase(
);
}

if (modelVariantDoesNotMatchArchitecturesAndIsNotPlatformAgnostic(preferredModelVariant, esServiceSettingsBuilder.getModelId())) {
throw new IllegalArgumentException(
"Error parsing request config, model id does not match any models available on this platform. Was ["
+ esServiceSettingsBuilder.getModelId()
+ "]"
);
}

throwIfNotEmptyMap(config, name());
throwIfNotEmptyMap(serviceSettingsMap, name());

Expand All @@ -411,19 +403,6 @@ private void elserCase(
);
}

private static boolean modelVariantDoesNotMatchArchitecturesAndIsNotPlatformAgnostic(
PreferredModelVariant preferredModelVariant,
String modelId
) {
return modelId.equals(
selectDefaultModelVariantBasedOnClusterArchitecture(
preferredModelVariant,
MULTILINGUAL_E5_SMALL_MODEL_ID_LINUX_X86,
MULTILINGUAL_E5_SMALL_MODEL_ID
)
);
}

@Override
public Model parsePersistedConfigWithSecrets(
String inferenceEntityId,
Expand Down Expand Up @@ -799,7 +778,10 @@ private RankedDocsResults textSimilarityResultsToRankedDocs(
}

public List<DefaultConfigId> defaultConfigIds() {
return List.of(new DefaultConfigId(DEFAULT_ELSER_ID, TaskType.SPARSE_EMBEDDING, this));
return List.of(
new DefaultConfigId(DEFAULT_ELSER_ID, TaskType.SPARSE_EMBEDDING, this),
new DefaultConfigId(DEFAULT_E5_ID, TaskType.TEXT_EMBEDDING, this)
);
}

/**
Expand Down Expand Up @@ -839,8 +821,19 @@ private List<Model> defaultConfigs(boolean useLinuxOptimizedModel) {
ElserMlNodeTaskSettings.DEFAULT,
null // default chunking settings
);

return List.of(defaultElser);
var defaultE5 = new MultilingualE5SmallModel(
DEFAULT_E5_ID,
TaskType.TEXT_EMBEDDING,
NAME,
new MultilingualE5SmallInternalServiceSettings(
null,
1,
useLinuxOptimizedModel ? MULTILINGUAL_E5_SMALL_MODEL_ID_LINUX_X86 : MULTILINGUAL_E5_SMALL_MODEL_ID,
new AdaptiveAllocationsSettings(Boolean.TRUE, 1, 8)
),
null // default chunking settings
);
return List.of(defaultElser, defaultE5);
}

@Override
Expand Down

0 comments on commit 859f6b1

Please sign in to comment.