OllamaEmbeddingProvider

org.llm4s.llmconnect.provider.OllamaEmbeddingProvider

Embedding provider implementation for Ollama, a local model inference server.

Generates text embeddings by calling the Ollama /api/embeddings HTTP endpoint. Each input text is embedded individually (one HTTP request per text) because the Ollama embedding API accepts a single prompt per call. Results are collected and returned as an org.llm4s.llmconnect.model.EmbeddingResponse.

No API key is required when Ollama runs locally, though one can be supplied for remote or authenticated deployments.

Ollama's entry in the embedding half of the provider SPI.

It shares the ollama id with OllamaProvider's chat client - the two namespaces are separate - so EMBEDDING_MODEL=ollama/nomic-embed-text and a named chat section with provider = "ollama" name the same provider.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

Builds the provider for the SPI; see fromConfig for the direct route.

Builds the provider for the SPI; see fromConfig for the direct route.

Attributes

override def dimensionsOf(model: String): Option[Int]

The vector dimensions of model, when this provider knows them.

The vector dimensions of model, when this provider knows them.

Attributes

Definition Classes

Creates an EmbeddingProvider backed by Ollama using the given configuration.

Creates an EmbeddingProvider backed by Ollama using the given configuration.

Attributes

Inherited methods

def aliases: Set[String]

Alternative spellings accepted in EMBEDDING_MODEL=<name>/<model>, folded onto id.

Alternative spellings accepted in EMBEDDING_MODEL=<name>/<model>, folded onto id.

Attributes

Inherited from:
EmbeddingProviderDescriptor
def buildConfig(section: EmbeddingProviderSection, modelOverride: Option[String]): Result[EmbeddingProviderConfig]

Turns this provider's config section into the EmbeddingProviderConfig its client needs.

Turns this provider's config section into the EmbeddingProviderConfig its client needs.

The default implementation resolves model, base URL and API key against configSpec, which is all any of the project's own providers needs. Override it only for a provider whose config genuinely cannot be expressed that way.

Value parameters

modelOverride

the <model> half of EMBEDDING_MODEL=<id>/<model>, when the unified form was used. Takes precedence over the section.

section

the llm4s.embeddings.<id> section, already parsed, its apiKey already falling back to the shared llm4s.credentials.<id>.apiKey when it sets none. Empty rather than absent when the user configured nothing. Everything this method needs arrives typed, in here: a descriptor never reads configuration itself.

Attributes

Inherited from:
EmbeddingProviderDescriptor

Concrete fields

What this provider needs from llm4s.embeddings.<id>, and its defaults.

What this provider needs from llm4s.embeddings.<id>, and its defaults.

Attributes

val id: ProviderId

Canonical id, e.g. ProviderId("voyage"). Must be unique among the embedding providers in a registry.

Canonical id, e.g. ProviderId("voyage"). Must be unique among the embedding providers in a registry.

Chat and embedding ids live in separate namespaces, so a provider that supplies both — OpenAI, Ollama — uses the same id for each without a clash. That is what lets EMBEDDING_MODEL=ollama/nomic-embed-text and a named chat section with provider = "ollama" name the same provider.

Attributes

override val modelDimensions: Map[String, Int]

The embedding models in Ollama's library that are commonly pulled, under their untagged names. Ollama model names carry an optional :tag, and different tags of one model can differ in size - snowflake-arctic-embed:22m is 384-dimensional, :335m is 1024 - so only :latest, which is what the untagged name means, is folded onto these.

The embedding models in Ollama's library that are commonly pulled, under their untagged names. Ollama model names carry an optional :tag, and different tags of one model can differ in size - snowflake-arctic-embed:22m is 384-dimensional, :335m is 1024 - so only :latest, which is what the untagged name means, is folded onto these.

Attributes