So given the following code:
private Criteria<String, float[]> makeCriteria() {
return Criteria.builder()
.setTypes(String.class, float[].class)
.optModelUrls(MODEL_URL)
.optEngine("PyTorch")
.optTranslatorFactory(new TextEmbeddingTranslatorFactory())
.build();
}
Works great for dowloading a model and returning sentence embeddings fast. However, given that it needs the model URL:
String MODEL_URL = "djl://ai.djl.huggingface.pytorch/sentence-transformers/all-MiniLM-L12-v2";
It loads this from the website directly, so I’m trying to refactor it to load from the disk instead.
To do this I see I should only need to do the following:
private Criteria<String, float[]> makeCriteria() {
return Criteria.builder()
.setTypes(String.class, float[].class)
.optModelPath(MODEL_PATH)
.optEngine("PyTorch")
.optTranslatorFactory(new TextEmbeddingTranslatorFactory())
.build();
}
But I can’t seem to find out how to take a model from my cache and point it to the model above.
I’ve tried pointing it directly to the cache directory:
.optModelPath(Path.of("/Users/krickert/.djl.ai/cache/repo/model/nlp/text_embedding/ai/djl/huggingface/pytorch/sentence-transformers/\n" +
"all-MiniLM-L12-v2/true/0.0.1/"))
and even tried "all-MiniLM-L12-v2/’
Can someone let me know what I can change to have it load from dsk only?