This version is still in development and is not considered stable yet. For the latest snapshot version, please use Spring AI 1.0.0-SNAPSHOT!spring-doc.cn

Refer to the Dependency Management section to add the Spring AI BOM to your build file. Refer to the Repositories section to add these repositories to your build system.
Property Description Default

spring.ai.embedding.transformer.enabledspring-doc.cn

Enable the Transformer Embedding model.spring-doc.cn

truespring-doc.cn

spring.ai.embedding.transformer.tokenizer.urispring-doc.cn

URI of a pre-trained HuggingFaceTokenizer created by the ONNX engine (e.g. tokenizer.json).spring-doc.cn

onnx/all-MiniLM-L6-v2/tokenizer.jsonspring-doc.cn

spring.ai.embedding.transformer.tokenizer.optionsspring-doc.cn

HuggingFaceTokenizer options such as ‘addSpecialTokens’, ‘modelMaxLength’, ‘truncation’, ‘padding’, ‘maxLength’, ‘stride’, ‘padToMultipleOf’. Leave empty to fallback to the defaults.spring-doc.cn

emptyspring-doc.cn

spring.ai.embedding.transformer.cache.enabledspring-doc.cn

Enable remote Resource caching.spring-doc.cn

truespring-doc.cn

spring.ai.embedding.transformer.cache.directoryspring-doc.cn

Directory path to cache remote resources, such as the ONNX modelsspring-doc.cn

${java.io.tmpdir}/spring-ai-onnx-modelspring-doc.cn

spring.ai.embedding.transformer.onnx.modelUrispring-doc.cn

Existing, pre-trained ONNX model.spring-doc.cn

onnx/all-MiniLM-L6-v2/model.onnxspring-doc.cn

spring.ai.embedding.transformer.onnx.modelOutputNamespring-doc.cn

The ONNX model’s output node name, which we’ll use for embedding calculation.spring-doc.cn

last_hidden_statespring-doc.cn

spring.ai.embedding.transformer.onnx.gpuDeviceIdspring-doc.cn

The GPU device ID to execute on. Only applicable if >= 0. Ignored otherwise.(Requires additional onnxruntime_gpu dependency)spring-doc.cn

-1spring-doc.cn

spring.ai.embedding.transformer.metadataModespring-doc.cn

Specifies what parts of the Documents content and metadata will be used for computing the embeddings.spring-doc.cn

NONEspring-doc.cn

If you see an error like Caused by: ai.onnxruntime.OrtException: Supplied array is ragged,.., you need to also enable the tokenizer padding in application.properties as follows:spring-doc.cn

spring.ai.embedding.transformer.tokenizer.options.padding=true

If you get an error like The generative output names don’t contain expected: last_hidden_state. Consider one of the available model outputs: token_embeddings, …​., you need to set the model output name to a correct value per your models. Consider the names listed in the error message. For example:spring-doc.cn

spring.ai.embedding.transformer.onnx.modelOutputName=token_embeddings

If you get an error like ai.onnxruntime.OrtException: Error code - ORT_FAIL - message: Deserialize tensor onnx::MatMul_10319 failed.GetFileLength for ./model.onnx_data failed:Invalid fd was supplied: -1, that means that you model is larger than 2GB and is serialized in two files: model.onnx and model.onnx_data.spring-doc.cn

The model.onnx_data is called External Data and is expected to be under the same directory of the model.onnx.spring-doc.cn

Currently the only workaround is to copy the large model.onnx_data in the folder you run your Boot applicaiton.spring-doc.cn

If you get an error like ai.onnxruntime.OrtException: Error code - ORT_EP_FAIL - message: Failed to find CUDA shared provider, that means that you are using the GPU parameters spring.ai.embedding.transformer.onnx.gpuDeviceId , but the onnxruntime_gpu dependency are missing.spring-doc.cn

<dependency>
    <groupId>com.microsoft.onnxruntime</groupId>
    <artifactId>onnxruntime_gpu</artifactId>
</dependency>

Please select the appropriate onnxruntime_gpu version based on the CUDA version(ONNX Java Runtime).spring-doc.cn

Refer to the Dependency Management section to add the Spring AI BOM to your build file.

Dimensionsspring-doc.cn

384spring-doc.cn

Avg. performancespring-doc.cn

58.80spring-doc.cn

Speedspring-doc.cn

14200 sentences/secspring-doc.cn

Sizespring-doc.cn

80MBspring-doc.cn

If you create an instance of TransformersEmbeddingModel manually, you must call the afterPropertiesSet() method after setting the properties and before using the client.