Package org.springframework.ai.ollama
Class OllamaEmbeddingModel
java.lang.Object
org.springframework.ai.embedding.AbstractEmbeddingModel
org.springframework.ai.ollama.OllamaEmbeddingModel
- All Implemented Interfaces:
EmbeddingModel,Model<EmbeddingRequest,EmbeddingResponse>
EmbeddingModel implementation for Ollama. Ollama allows developers
to run large language models and generate embeddings locally. It supports open-source
models available on [Ollama AI Library](...)
and on Hugging Face. Please refer to the official Ollama
website for the most up-to-date information on available models.- Since:
- 0.8.0
- Author:
- Christian Tzolov, Thomas Vitale, Ilayaperumal Gopinathan, Jonghoon Park
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classstatic class -
Field Summary
Fields inherited from class org.springframework.ai.embedding.AbstractEmbeddingModel
embeddingDimensions -
Constructor Summary
ConstructorsConstructorDescriptionOllamaEmbeddingModel(OllamaApi ollamaApi, OllamaOptions defaultOptions, io.micrometer.observation.ObservationRegistry observationRegistry, ModelManagementOptions modelManagementOptions) -
Method Summary
Modifier and TypeMethodDescriptionstatic OllamaEmbeddingModel.Builderbuilder()call(EmbeddingRequest request) Executes a method call to the AI model.float[]Embeds the given document's content into a vector.voidsetObservationConvention(EmbeddingModelObservationConvention observationConvention) Use the provided convention for reporting observation dataMethods inherited from class org.springframework.ai.embedding.AbstractEmbeddingModel
dimensions, dimensionsMethods 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, embed, embedForResponse
-
Constructor Details
-
OllamaEmbeddingModel
public OllamaEmbeddingModel(OllamaApi ollamaApi, OllamaOptions defaultOptions, io.micrometer.observation.ObservationRegistry observationRegistry, ModelManagementOptions modelManagementOptions)
-
-
Method Details
-
builder
-
embed
Description copied from interface:EmbeddingModelEmbeds the given document's content into a vector.- Parameters:
document- the document to embed.- Returns:
- the embedded vector.
-
call
Description copied from interface:ModelExecutes a method call to the AI model.- Parameters:
request- the request object to be sent to the AI model- Returns:
- the response from the AI model
-
setObservationConvention
Use the provided convention for reporting observation data- Parameters:
observationConvention- The provided convention
-