Skip to content

Commit 6f49773

Browse files
authored
[ML] Support any tokenizers for text_expansion task (#116935) (#117018)
Backport of #116935
1 parent 04b0a7b commit 6f49773

File tree

2 files changed

+0
-17
lines changed

2 files changed

+0
-17
lines changed

x-pack/plugin/core/src/main/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/TextExpansionConfig.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,6 @@ public TextExpansionConfig(
7676
this.vocabularyConfig = Optional.ofNullable(vocabularyConfig)
7777
.orElse(new VocabularyConfig(InferenceIndexConstants.nativeDefinitionStore()));
7878
this.tokenization = tokenization == null ? Tokenization.createDefault() : tokenization;
79-
if (this.tokenization instanceof BertTokenization == false) {
80-
throw ExceptionsHelper.badRequestException(
81-
"text expansion models must be configured with BERT tokenizer, [{}] given",
82-
this.tokenization.getName()
83-
);
84-
}
8579
this.resultsField = resultsField;
8680
}
8781

x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/inference/trainedmodel/TextExpansionConfigTests.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77

88
package org.elasticsearch.xpack.core.ml.inference.trainedmodel;
99

10-
import org.elasticsearch.ElasticsearchStatusException;
1110
import org.elasticsearch.TransportVersion;
1211
import org.elasticsearch.common.io.stream.Writeable;
13-
import org.elasticsearch.rest.RestStatus;
1412
import org.elasticsearch.xcontent.XContentParser;
1513
import org.elasticsearch.xpack.core.ml.inference.InferenceConfigItemTestCase;
1614

@@ -67,13 +65,4 @@ protected TextExpansionConfig doParseInstance(XContentParser parser) throws IOEx
6765
protected TextExpansionConfig mutateInstanceForVersion(TextExpansionConfig instance, TransportVersion version) {
6866
return instance;
6967
}
70-
71-
public void testBertTokenizationOnly() {
72-
ElasticsearchStatusException e = expectThrows(
73-
ElasticsearchStatusException.class,
74-
() -> new TextExpansionConfig(null, RobertaTokenizationTests.createRandom(), null)
75-
);
76-
assertEquals(RestStatus.BAD_REQUEST, e.status());
77-
assertEquals("text expansion models must be configured with BERT tokenizer, [roberta] given", e.getMessage());
78-
}
7968
}

0 commit comments

Comments
 (0)