Skip to content

How-ToGPU

How to Create a Custom Model in Ollama With a Modelfile

How to make a custom local AI model in Ollama: write a Modelfile with FROM, a SYSTEM prompt and PARAMETER lines such as num_ctx and temperature, build it with ollama create name -f Modelfile, and manage it with ollama ls, ps, stop and rm. Keep the context window within your VRAM.

By , Editorial team

4 min read

How to Create a Custom Model in Ollama With a Modelfile

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.

The bottom line

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.

Sources

  1. 01Ollama, Modelfile Reference
  2. 02Ollama, CLI Reference

About the author

Forge PC Staff

Editorial team

The shared byline for articles researched, written and edited by the Forge PC editorial team. How we source, check and correct our work is set out in our editorial policy.

More from Forge PC Staff

Read next

How to Enable AMD Fluid Motion Frames (AFMF 2.1) on a Radeon Graphics Card

How-To

How to Enable AMD Fluid Motion Frames (AFMF 2.1) on a Radeon Graphics Card

To enable AMD Fluid Motion Frames, install Adrenalin 25.3.1 or newer, then select the HYPR-RX profile (RX 7000 and newer) or turn on AMD Fluid Motion Frames under Gaming > Graphics, globally or per game. AFMF 2.1 works on RX 6000 cards and newer in DirectX 11, DirectX 12, Vulkan and OpenGL games, with VSync off; RX 6000 cards need exclusive full screen.

Forge PC Staff2 min

How to Use System Restore in Windows 11: Turn It On, Create a Restore Point and Roll Back

How-To

How to Use System Restore in Windows 11: Turn It On, Create a Restore Point and Roll Back

Microsoft says System Protection isn't on by default. Search for Create a restore point, select your C: drive, choose Configure and turn it on, then create a restore point before installing drivers or tools. To roll back, run rstrui.exe, or use Troubleshoot > Advanced options > System Restore in Windows RE. Personal files aren't affected, but it isn't a backup.

Forge PC Staff3 min

How to Use Live Captions and Translation in Windows 11

How-To

How to Use Live Captions and Translation in Windows 11

Press Windows + Ctrl + L to turn on live captions in Windows 11 22H2 or later, download the language files, then dock or float the captions and pick a style. Captions are generated on the device and work offline. On a Copilot+ PC with 24H2 or later, live captions can translate from over 40 languages into English and 27 into Chinese (Simplified).

Forge PC Staff3 min

How to Manage Ollama Models: List, Remove and Move Them to Another Drive

How-To

How to Manage Ollama Models: List, Remove and Move Them to Another Drive

Run ollama ls to list your models, ollama ps to see what's loaded, ollama stop to unload one and ollama rm to delete it. On Windows, models are stored in C:\Users\%username%\.ollama\models; to move them, quit Ollama, set an OLLAMA_MODELS user environment variable to a folder on a bigger drive and restart Ollama.

Forge PC Staff3 min