Table of Contents
Format
The format of theModelfile:
Examples
Basic Modelfile
An example of a Modelfile creating a mario blueprint:
- Save it as a file (e.g.
Modelfile) ollama create choose-a-model-name -f <location of the file e.g. ./Modelfile>ollama run choose-a-model-name- Start using the model!
ollama show --modelfile command.
Instructions
FROM (Required)
TheFROM instruction defines the base model to use when creating a model.
Build from existing model
Base Models
A list of available base models
Base Models
Additional models can be found at
Build from a Safetensors model
- Llama (including Llama 2, Llama 3, Llama 3.1, and Llama 3.2)
- Mistral (including Mistral 1, Mistral 2, and Mixtral)
- Gemma (including Gemma 1 and Gemma 2)
- Phi3
Build from a GGUF file
Modelfile location.
PARAMETER
ThePARAMETER instruction defines a parameter that can be set when the model is run.
Valid Parameters and Values
TEMPLATE
TEMPLATE of the full prompt template to be passed into the model. It may include (optionally) a system message, a user’s message and the response from the model. Note: syntax may be model specific. Templates use Go template syntax.
Template Variables
SYSTEM
TheSYSTEM instruction specifies the system message to be used in the template, if applicable.
ADAPTER
TheADAPTER instruction specifies a fine tuned LoRA adapter that should apply to the base model. The value of the adapter should be an absolute path or a path relative to the Modelfile. The base model should be specified with a FROM instruction. If the base model is not the same as the base model that the adapter was tuned from the behaviour will be erratic.
Safetensor adapter
- Llama (including Llama 2, Llama 3, and Llama 3.1)
- Mistral (including Mistral 1, Mistral 2, and Mixtral)
- Gemma (including Gemma 1 and Gemma 2)
GGUF adapter
LICENSE
TheLICENSE instruction allows you to specify the legal license under which the model used with this Modelfile is shared or distributed.
MESSAGE
TheMESSAGE instruction allows you to specify a message history for the model to use when responding. Use multiple iterations of the MESSAGE command to build up a conversation which will guide the model to answer in a similar way.
Valid roles
Example conversation
REQUIRES
TheREQUIRES instruction allows you to specify the minimum version of Ollama required by the model.
Notes
- the
Modelfileis not case sensitive. In the examples, uppercase instructions are used to make it easier to distinguish it from arguments. - Instructions can be in any order. In the examples, the
FROMinstruction is first to keep it easily readable.

