Package org.springframework.ai.embedding
Class AbstractEmbeddingModel
java.lang.Object
org.springframework.ai.embedding.AbstractEmbeddingModel
- All Implemented Interfaces:
EmbeddingModel
,Model<EmbeddingRequest,
EmbeddingResponse>
- Direct Known Subclasses:
AzureOpenAiEmbeddingModel
,BedrockCohereEmbeddingModel
,BedrockTitanEmbeddingModel
,MiniMaxEmbeddingModel
,MistralAiEmbeddingModel
,OCIEmbeddingModel
,OllamaEmbeddingModel
,OpenAiEmbeddingModel
,PostgresMlEmbeddingModel
,QianFanEmbeddingModel
,TransformersEmbeddingModel
,VertexAiPaLm2EmbeddingModel
,VertexAiTextEmbeddingModel
,WatsonxAiEmbeddingModel
,ZhiPuAiEmbeddingModel
Abstract implementation of the
EmbeddingModel
interface that provides
dimensions calculation caching.- Author:
- Christian Tzolov
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
static int
dimensions
(EmbeddingModel embeddingModel, String modelName, String dummyContent) Return the dimension of the requested embedding generative name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.ai.embedding.EmbeddingModel
call, embed, embed, embed, embed, embedForResponse
-
Field Details
-
embeddingDimensions
-
-
Constructor Details
-
AbstractEmbeddingModel
public AbstractEmbeddingModel()
-
-
Method Details
-
dimensions
Return the dimension of the requested embedding generative name. If the generative name is unknown uses the EmbeddingModel to perform a dummy EmbeddingModel#embed and count the response dimensions.- Parameters:
embeddingModel
- Fall-back client to determine, empirically the dimensions.modelName
- Embedding generative name to retrieve the dimensions for.dummyContent
- Dummy content to use for the empirical dimension calculation.- Returns:
- Returns the embedding dimensions for the modelName.
-
dimensions
public int dimensions()- Specified by:
dimensions
in interfaceEmbeddingModel
- Returns:
- the number of dimensions of the embedded vectors. It is generative specific.
-