Synopsis
Description
Thecreate command builds a custom model from a Modelfile. A Modelfile is a blueprint that defines:
- Base model to build from
- Custom system prompts
- Model parameters (temperature, context length, etc.)
- Additional files (adapters, weights)
Arguments
string
required
Name for your new modelExamples:
mymodelmyusername/custom-assistantcode-helper:latest
Options
string
default:"Modelfile"
Short:
-fPath to the Modelfile. Defaults to Modelfile in the current directory.string
Short:
-qQuantization level for the model (reduces size and memory usage)Options: q4_K_M, q4_K_S, q5_K_M, q5_K_S, q8_0boolean
default:"false"
Enable experimental safetensors model creation from local weights
Modelfile Syntax
A Modelfile contains instructions for building a model:Available Instructions
string
required
Base model to build from. Can be:
- Model name:
FROM llama3.2 - Local model:
FROM ./model-weights - Model with tag:
FROM mistral:7b-instruct
string
System prompt that sets the behavior and context for the model
string
Chat template that formats prompts. Uses Go template syntax.
string
Set model parameters:
temperature(float): Randomness (0.0-2.0)top_p(float): Nucleus sampling (0.0-1.0)top_k(int): Top-k samplingnum_ctx(int): Context window sizerepeat_penalty(float): Penalty for repetition
string
License information for the model
path
Path to LoRA adapter files
Examples
Basic Custom Model
Create a Modelfile:Modelfile
Coding Assistant
Modelfile
Quantized Model
Create a smaller, faster version:From Local Weights
Create from a directory containing model weights:Modelfile
With LoRA Adapter
Add fine-tuned adapter weights:Modelfile
Advanced Examples
Multi-File Model
Modelfile
Function Calling Model
Modelfile
Model Creation Process
When you runollama create, it:
- Parses the Modelfile
- Downloads base model (if needed)
- Processes any adapter files
- Combines configuration and weights
- Generates model manifest
- Saves to local model library
Quantization Levels
Environment Variables
string
default:"http://127.0.0.1:11434"
Ollama server address
Exit Codes
0- Success, model created1- Error occurred (invalid Modelfile, missing base model, etc.)
Troubleshooting
Modelfile Not Found
Modelfile in the current directory or use -f to specify the path:
Invalid Model Name
Base Model Not Found
Server Not Running
Best Practices
Clear System Prompts
Write specific, detailed system prompts that clearly define the model’s role and behavior.
Test Parameters
Experiment with temperature and other parameters to find the right balance for your use case.
Version Your Models
Use tags to version your models:
mymodel:v1, mymodel:v2Document Changes
Keep your Modelfile in version control and document what each version changes.
Related Commands
ollama run- Run your created modelollama show- View model detailsollama push- Share your modelollama rm- Delete a modelollama list- List all models