Class TransformersEmbeddingClient

java.lang.Object
org.springframework.ai.embedding.TransformersEmbeddingClient
All Implemented Interfaces:
EmbeddingClient, org.springframework.beans.factory.InitializingBean

public class TransformersEmbeddingClient extends Object implements EmbeddingClient, org.springframework.beans.factory.InitializingBean
https://www.sbert.net/index.html https://www.sbert.net/docs/pretrained_models.html
Author:
Christian Tzolov
  • Field Details

  • Constructor Details

    • TransformersEmbeddingClient

      public TransformersEmbeddingClient()
    • TransformersEmbeddingClient

      public TransformersEmbeddingClient(MetadataMode metadataMode)
  • Method Details

    • setTokenizerOptions

      public void setTokenizerOptions(Map<String,String> tokenizerOptions)
    • setDisableCaching

      public void setDisableCaching(boolean disableCaching)
    • setResourceCacheDirectory

      public void setResourceCacheDirectory(String resourceCacheDir)
    • 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

      public void setTokenizerResource(String tokenizerResourceUri)
    • setModelResource

      public void setModelResource(String modelResourceUri)
    • setEmbeddingDimensions

      public void setEmbeddingDimensions(int dimension)
    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • embed

      public List<Double> embed(String text)
      Specified by:
      embed in interface EmbeddingClient
    • embed

      public List<Double> embed(Document document)
      Specified by:
      embed in interface EmbeddingClient
    • embedForResponse

      public EmbeddingResponse embedForResponse(List<String> texts)
      Specified by:
      embedForResponse in interface EmbeddingClient
    • embed

      public List<List<Double>> embed(List<String> texts)
      Specified by:
      embed in interface EmbeddingClient
    • dimensions

      public int dimensions()
      Specified by:
      dimensions in interface EmbeddingClient