Ollama Modelfile Guide: Make a Custom Model with Your Own System Prompt and Settings
Note: Some future links on this site may be affiliate links. We never claim hands-on testing; guides are researched from the public sources listed in each article.
How we wrote this: A summary of Ollama's official Modelfile reference (linked below), checked October 29, 2026. Parameter defaults can change between Ollama versions, so check the reference for the version you run.
If you keep pasting the same instructions into every chat ("answer in plain English," "always reply as a bulleted list," "you are a support assistant for a plumbing company"), you can save them once. In Ollama, that is what a Modelfile is for.
What a Modelfile is
Ollama's Modelfile reference calls it "the blueprint to create and share customized models." It is a plain text file. Each line is an instruction followed by its arguments, and lines starting with # are comments. The reference notes that instructions aren't case sensitive and can appear in any order, although putting FROM first is easier to read.
A custom model built this way doesn't involve any training. You are packaging a base model together with your own settings and instructions.
The instructions you'll actually use
| Instruction | What it does |
|---|---|
FROM (required) |
The base model: a library model such as llama3.2, a folder of Safetensors weights, or a GGUF file. |
PARAMETER |
A runtime setting such as temperature, num_ctx or stop. |
SYSTEM |
The system message, which is the standing instructions the model sees in every chat. |
MESSAGE |
Example conversation turns (user and assistant) that show the model the style you want. |
TEMPLATE |
The full prompt template. Model specific; most people never change it. |
LICENSE |
The license text for the model you're sharing. |
The reference also lists REQUIRES (the minimum Ollama version a model needs) and CAPABILITY (to declare an extra capability for GGUF or MLX models).
A first Modelfile
Here is a small example in the same shape as the one in Ollama's reference. Save it as a file called Modelfile:
FROM llama3.2
PARAMETER temperature 0.3
PARAMETER num_ctx 8192
SYSTEM """You are a concise assistant for a small office. Answer in plain English, in five sentences or fewer, and say when you are not sure."""
Then build and run it, using the steps from the reference:
ollama create office-helper -f ./Modelfile
ollama run office-helper
After that, ollama run office-helper starts a chat with your instructions already in place.
Parameters worth knowing
From the reference's table of valid parameters:
- temperature: higher is more creative, lower is more focused. The reference lists 0.8 as the default.
- num_ctx: the size of the context window. A bigger window uses more memory; our guide to Ollama context length explains the trade-off and the defaults.
- num_predict: the maximum number of tokens to generate (the default, -1, means no limit).
- stop: text that makes the model stop generating. You can set several stop sequences, one per line.
- seed: a fixed number makes the same prompt produce the same text, which is useful for testing a prompt.
- top_k, top_p, min_p and repeat_penalty: finer controls over word choice and repetition. Leave them alone until you have a specific problem.
Show the model examples with MESSAGE
MESSAGE lines give the model a short example conversation before the real one starts. The reference's example teaches a yes/no style:
MESSAGE user Is Toronto in Canada?
MESSAGE assistant yes
MESSAGE user Is Sacramento in Canada?
MESSAGE assistant no
The valid roles are system, user and assistant.
Start from an existing model's Modelfile
To see how a model you already have is set up, run:
ollama show --modelfile llama3.2
The output includes the model's TEMPLATE and stop parameters. The reference suggests copying it and replacing the FROM line as a starting point for your own version.
Import a GGUF file you downloaded
If you downloaded a .gguf file (for example from Hugging Face), the Modelfile can point straight at it:
FROM ./my-model.gguf
The path can be absolute or relative to the Modelfile. For a model split across several files, the reference says to keep the original shard names and use a wildcard such as FROM ./model-*.gguf. Our guides on reading GGUF file names and downloading models from Hugging Face cover picking the right file.
Tips
- Keep each Modelfile in a folder with a short README, so you remember what each custom model is for.
- Change one setting at a time and re-run the same test prompt (with a fixed
seed) to see what it does. - Check the base model's license before you share a custom model. See open-weight model licenses explained.