Ollama allows you to create customized versions of AI models using a simple configuration file called a Modelfile
. This guide walks you through the process of customizing a model, adjusting its behavior, and running your personalized version—all from the command line.
Step 1 : Understand the Modelfile
A Modelfile
is a text file (usually named just Modelfile
with no extension) that specifies how you want to customize your model. You can set parameters like:
- The base model to start from
- Model behavior (system prompt)
- Creativity (temperature)
- And more
Step 2 : Create a Modelfile
Create a new file named Modelfile
in your working directory. Here's an example of a simple Modelfile that customizes the Llama 3.2 model:
FROM llama3.2
tells Ollama to use the Llama 3.2 model as the base.PARAMETER temperature 0.3
makes the model less creative and more direct.- The
SYSTEM
block defines the assistant's personality, now explicitly introducing it as "BriefAI".
Step 3 : Build Your Custom Model
Use the ollama create
command to build your model from the Modelfile. Specify a new name for your custom model (e.g., BriefAI
):
Ollama will process the Modelfile and create a new model called BriefAI
based on your specifications.
Step 4 : Verify Your Custom Model
List your available models to confirm the new one was created:
You should see BriefAI
listed alongside other models.
Step 5 : Run and Test Your Custom Model
Start a chat session with your custom model:
Try asking questions like:
What is your name?
Tell me about the solar system.
The model should respond according to the system prompt and parameters you set in the Modelfile (e.g., introducing itself as BriefAI, being succinct and informative).
Step 6 : Edit and Iterate
You can further customize your Modelfile with more parameters, different prompts, or other settings supported by Ollama. Re-run the ollama create
command to update your custom model.
Step 7 : Remove a Custom Model
If you want to delete your custom model to save space:
With Modelfile, Ollama gives you the power to build AI that fits your exact needs.