Ollama Embedder

Generate embeddings with OllamaEmbedder and an explicit local embedding model.

OllamaEmbedder connects to an Ollama server. Set id and dimensions to match the model served by Ollama.

from agno.knowledge.embedder.ollama import OllamaEmbedder

embedder = OllamaEmbedder(
    id="mxbai-embed-large",
    dimensions=1024,
)

embedding = embedder.get_embedding("The quick brown fox jumps over the lazy dog.")

print(embedding[:5])
print(len(embedding))

Run the Example

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Install Ollama

Install Ollama, then pull the model:

ollama pull mxbai-embed-large

Install dependencies

uv pip install -U agno ollama

Run the example

python ollama_embedder.py

Developer Resources