vectorisers.ollama.OllamaVectoriser

vectorisers.ollama.OllamaVectoriser(model_name)

A wrapper class allowing a locally-running ollama server to generate text embeddings.

The OllamaVectoriser interacts with a locally-running Ollama server, which must be set up by the user separately. In general, Ollama can run the same encoder-based models as the HuggingFaceVectoriser. A future goal is to extend the OllamaVectoriser to interface with an external Ollama server, allowing separation of embedding generation from the user’s local environment.

Attributes

Name Type Description
model_name str The name of the local model to use.

Methods

Name Description
transform Transforms input text(s) into embeddings using the Huggingface model.

transform

vectorisers.ollama.OllamaVectoriser.transform(texts)

Transforms input text(s) into embeddings using the Huggingface model.

Parameters

Name Type Description Default
texts (str, list[str]) The input text(s) to embed. Can be a single string or a list of strings. required

Returns

Name Type Description
np.ndarray numpy.ndarray: A 2D array of embeddings, where each row corresponds to an input text.

Raises

Name Type Description
ExternalServiceError If the Ollama service fails to generate embeddings.
VectorisationError If embedding extraction from the Ollama response fails.