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
Name for your new modelExamples:
mymodelmyusername/custom-assistantcode-helper:latest
Options
Short:
-fPath to the Modelfile. Defaults to Modelfile in the current directory.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_0Enable experimental safetensors model creation from local weights
Modelfile Syntax
A Modelfile contains instructions for building a model:Available Instructions
Base model to build from. Can be:
- Model name:
FROM llama3.2 - Local model:
FROM ./model-weights - Model with tag:
FROM mistral:7b-instruct
System prompt that sets the behavior and context for the model
Chat template that formats prompts. Uses Go template syntax.
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
License information for the model
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
| Level | Size | Quality | Speed | Description |
|---|---|---|---|---|
| q4_K_M | ~4 bits/weight | Good | Fast | Recommended for most use cases |
| q4_K_S | ~4 bits/weight | Moderate | Fastest | Smaller, faster, lower quality |
| q5_K_M | ~5 bits/weight | Better | Medium | Higher quality, larger |
| q5_K_S | ~5 bits/weight | Good | Medium | Balanced medium quality |
| q8_0 | ~8 bits/weight | Best | Slow | Highest quality, largest |
Environment Variables
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