Class FixedDimensionEmbeddingModel
java.lang.Object
org.springframework.ai.test.vectorstore.FixedDimensionEmbeddingModel
- All Implemented Interfaces:
EmbeddingModel,Model<EmbeddingRequest,EmbeddingResponse>
A minimal deterministic
EmbeddingModel that returns a constant vector of a
configured dimension, for tests that must not depend on a hosted embedding provider.
It is the query-side model for the AbstractVectorStoreUpsertTests suite:
upsert supplies its own vectors, and the suite reads back with
similarityThresholdAll() regardless of ranking, so a constant vector is
sufficient and no API key is needed. Wire it into a store's upsert integration test and
size the store's index to dimensions().
- Since:
- 2.1.0
- Author:
- Soby Chacko
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncall(EmbeddingRequest request) Executes a method call to the AI model.intGet the number of dimensions of the embedded vectors.float[]Embeds the given text into a vector.float[]Embeds the given document's content into a vector.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.ai.embedding.EmbeddingModel
embed, embed, embedForResponse, getEmbeddingContent
-
Constructor Details
-
FixedDimensionEmbeddingModel
public FixedDimensionEmbeddingModel(int dimensions)
-
-
Method Details
-
embed
Description copied from interface:EmbeddingModelEmbeds the given document's content into a vector.- Specified by:
embedin interfaceEmbeddingModel- Parameters:
document- the document to embed.- Returns:
- the embedded vector.
-
embed
Description copied from interface:EmbeddingModelEmbeds the given text into a vector.- Specified by:
embedin interfaceEmbeddingModel- Parameters:
text- the text to embed.- Returns:
- the embedded vector.
-
call
Description copied from interface:ModelExecutes a method call to the AI model.- Specified by:
callin interfaceEmbeddingModel- Specified by:
callin interfaceModel<EmbeddingRequest,EmbeddingResponse> - Parameters:
request- the request object to be sent to the AI model- Returns:
- the response from the AI model
-
dimensions
public int dimensions()Description copied from interface:EmbeddingModelGet 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.- Specified by:
dimensionsin interfaceEmbeddingModel- Returns:
- the number of dimensions of the embedded vectors.
-