Skip to content

Commit

Permalink
fix typo error
Browse files Browse the repository at this point in the history
Signed-off-by: xinyual <[email protected]>
  • Loading branch information
xinyual committed Sep 26, 2023
1 parent a837080 commit dca433a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,6 @@
import static org.opensearch.ml.common.CommonValue.ML_MAP_RESPONSE_KEY;

public class SparseEncodingTranslator extends SentenceTransformerTranslator {
private Map<String, Float> convertOutput(NDArray array)
{
Map<String, Float> 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");
Expand All @@ -64,4 +51,17 @@ public Output processOutput(TranslatorContext ctx, NDList list) {
output.add(modelTensorOutput.toBytes());
return output;
}
private Map<String, Float> convertOutput(NDArray array)
{
Map<String, Float> 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;
}
}

0 comments on commit dca433a

Please sign in to comment.