Local AI Local AI Intermediate

Customize Models with Modelfiles

Build reusable model configs with system prompts and parameters

57 of 66

What is a Modelfile?

A Modelfile is Ollama's recipe for a model. It sets the base model, system prompt, temperature, and other parameters. Create a custom model once, reuse it everywhere.

Create a coding assistant

Save this as

Modelfile
FROM llama3.2

SYSTEM """You are a terse Python expert.
Always include type hints.
Prefer standard library over dependencies."""

PARAMETER temperature 0.2
PARAMETER num_ctx 4096

Build and run

ollama create mycoder -f ./Modelfile
ollama run mycoder

Use cases

  • Coding persona with strict style rules
  • Review bot that only finds bugs
  • Formatter that rewrites code to match conventions
  • Spec writer that turns bullet points into tickets

Iterate quickly

Edit the Modelfile, rebuild, and test:

ollama create mycoder -f ./Modelfile
ollama run mycoder "Refactor this function to use list comprehensions"

Keep versioned Modelfiles in your repo to share personas with your team.

Working out which model to run this on? See The Codex. Packaging it as a reusable skill? See The Armory.