~/tools / Model files and chat templates / Ollama Modelfile Generator
Ollama Modelfile Generator — Build an Ollama Modelfile: FROM, SYSTEM, PARAMETER, MESSAGE and more
Build an Ollama Modelfile from a form: the base model, a system message, parameters such as temperature and num_ctx, stop sequences, example messages, a template, the minimum Ollama version, extra capabilities and a license. Values are checked against the official Modelfile reference and quoted so that Ollama reads them back unchanged. Nothing leaves your browser.
Template, minimum version, capabilities and license
Modelfile
FROM llama3.2 PARAMETER num_ctx 4096 PARAMETER temperature 1 SYSTEM """Answer in one short sentence.""" MESSAGE user Is Toronto in Canada? MESSAGE assistant yes
Commands
Save the text above as a file named Modelfile in the current directory, then run:
ollama create short-answers -f ./Modelfile ollama run short-answers
Instructions, parameters and defaults as given in the Modelfile reference on 2026-11-09. Ollama Modelfile reference
Everything is done in your browser. Nothing you enter is sent anywhere.
A Modelfile is the blueprint Ollama uses to create a model with ollama create. It names the base model with FROM and can add a system message, parameters, an example conversation, a prompt template, the minimum Ollama version, extra capabilities and a license. The format is simple, but a few details cause errors: PARAMETER only accepts the names in the reference and each one expects an integer or a decimal number, stop sequences are set one per line, and text that spans several lines has to be wrapped in triple quotes. This tool writes the file for you. It lists only the instructions and parameters in the official Modelfile reference, shows the default value of each parameter next to its field, tells you when a value would be rejected, and quotes each value the way Ollama's own parser reads it. We tested the output with Ollama 0.40.11: we created models from generated files and read them back with ollama show --modelfile. REQUIRES and CAPABILITY were checked the same way. It also gives you the ollama create and ollama run commands for the model name you choose.
The core logic of this tool is open source under the MIT License. github.com/seigo5555/toolkitbox-lib/src/modelfile.ts
Use Cases
- Make a copy of a library model with your own system message and temperature, to run it under a new name
- Set a larger context window (num_ctx) or a fixed seed for a model you serve from a VPS
- Add a short example conversation that shows the model how to answer
Usage
- Enter the base model in FROM: a model from the Ollama library (for example llama3.2), the path of a GGUF file, or a directory with Safetensors weights. Enter the name you want for the new model.
- Write a system message and fill in only the parameters you want to change. Empty fields are left out, so the base model's values stay in effect. Add stop sequences one per line and example messages if you need them.
- Copy the Modelfile into a file named Modelfile, then run the two commands shown under it: ollama create builds the model, and ollama run starts it.
The Modelfile format
A Modelfile is a text file with one instruction and its arguments per line. Lines that start with # are comments. According to the official reference, instructions are not case sensitive and can be in any order. Only FROM is required.
A value normally runs to the end of its line. A value that spans several lines is wrapped in three double quotes ("""). Ollama's parser (parser/parser.go) has no escape mechanism, so if """ appears at the end of a line inside your text, the value ends there. The tool shows an error in that case.
Instructions
| Instruction | What it does | This tool |
|---|---|---|
| FROM | The base model: a model name from the library, a GGUF file, or a directory with Safetensors weights | Supported |
| PARAMETER | Parameters for running the model | Supported (the 11 in the reference table) |
| TEMPLATE | The prompt template passed to the model, in Go template syntax | Supported |
| SYSTEM | The system message set in the template | Supported |
| LICENSE | The model's license | Supported |
| MESSAGE | An example conversation, with the roles system, user and assistant | Supported |
| REQUIRES | The minimum Ollama version required | Supported |
| CAPABILITY | Adds a capability to a GGUF or MLX model | Supported |
For CAPABILITY, the reference says to declare decision only for weights trained for its prompts. In our test with Ollama 0.40.11, the other values were added to the model's existing capabilities, but with decision only the declared values were listed.
The official docs disagree on the default num_ctx
The grey defaults next to the fields come from the table in the Modelfile reference. It gives 2048 for num_ctx (the context length), but other pages of the same official documentation give different values.
| Page | Default context length |
|---|---|
| Modelfile reference | 2048 |
| FAQ | 4096 tokens |
| Context length | Depends on VRAM: 4k below 24 GiB, 32k for 24–48 GiB, 256k for 48 GiB or more |
To see the value actually in use, run ollama ps while the model is loaded and look at the CONTEXT column. To fix the value, write PARAMETER num_ctx.
What we checked with Ollama 0.40.11
On 30 October 2026 we ran ollama create on files generated by this tool and read them back with ollama show --modelfile.
- A decimal such as 1.5 in an integer parameter (num_ctx and others) makes ollama create fail with invalid int value.
- Text in a decimal parameter (temperature and others) fails with invalid float value.
- Forms such as top_p 1e-1 and top_p .5 are accepted, and so is seed -1.
- A SYSTEM value wrapped in """ keeps its double quotes, a double quote at the end of a line, and its indentation.
- A stop sequence wrapped in double quotes keeps its leading and trailing spaces.
- If you leave out SYSTEM, the new model keeps the base model's system message.
Checking the model you created
- Create the model with ollama create <name> -f ./Modelfile.
- Run ollama show --modelfile <name> to see the Modelfile as Ollama read it. It also shows whether settings you left out took values from the base model.
- Start it with ollama run <name>.
Sources (checked 2026-11-09): Ollama: Modelfile Reference / Ollama: FAQ / Ollama: Context length / ollama/ollama: parser/parser.go
FAQ
Which parameters can I set?
The ones listed in the official Modelfile reference: num_ctx, repeat_last_n, repeat_penalty, temperature, seed, stop, num_predict, draft_num_predict, top_k, top_p and min_p. The reference marks each as an integer, a decimal number or a string. When we tested Ollama 0.40.11, a decimal in an integer parameter failed with invalid int value, and text in a decimal parameter failed with invalid float value. The tool shows the same problem before you run ollama create.
Why are some values wrapped in triple quotes?
In a Modelfile, a value ends at the end of its line unless it is quoted. Ollama's parser reads a value that starts with three double quotes until it reaches three double quotes at the end of a line, so text with several lines must be wrapped that way. The tool always wraps the system message, the template and the license, and wraps an example message when it has several lines, starts with a double quote, or starts or ends with a space. Stop sequences are wrapped in double quotes, so spaces at the start or end are kept.
Can my text contain three double quotes in a row?
No. The format has no escape character, so three double quotes at the end of a line close the value early, and the next line is then read as an instruction, which makes ollama create fail. The tool reports this as an error. Rewrite that part of the text.
What happens to settings I leave empty?
They are not written, and the new model keeps what it inherits from the base model. For example, a model created from qwen2.5:7b without SYSTEM keeps the system message of qwen2.5:7b. Run ollama show --modelfile with the base model's name to see what it already sets.
Does the tool check that the base model exists?
No. It does not contact Ollama or the library. If the name or the path in FROM is wrong, ollama create reports it. A GGUF path is read relative to the location of the Modelfile unless you give an absolute path.
Is anything sent to a server?
No. The Modelfile is put together in your browser.