Skip to main content

Ollama Embeddings

Select a language

Chroma provides a convenient wrapper around Ollama' s embeddings API. You can use the OllamaEmbeddingFunction embedding function to generate embeddings for your documents with a model of your choice.

import chromadb.utils.embedding_functions as embedding_functions

ollama_ef = embedding_functions.OllamaEmbeddingFunction(
url="http://localhost:11434/api/embeddings",
model_name="llama2",
)

embeddings = ollama_ef(["This is my first text to embed",
"This is my second document"])

You can pass in an optional model_name argument, which lets you choose which OpenAI embeddings model to use. By default, Chroma uses text-embedding-ada-002. You can see a list of all available models here.