Custom Models with Modelfile

Harry · 13 Sep 2026 · 2 views

Why a Modelfile

A Modelfile is a small text file that wraps a base model with your own system prompt, defaults and parameters. You get a model tuned to your task without any training.

A Simple Modelfile

FROM llama3.2

SYSTEM "You are a concise Java tutor. Answer in short steps."

PARAMETER temperature 0.3
PARAMETER top_p 0.9

Create and Run It

ollama create java-tutor -f Modelfile
ollama run java-tutor

The new model appears in ollama list and behaves according to the system prompt and parameters.

Useful Parameters

  • temperature - Lower is more factual; higher is more creative.
  • top_p - Nucleus sampling threshold.
  • num_ctx - Context window size in tokens.
  • stop - Custom stop sequences for structured output.

Key Points

  • Modelfiles add behaviour without retraining.
  • SYSTEM sets the persistent instruction.
  • PARAMETER sets defaults for every call.
  • ollama create turns a Modelfile into a runnable model.
Share this post:

Comments (0)

Please login or register to comment.