djl
djl copied to clipboard
use the gte model generate embedding
Issue Description: i use the gte model generate embedding ,but get a error like the following
the gte model download from https://www.modelscope.cn/iic/nlp_gte_sentence-embedding_chinese-large.git
my code:
` {
public static void main(String[] args) {
String text = "This is an example sentence";
Criteria<String, float[]> criteria =
Criteria.builder()
.setTypes(String.class, float[].class)
.optModelPath(Paths.get("nlp_gte_sentence-embedding_chinese-large"))
.optEngine("PyTorch")
.optOption("mapLocation", "true")
.optTranslatorFactory(new TextEmbeddingTranslatorFactory())
.optProgress(new ProgressBar())
.optModelName("pytorch_model.bin")
.build();
try (ZooModel<String, float[]> model = criteria.loadModel();
Predictor<String, float[]> predictor = model.newPredictor()) {
float[] res = predictor.predict(text);
System.out.println("Embedding: " + Arrays.toString(res));
} catch (Exception e) {
e.printStackTrace();
}
}
`
my pom.xml:
the djl pytorch env config:
and i use the python run the gte model,run successs,the following is the python code