Skip to main content

Synopsis

Description

The create 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)
This allows you to customize existing models or create entirely new ones.

Arguments

string
required
Name for your new modelExamples:
  • mymodel
  • myusername/custom-assistant
  • code-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_0
boolean
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 sampling
  • num_ctx (int): Context window size
  • repeat_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
Create the model:
Run it:

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 run ollama create, it:
  1. Parses the Modelfile
  2. Downloads base model (if needed)
  3. Processes any adapter files
  4. Combines configuration and weights
  5. Generates model manifest
  6. Saves to local model library
Output example:

Quantization Levels

Environment Variables

string
default:"http://127.0.0.1:11434"
Ollama server address

Exit Codes

  • 0 - Success, model created
  • 1 - Error occurred (invalid Modelfile, missing base model, etc.)

Troubleshooting

Modelfile Not Found

Solution: Create a Modelfile in the current directory or use -f to specify the path:

Invalid Model Name

Solution: Model names must be lowercase and can contain letters, numbers, hyphens, and underscores.

Base Model Not Found

Solution: Pull the base model first:

Server Not Running

Solution: Start the Ollama server:

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:v2

Document Changes

Keep your Modelfile in version control and document what each version changes.