Ollama Embeddings
Generate embeddings using locally-hosted Ollama models
Overview
Ollama allows you to run embedding models locally on your machine with no API costs.
Quick Start
from praisonaiagents import embedding
result = embedding(
input="Hello world",
model="ollama/nomic-embed-text"
)
print(f"Dimensions: {len(result.embeddings[0])}")CLI Usage
praisonai embed "Hello world" --model ollama/nomic-embed-textSetup
- Install Ollama: https://ollama.ai
- Pull an embedding model:
ollama pull nomic-embed-textAvailable Models
| Model | Dimensions | Size |
|---|---|---|
ollama/nomic-embed-text | 768 | 274MB |
ollama/mxbai-embed-large | 1024 | 669MB |
ollama/all-minilm | 384 | 45MB |
ollama/snowflake-arctic-embed | not auto-detected | 669MB |
Custom API Base
from praisonaiagents import embedding
result = embedding(
input="Hello world",
model="ollama/nomic-embed-text",
api_base="http://localhost:11434"
)Batch Embeddings
from praisonaiagents import embedding
texts = ["Document 1", "Document 2", "Document 3"]
result = embedding(
input=texts,
model="ollama/nomic-embed-text"
)
print(f"Generated {len(result.embeddings)} embeddings")Using Ollama embeddings for memory / knowledge
Point agent memory or knowledge at a local Ollama embedder with the same embedder block used across PraisonAI:
from praisonaiagents import Agent
agent = Agent(
name="assistant",
memory={
"provider": "mongodb",
"config": {
"connection_string": "mongodb://localhost:27017/",
"database": "praisonai",
"use_vector_search": True,
"embedder": {
"provider": "ollama",
"config": {"model": "nomic-embed-text"},
},
},
},
)See MongoDB Memory and MongoDB Knowledge for the full setup, or Local Memory & Knowledge to wire both fully local end to end.