Interface EmbeddingModel

All Superinterfaces:
Model<EmbeddingRequest,EmbeddingResponse>
All Known Implementing Classes:
AbstractEmbeddingModel

public interface EmbeddingModel extends Model<EmbeddingRequest,EmbeddingResponse>
EmbeddingModel is a generic interface for embedding models.
Since:
1.0.0
Author:
Mark Pollack, Christian Tzolov, Josh Long, Soby Chacko, Jihoon Kim
  • Method Summary

    Modifier and Type
    Method
    Description
    Executes a method call to the AI model.
    default int
    Get the number of dimensions of the embedded vectors.
    default float[]
    embed(String text)
    Embeds the given text into a vector.
    default List<float[]>
    embed(List<String> texts)
    Embeds a batch of texts into vectors.
    default List<float[]>
    embed(List<org.springframework.ai.document.Document> documents, EmbeddingOptions options, org.springframework.ai.embedding.BatchingStrategy batchingStrategy)
    Embeds a batch of Documents into vectors based on a BatchingStrategy.
    float[]
    embed(org.springframework.ai.document.Document document)
    Embeds the given document's content into a vector.
    Embeds a batch of texts into vectors and returns the EmbeddingResponse.
  • Method Details

    • call

      Description copied from interface: Model
      Executes a method call to the AI model.
      Specified by:
      call in interface Model<EmbeddingRequest,EmbeddingResponse>
      Parameters:
      request - the request object to be sent to the AI model
      Returns:
      the response from the AI model
    • embed

      default float[] embed(String text)
      Embeds the given text into a vector.
      Parameters:
      text - the text to embed.
      Returns:
      the embedded vector.
    • embed

      float[] embed(org.springframework.ai.document.Document document)
      Embeds the given document's content into a vector.
      Parameters:
      document - the document to embed.
      Returns:
      the embedded vector.
    • embed

      default List<float[]> embed(List<String> texts)
      Embeds a batch of texts into vectors.
      Parameters:
      texts - list of texts to embed.
      Returns:
      list of embedded vectors.
    • embed

      default List<float[]> embed(List<org.springframework.ai.document.Document> documents, EmbeddingOptions options, org.springframework.ai.embedding.BatchingStrategy batchingStrategy)
      Embeds a batch of Documents into vectors based on a BatchingStrategy.
      Parameters:
      documents - list of Documents.
      options - EmbeddingOptions.
      batchingStrategy - BatchingStrategy.
      Returns:
      a list of float[] that represents the vectors for the incoming Documents. The returned list is expected to be in the same order of the Document list.
    • embedForResponse

      default EmbeddingResponse embedForResponse(List<String> texts)
      Embeds a batch of texts into vectors and returns the EmbeddingResponse.
      Parameters:
      texts - list of texts to embed.
      Returns:
      the embedding response.
    • dimensions

      default int dimensions()
      Get the number of dimensions of the embedded vectors. Note that by default, this method will call the remote Embedding endpoint to get the dimensions of the embedded vectors. If the dimensions are known ahead of time, it is recommended to override this method.
      Returns:
      the number of dimensions of the embedded vectors.