diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/SentenceTransformerTranslator.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/SentenceTransformerTranslator.java index 30b0bacc11..d62a2cd992 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/SentenceTransformerTranslator.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/SentenceTransformerTranslator.java @@ -25,7 +25,12 @@ public Batchifier getBatchifier() { @Override public void prepare(TranslatorContext ctx) throws IOException { Path path = ctx.getModel().getModelPath(); - tokenizer = HuggingFaceTokenizer.builder().optPadding(true).optTokenizerPath(path.resolve("tokenizer.json")).build(); + tokenizer = HuggingFaceTokenizer + .builder() + .optPadding(true) + .optTruncation(true) + .optTokenizerPath(path.resolve("tokenizer.json")) + .build(); } @Override