Ollama
DeepEval allows you to use any model served by Ollama to run evals, either through the CLI or directly in Python. Some capabilities, such as multimodal support, are detected from a known-model list.
Environment Setup
DeepEval can use a local Ollama server (default: http://localhost:11434).
Optionally set a custom host:
# .env.local
LOCAL_MODEL_BASE_URL=http://localhost:11434Command Line
To configure your Ollama model through the CLI, run the following command. Replace deepseek-r1:1.5b with any Ollama-supported model of your choice.
deepeval set-ollama --model=deepseek-r1:1.5bYou may also specify the base URL of your local Ollama model instance if you've defined a custom port. By default, the base URL is set to http://localhost:11434.
deepeval set-ollama --model=deepseek-r1:1.5b \
--base-url="http://localhost:11434"Python
Alternatively, you can specify your model directly in code using OllamaModel from DeepEval's model collection.
from deepeval.models import OllamaModel
from deepeval.metrics import AnswerRelevancyMetric
model = OllamaModel(
model="deepseek-r1:1.5b",
base_url="http://localhost:11434",
temperature=0
)
answer_relevancy = AnswerRelevancyMetric(model=model)To use any Ollama model directly in deepeval, set the LOCAL_MODEL_API_KEY in your env and simply pass the name of your desired model in your metric initialization:
from deepeval.metrics import AnswerRelevancyMetric
answer_relevancy = AnswerRelevancyMetric(
model="deepseek-r1:1.5b",
)There is ONE mandatory parameter and THREE optional parameters when creating an OllamaModel:
- [Optional]
model: A string specifying the name of the Ollama model to use. Defaults toOLLAMA_MODEL_NAMEif not passed; raises an error at runtime if unset. - [Optional]
base_url: A string specifying the base URL of the Ollama server. Defaults toLOCAL_MODEL_BASE_URLif not passed; falls back tohttp://localhost:11434if unset. - [Optional]
temperature: A float specifying the model temperature. Defaults toTEMPERATUREif not passed; falls back to0.0if unset. - [Optional]
generation_kwargs: A dictionary of additional generation parameters forwarded to Ollama’schat(..., options={...})call.
Available Ollama Models
Below is a list of commonly used Ollama models:
deepseek-r1llama3.1gemmaqwenmistralcodellamaphi3tinyllamastarcoder2