Package org.springframework.ai.embedding
Interface EmbeddingModel
- All Superinterfaces:
- Model<EmbeddingRequest,- EmbeddingResponse> 
- All Known Implementing Classes:
- AbstractEmbeddingModel,- AzureOpenAiEmbeddingModel,- BedrockCohereEmbeddingModel,- BedrockTitanEmbeddingModel,- MiniMaxEmbeddingModel,- MistralAiEmbeddingModel,- OCIEmbeddingModel,- OllamaEmbeddingModel,- OpenAiEmbeddingModel,- PostgresMlEmbeddingModel,- TransformersEmbeddingModel,- VertexAiTextEmbeddingModel,- ZhiPuAiEmbeddingModel
EmbeddingModel is a generic interface for embedding models.
- Since:
- 1.0.0
- Author:
- Mark Pollack, Christian Tzolov, Josh Long, Soby Chacko, Jihoon Kim
- 
Method SummaryModifier and TypeMethodDescriptioncall(EmbeddingRequest request) Executes a method call to the AI model.default intGet the number of dimensions of the embedded vectors.default float[]Embeds the given text into a vector.default List<float[]>Embeds a batch of texts into vectors.default List<float[]>embed(List<Document> documents, EmbeddingOptions options, BatchingStrategy batchingStrategy) Embeds a batch ofDocuments into vectors based on aBatchingStrategy.float[]Embeds the given document's content into a vector.default EmbeddingResponseembedForResponse(List<String> texts) Embeds a batch of texts into vectors and returns theEmbeddingResponse.
- 
Method Details- 
callDescription copied from interface:ModelExecutes a method call to the AI model.- Specified by:
- callin interface- Model<EmbeddingRequest,- EmbeddingResponse> 
- Parameters:
- request- the request object to be sent to the AI model
- Returns:
- the response from the AI model
 
- 
embedEmbeds the given text into a vector.- Parameters:
- text- the text to embed.
- Returns:
- the embedded vector.
 
- 
embedEmbeds the given document's content into a vector.- Parameters:
- document- the document to embed.
- Returns:
- the embedded vector.
 
- 
embedEmbeds a batch of texts into vectors.- Parameters:
- texts- list of texts to embed.
- Returns:
- list of embedded vectors.
 
- 
embeddefault List<float[]> embed(List<Document> documents, EmbeddingOptions options, BatchingStrategy batchingStrategy) Embeds a batch ofDocuments into vectors based on aBatchingStrategy.- 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 theDocumentlist.
 
- 
embedForResponseEmbeds a batch of texts into vectors and returns theEmbeddingResponse.- Parameters:
- texts- list of texts to embed.
- Returns:
- the embedding response.
 
- 
dimensionsdefault 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.
 
 
-