examples/ollama/README.md
This directory contains examples demonstrating different capabilities of Ollama with promptfoo.
You can run this example with:
npx promptfoo@latest init --example ollama
cd ollama
# For comparison example (default)
ollama pull llama4:scout
ollama pull llama2-uncensored
# For function calling example
ollama pull llama3.2:1b
This directory contains two different Ollama examples:
Config: promptfooconfig.yaml
Compares different Ollama models (llama4:scout, llama2-uncensored) with OpenAI models using various prompts and assertions.
Running:
npx promptfoo@latest eval
Or with a specific config:
npx promptfoo@latest eval -c promptfooconfig.yaml
What this tests:
Tutorial: See the accompanying guide at https://promptfoo.dev/docs/guides/censored-vs-uncensored-ollama/
Config: promptfooconfig.function-calling.yaml
Demonstrates Ollama's function calling capabilities using a tiny 1B parameter model.
Running:
npx promptfoo@latest eval -c promptfooconfig.function-calling.yaml
What this tests:
llama3.2:1b (tiny, fast model)is-valid-openai-tools-call assertionExpected output:
✔ Evaluation complete
Pass Rate: 100.00%
Successes: 3
Each test generates a tool call:
[
{
"function": {
"name": "get_current_weather",
"arguments": "{\"location\":\"Boston\",\"unit\":\"celsius\"}"
}
}
]
Supported models: Models with function calling support include llama3.2:1b, llama3.2:3b, llama3.1, llama3.3, and qwen2.5.
Edit the prompts and test cases in promptfooconfig.yaml. You can modify:
tests sectionprompts/ directoryEdit promptfooconfig.function-calling.yaml to:
get_current_weather.yamlexamples/ollama/
├── README.md # This file
├── promptfooconfig.yaml # Model comparison (default)
├── promptfooconfig.function-calling.yaml # Function calling example
├── prompts/
│ ├── llama_prompt.txt # Llama-style prompt format
│ └── openai_prompt.json # OpenAI chat format
├── prompts.txt # Additional prompt examples
└── get_current_weather.yaml # Tool definition for function calling
After running an evaluation, view the results in the web UI:
npx promptfoo@latest view
This opens an interactive comparison showing: