Skip to content
BENIBIX Learn

Ollama Modelfile

AI💻 Running LocallyLocal Runtimes

Also known as Modelfile, Ollama Model File

A small text file. It builds your own model in Ollama from a base model.

Think of it like

It is like a recipe card. It names the base dish, then adds your own spices.

Example

Emma wants a model that always answers as a kind maths tutor. She puts that rule in a SYSTEM line. She builds it as tutor and then runs it.

Why it matters

You set it up once, and every chat starts with the same rules. Nobody has to paste them in.

Definition

A Modelfile is a small text file that tells Ollama how to build a model of your own. It starts with FROM and a base model, which is the one line it must have. PARAMETER lines set things like the temperature or the size of the context. A SYSTEM line gives the standing instructions. You build it with ollama create and a new name. The new model then runs like any other, with your settings baked in.

Example code

dockerfile
FROM llama3.2
PARAMETER temperature 0.3
SYSTEM You are a kind maths tutor. Explain one step at a time.

# then build it:
# ollama create tutor -f ./Modelfile
A base model, one setting and one rule. Then it is built as a new model named tutor.
The file tells the runtime layer what to run. It picks the weights and sets the rules.

Common mistake

Thinking it trains the model. It only wraps settings and instructions around the same weights.

Key takeaways

  1. 1
    FROM comes first. It names the base model.
  2. 2
    Settings and rules. PARAMETER and SYSTEM lines.
  3. 3
    Build, then run. Create it once, then use its name.