Interface EmbeddingModel

All Superinterfaces:
Model<EmbeddingRequest,EmbeddingResponse>
All Known Implementing Classes:
AbstractEmbeddingModel, AzureOpenAiEmbeddingModel, BedrockCohereEmbeddingModel, BedrockTitanEmbeddingModel, MiniMaxEmbeddingModel, MistralAiEmbeddingModel, OCIEmbeddingModel, OllamaEmbeddingModel, OpenAiEmbeddingModel, PostgresMlEmbeddingModel, QianFanEmbeddingModel, TransformersEmbeddingModel, VertexAiPaLm2EmbeddingModel, VertexAiTextEmbeddingModel, WatsonxAiEmbeddingModel, ZhiPuAiEmbeddingModel

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
  • 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(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 list of embedded vectors.
    • embed

      default List<float[]> embed(List<Document> documents, EmbeddingOptions options, 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.
    • 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()
      Returns:
      the number of dimensions of the embedded vectors. It is generative specific.