Class TransformersEmbeddingClient
java.lang.Object
org.springframework.ai.embedding.AbstractEmbeddingClient
org.springframework.ai.transformers.TransformersEmbeddingClient
- All Implemented Interfaces:
EmbeddingClient,ModelClient<EmbeddingRequest,,EmbeddingResponse> org.springframework.beans.factory.InitializingBean
public class TransformersEmbeddingClient
extends AbstractEmbeddingClient
implements org.springframework.beans.factory.InitializingBean
https://www.sbert.net/index.html https://www.sbert.net/docs/pretrained_models.html
- Author:
- Christian Tzolov
-
Field Summary
FieldsFields inherited from class org.springframework.ai.embedding.AbstractEmbeddingClient
embeddingDimensions -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcall(EmbeddingRequest request) Executes a method call to the AI model.Embeds the given text into a vector.Embeds a batch of texts into vectors.Embeds the given document's content into a vector.embedForResponse(List<String> texts) Embeds a batch of texts into vectors and returns theEmbeddingResponse.voidsetDisableCaching(boolean disableCaching) voidsetGpuDeviceId(int gpuDeviceId) voidsetModelOutputName(String modelOutputName) voidsetModelResource(String modelResourceUri) voidsetModelResource(org.springframework.core.io.Resource modelResource) voidsetResourceCacheDirectory(String resourceCacheDir) voidsetTokenizerOptions(Map<String, String> tokenizerOptions) voidsetTokenizerResource(String tokenizerResourceUri) voidsetTokenizerResource(org.springframework.core.io.Resource tokenizerResource) Methods inherited from class org.springframework.ai.embedding.AbstractEmbeddingClient
dimensions, dimensions
-
Field Details
-
DEFAULT_ONNX_TOKENIZER_URI
- See Also:
-
DEFAULT_ONNX_MODEL_URI
- See Also:
-
DEFAULT_MODEL_OUTPUT_NAME
- See Also:
-
tokenizerOptions
-
-
Constructor Details
-
TransformersEmbeddingClient
public TransformersEmbeddingClient() -
TransformersEmbeddingClient
-
-
Method Details
-
setTokenizerOptions
-
setDisableCaching
public void setDisableCaching(boolean disableCaching) -
setResourceCacheDirectory
-
setGpuDeviceId
public void setGpuDeviceId(int gpuDeviceId) -
setTokenizerResource
public void setTokenizerResource(org.springframework.core.io.Resource tokenizerResource) -
setModelResource
public void setModelResource(org.springframework.core.io.Resource modelResource) -
setTokenizerResource
-
setModelResource
-
setModelOutputName
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
embed
Description copied from interface:EmbeddingClientEmbeds the given text into a vector.- Specified by:
embedin interfaceEmbeddingClient- Parameters:
text- the text to embed.- Returns:
- the embedded vector.
-
embed
Description copied from interface:EmbeddingClientEmbeds the given document's content into a vector.- Specified by:
embedin interfaceEmbeddingClient- Parameters:
document- the document to embed.- Returns:
- the embedded vector.
-
embedForResponse
Description copied from interface:EmbeddingClientEmbeds a batch of texts into vectors and returns theEmbeddingResponse.- Specified by:
embedForResponsein interfaceEmbeddingClient- Parameters:
texts- list of texts to embed.- Returns:
- the embedding response.
-
embed
Description copied from interface:EmbeddingClientEmbeds a batch of texts into vectors.- Specified by:
embedin interfaceEmbeddingClient- Parameters:
texts- list of texts to embed.- Returns:
- list of list of embedded vectors.
-
call
Description copied from interface:ModelClientExecutes a method call to the AI model.- Specified by:
callin interfaceEmbeddingClient- Specified by:
callin interfaceModelClient<EmbeddingRequest,EmbeddingResponse> - Parameters:
request- the request object to be sent to the AI model- Returns:
- the response from the AI model
-