Ollama Modelfile Generator

Build a valid Ollama Modelfile without memorizing the syntax. Choose a base model, write a system prompt, set the sampling parameters and context length, and add any stop sequences — the Modelfile is generated live and ready to paste into a file. Then run ollama create to bake your settings into a reusable named model. Everything is generated in your browser.

Modelfile

Save as a file named Modelfile, then run ollama create my-model -f Modelfile and ollama run my-model.

How to use the Ollama Modelfile Generator

Start by setting the base model in the FROM field — this is any model Ollama can pull (such as llama3.1 or qwen2.5) or a path to a local GGUF file. Write the system prompt that defines your model's behavior; this is the single most useful customization. Adjust the sampling parameters — temperature for creativity, top_p and top_k for the candidate pool, and repeat_penalty to discourage loops — and set the context length you need.

Add any stop sequences, one per line, if you want generation to halt at specific strings. The Modelfile updates as you type. Copy it, save it to a file called Modelfile with no extension, and run ollama create my-model -f Modelfile to register your customized model. From then on, ollama run my-model launches it with all your settings baked in — no need to repeat flags each time.

What a Modelfile does

A Modelfile is Ollama's recipe for a model — a small text file that layers your customizations on top of a base model, much like a Dockerfile layers changes on a base image. Instead of passing the same system prompt and parameters every time you run a model, you encode them once in a Modelfile, run ollama create, and get a new named model that always behaves the way you specified.

The core directives are simple. FROM names the base model or a local GGUF file. SYSTEM sets the system prompt. Each PARAMETER line sets one sampling or runtime option: temperature, top_p, top_k, repeat_penalty, num_ctx for context length, and stop for stop sequences (you can have several). More advanced directives include TEMPLATE to override the prompt template, ADAPTER to apply a LoRA, LICENSE, and MESSAGE to seed few-shot conversation history.

The most common use is the cheapest win: a custom system prompt plus a tuned temperature. A coding assistant might pin a low temperature and a system prompt that enforces a style; a brainstorming model might raise the temperature and widen top_p. Because the result is a normal Ollama model, you can share the Modelfile with teammates so everyone runs an identical configuration, or push the resulting model to a registry. This generator produces the standard directives; for the rarer ones, add them by hand to the file afterward.

Common use cases

  • Pinning a system prompt. Bake a persona or instruction set into a named model so it is applied automatically every run.
  • Locking sampling settings. Save a tuned temperature and top_p for a specific task instead of passing flags each time.
  • Sharing configs. Hand a teammate a Modelfile so everyone runs an identical local model.
  • Wrapping a local GGUF. Point FROM at a downloaded GGUF file to turn it into a managed Ollama model.

Frequently asked questions

Where do I save the Modelfile?

Save it as a plain text file named Modelfile (no extension) in any directory. Then run ollama create my-model -f Modelfile from that directory. The name "my-model" is whatever you want to call your customized model.

Can I use a local GGUF file as the base?

Yes. Put the path in the FROM field, for example FROM ./mistral-7b-q4.gguf. Ollama will import the GGUF and apply your parameters and system prompt on top of it, producing a managed model you can run by name.

What does num_ctx do?

It sets the context window size in tokens for the model. A larger num_ctx lets the model consider more text at once but uses more memory for the KV cache. Set it to the longest prompt plus output you expect, within what your hardware can hold.

How many stop sequences can I add?

As many as you need — each becomes its own PARAMETER stop line. Generation halts as soon as any of them appears in the output. They are useful for chat templates and for preventing a model from continuing past a turn boundary.

Does this generator support TEMPLATE and ADAPTER?

It generates the common FROM, SYSTEM, and PARAMETER directives. For TEMPLATE (a custom prompt template), ADAPTER (a LoRA), LICENSE, or MESSAGE, add those lines to the generated file by hand — the syntax is documented in the Ollama Modelfile reference.
Embed this tool on your site

Free to embed, no attribution required (but appreciated). Paste this where you want the tool to appear: