Once you're running AI models locally with Ollama, you'll soon want them to behave a certain way every time: always answer in UK English, always use a larger context window, or always act as a coding helper. Instead of typing the same instructions into every chat, you can bake them into a custom model using a Modelfile.
A Modelfile doesn't retrain or download a new model. It's a small text file that points at a model you already have and adds settings on top. Forge PC hasn't tested every option below on every model; the instructions and parameters come from Ollama's official Modelfile and CLI documentation. If you haven't installed Ollama yet, start with our guide to running AI models locally.
Step 1: pick a base model
Open a terminal (PowerShell or Command Prompt on Windows) and list the models you have:
ollama ls
If you need one, download it with ollama pull followed by the model name. Pick a model that fits in your graphics card's memory; our guides to running a local LLM on 8GB of VRAM and how much VRAM you need help.
Step 2: write the Modelfile
Create a folder, then create a plain text file in it called Modelfile (no extension). In Notepad, choose Save as type: All files so Windows doesn't add .txt. Here's a simple example for a UK-English PC hardware helper:
FROM llama3.2
PARAMETER temperature 0.6
PARAMETER num_ctx 8192
SYSTEM """You are a helpful PC hardware assistant. Answer in UK English, keep answers short and say when you are not sure."""
What each line does, according to Ollama's documentation:
FROM (required) sets the base model. It can be a model from the Ollama library, a GGUF file or a folder of Safetensors weights.
PARAMETER sets how Ollama runs the model. temperature controls creativity (higher is more creative, lower more coherent) and num_ctx sets the context window size in tokens.
SYSTEM sets the system message, the standing instructions the model sees before every chat.
Ollama's notes say the Modelfile isn't case-sensitive and instructions can be in any order, although putting FROM first keeps it readable. Lines starting with # are comments.
Step 3: build and run it
In the same folder, run:
ollama create pc-helper -f Modelfile
ollama run pc-helper
ollama create builds the new model under the name you choose, and ollama run starts a chat with it. Your custom model also appears in apps that use Ollama, such as Open WebUI, and you can call it by name through Ollama's OpenAI-compatible API. As that guide explains, OpenAI-style requests can't set the context length, so a Modelfile is the way to change it there.
Useful parameters
Ollama's Modelfile reference lists these among the valid parameters:
Parameter | What it does |
|---|
num_ctx
| Context window size in tokens |
temperature
| Higher is more creative, lower more focused |
top_k, top_p, min_p
| Limit which words the model can pick, trading variety against focus |
repeat_penalty, repeat_last_n
| Discourage the model repeating itself |
seed
| A fixed number gives the same answer to the same prompt |
stop
| Text that makes the model stop generating; you can set several |
num_predict
| Maximum number of tokens in a reply |
Be careful with num_ctx. A bigger context window lets the model see more of a long conversation or document, but it needs more memory. If the model and its context no longer fit in your graphics card's memory, part of the work moves to the slower CPU and system RAM. Our context length and VRAM explainer covers how to size it, and ollama ps shows whether a loaded model is running fully on the GPU.
Other instructions
MESSAGE adds example conversation turns (roles system, user or assistant) to steer the model's style. Ollama's example uses several user/assistant pairs to teach yes/no answers.
TEMPLATE sets the full prompt template in Go template syntax. Most library models already include the right template, so leave this alone unless you're importing a raw GGUF file that lacks one.
LICENSE records the licence a model is shared under.
REQUIRES sets the minimum Ollama version the model needs.
CAPABILITY declares an extra capability for a GGUF or MLX model.
See what's inside an existing model
To see the Modelfile behind any model, including its template and stop parameters, run:
ollama show --modelfile llama3.2
That's a good starting point for your own: Ollama's documentation says to copy the output and replace the FROM line with the model's name (for example FROM llama3.2:latest).
Managing your custom models
ollama ls lists all models, including yours.
ollama ps shows which models are loaded and how much is on the GPU.
ollama stop pc-helper unloads it from memory.
ollama rm pc-helper deletes it. If you change the Modelfile, run ollama create again with the same name to rebuild it.
Our verdict
A Modelfile is the easiest way to make Ollama behave the same way every time. Point FROM at a model you already have, add a SYSTEM prompt and a few PARAMETER lines such as num_ctx and temperature, then run ollama create name -f Modelfile. Keep the context window within your VRAM and check with ollama ps. Forge PC hasn't tested every parameter on every model; these steps follow Ollama's official documentation.