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 b6c9e01adc..b02a8c9092 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 @@ -23,7 +23,7 @@ import java.util.List; import java.util.Map; -abstract public class SentenceTransformerTranslator implements ServingTranslator { +public abstract class SentenceTransformerTranslator implements ServingTranslator { protected HuggingFaceTokenizer tokenizer; @Override diff --git a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/sparse_encoding/SparseEncodingTranslator.java b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/sparse_encoding/SparseEncodingTranslator.java index 68f5024d1b..e06232ca54 100644 --- a/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/sparse_encoding/SparseEncodingTranslator.java +++ b/ml-algorithms/src/main/java/org/opensearch/ml/engine/algorithms/sparse_encoding/SparseEncodingTranslator.java @@ -29,19 +29,6 @@ import static org.opensearch.ml.common.CommonValue.ML_MAP_RESPONSE_KEY; public class SparseEncodingTranslator extends SentenceTransformerTranslator { - private Map convertOutput(NDArray array) - { - Map map = new HashMap<>(); - NDArray nonZeroIndices = array.nonzero().squeeze(); - - for (long index : nonZeroIndices.toLongArray()) { - String s = this.tokenizer.decode(new long[]{index}, true); - if (!s.isEmpty()){ - map.put(s, array.getFloat(index)); - } - } - return map; - } @Override public Output processOutput(TranslatorContext ctx, NDList list) { Output output = new Output(200, "OK"); @@ -64,4 +51,17 @@ public Output processOutput(TranslatorContext ctx, NDList list) { output.add(modelTensorOutput.toBytes()); return output; } + private Map convertOutput(NDArray array) + { + Map map = new HashMap<>(); + NDArray nonZeroIndices = array.nonzero().squeeze(); + + for (long index : nonZeroIndices.toLongArray()) { + String s = this.tokenizer.decode(new long[]{index}, true); + if (!s.isEmpty()){ + map.put(s, array.getFloat(index)); + } + } + return map; + } }