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
,QianFanEmbeddingModel
,TransformersEmbeddingModel
,VertexAiPaLm2EmbeddingModel
,VertexAiTextEmbeddingModel
,WatsonxAiEmbeddingModel
,ZhiPuAiEmbeddingModel
EmbeddingModel is a generic interface for embedding models.
- Since:
- 1.0.0
- Author:
- Mark Pollack, Christian Tzolov, Josh Long, Soby Chacko
-
Method Summary
Modifier and TypeMethodDescriptioncall
(EmbeddingRequest request) Executes a method call to the AI model.default int
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 ofDocument
s into vectors based on aBatchingStrategy
.float[]
Embeds the given document's content into a vector.default EmbeddingResponse
embedForResponse
(List<String> texts) Embeds a batch of texts into vectors and returns theEmbeddingResponse
.
-
Method Details
-
call
Description copied from interface:Model
Executes a method call to the AI model.- Specified by:
call
in interfaceModel<EmbeddingRequest,
EmbeddingResponse> - Parameters:
request
- the request object to be sent to the AI model- Returns:
- the response from the AI model
-
embed
Embeds the given text into a vector.- Parameters:
text
- the text to embed.- Returns:
- the embedded vector.
-
embed
Embeds the given document's content into a vector.- Parameters:
document
- the document to embed.- Returns:
- the embedded vector.
-
embed
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 ofDocument
s into vectors based on aBatchingStrategy
.- Parameters:
documents
- list ofDocument
s.options
-EmbeddingOptions
.batchingStrategy
-BatchingStrategy
.- Returns:
- a list of float[] that represents the vectors for the incoming
Document
s.
-
embedForResponse
Embeds a batch of texts into vectors and returns theEmbeddingResponse
.- 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.
-