Custom models package a base model with your settings and instructions, so every app gets the same behaviour.
A Modelfile is a small text file describing a model: which base model to use and which settings and instructions to add. It is like a recipe: the ingredients (weights) stay the same, but you fix the seasoning.
FROM qwen3:8b
PARAMETER temperature 0.2
PARAMETER num_ctx 16384
SYSTEM You are a support assistant for Acme. Answer in at most 3 sentences.Build and use it:
ollama create acme-support -f Modelfile
ollama run acme-supportThe new model shares the base model's weights on disk, so it takes almost no extra space.
Instructions (not case-sensitive, any order):
FROM(required): the base model, or a path to model files (see the importing lesson).PARAMETER name value: default settings such astemperature,num_ctx,top_p,top_k,repeat_penalty,seed,num_predictandstop. Repeatstopfor several stop sequences.SYSTEM: the system prompt. Use"""around multi-line text.MESSAGE role content: example conversation turns (user,assistant), a built-in few-shot example.TEMPLATE: the prompt format the model was trained with. Usually inherited from the base; rarely edit it.LICENSE: license text.REQUIRES: a minimum Ollama version.
Inspect any model's recipe with ollama show qwen3:8b --modelfile.
Settings sent in an API request override the Modelfile's defaults, so the Modelfile sets sensible defaults while apps can still adjust them. Keep Modelfiles in version control next to the code that uses them.
Example
# File: Modelfile
FROM qwen3:8b
PARAMETER temperature 0.2
PARAMETER num_ctx 16384
PARAMETER stop "<END>"
SYSTEM """You are Acme's support assistant.
Answer in at most 3 sentences. If unsure, say you will escalate."""
MESSAGE user Where is my order?
MESSAGE assistant I can check that. Please share your order number (it starts with A-).
# Terminal
ollama create acme-support -f Modelfile
ollama run acme-support "My parcel is late."
# I'm sorry about the delay. Please share your order number (it starts with A-) ...
ollama show acme-support --modelfile # view the full recipeRemember
FROM+PARAMETER+SYSTEM(+MESSAGE) define a custom modelollama create NAME -f Modelfilebuilds it; it reuses the base weights- API request options override Modelfile defaults
Watch out for
- Copying a TEMPLATE from another model family, which breaks the prompt format and produces garbled answers.