A Modelfile is a plain-text recipe for a custom Ollama model. It names a base model and bundles choices such as a system prompt and generation parameters. Once created, the customized model has its own name, so you can run it without re-entering those settings. section 13.4 section 13.4.1
# The base model to build upon
FROM gemma3:4b
# Parameter settings
PARAMETER temperature 0.8
PARAMETER top_p 0.9
PARAMETER repeat_penalty 1.1
# The system prompt (use triple quotes for multi-line)
SYSTEM """You are a friendly study buddy who explains concepts simply
and encourages the learner. Always use analogies and examples from
everyday life. When the user seems confused, break the concept down
into smaller steps. Celebrate their progress."""
# Template (optional, for advanced customization)
# TEMPLATE """{{ .System }}
# {{ .Prompt }}"""
# License information (optional)
# LICENSE """MIT License..."""
Read the recipe from top to bottom: FROM is required and selects the base model; PARAMETER sets defaults; SYSTEM supplies behavior instructions. The commented TEMPLATE and LICENSE lines illustrate optional settings. section 13.4.1
To make a reusable study assistant:
- Save a plain-text file named Modelfile.studybuddy. Start with FROM gemma3:4b, then add a SYSTEM instruction asking for simple, encouraging explanations. Add PARAMETER temperature 0.8 and PARAMETER top_p 0.9 if you want those defaults. section 13.4.3
- Run ollama create studybuddy -f Modelfile.studybuddy to register the named model in your local Ollama installation. section 13.4.3
- Run ollama run studybuddy to try it. The named model can also be used through the API or in a Streamlit chatbot. section 13.4.3
Change the job, change the recipe
A study assistant can use a patient SYSTEM prompt and temperature 0.7. A code reviewer can instead use instructions that prioritize bugs, security, performance, readability, and style, with temperature 0.3. Both use the same Modelfile pattern: a base model plus settings for a particular job. section 16.3.1 section 13.4.3
A Modelfile can also point FROM to an exported GGUF file. In that workflow, fine-tuning happens first; the Modelfile and ollama create then register the result for local use. Merely writing a Modelfile does not perform the training. section 16.6.4 section 17.7.1

