Skip to content

Commit

Permalink
Transformers embedding Readme clarifications
Browse files Browse the repository at this point in the history
  • Loading branch information
tzolov committed Nov 10, 2023
1 parent e423c3f commit 0a584f0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions embedding-clients/transformers-embedding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ TransformersEmbeddingClient embeddingClient = new TransformersEmbeddingClient();

// (optional) defaults to classpath:/onnx/all-MiniLM-L6-v2/tokenizer.json
embeddingClient.setTokenizerResource("classpath:/onnx/all-MiniLM-L6-v2/tokenizer.json");

// (optional) defaults to classpath:/onnx/all-MiniLM-L6-v2/model.onnx
embeddingClient.setModelResource("classpath:/onnx/all-MiniLM-L6-v2/model.onnx");

Expand All @@ -68,11 +69,14 @@ embeddingClient.setResourceCacheDirectory("/tmp/onnx-zoo");

embeddingClient.afterPropertiesSet();

List<List<Double>> embeddings =
embeddingClient.embed(List.of("Hello world", "World is big"));
List<List<Double>> embeddings = embeddingClient.embed(List.of("Hello world", "World is big"));

```

The first `embed()` call downloads the the large ONNX model and caches it on the local file system.
Therefore the first call might take longer than usual.
Use the `#setResourceCacheDirectory(<path>)` to set the local folder where the ONNX models as stored.
The default cache folder is `${java.io.tmpdir}/spring-ai-onnx-model`.



Expand Down

0 comments on commit 0a584f0

Please sign in to comment.