Importing, quantizing and sharing models

Ollama · Expert · 14 min

Fine-tuned and niche models often aren't in the library; importing lets you run them like any other model.

Not every model is in the Ollama library. You may have fine-tuned one yourself or found it on Hugging Face (a large public hub for models). Ollama can import two common file formats:

  • GGUF: a single-file format from the llama.cpp project, usually already quantized (file names contain things like Q4_K_M).
  • Safetensors: the standard format for original, unquantized weights, typically a folder with several files plus configuration.

Import with a Modelfile whose FROM points at the files:

FROM ./my-model-Q4_K_M.gguf

or FROM /path/to/safetensors/folder, then run ollama create my-model. Split GGUF files keep their original names and can be referenced with a wildcard such as FROM ./model-*.gguf.

Quantization during import: for Safetensors imports, ollama create my-model --quantize int4 (short -q) creates a smaller quantized version. Current versions accept levels such as int4, int8, nvfp4, mxfp4 and mxfp8; an unsupported value prints the list for your version. GGUF files are not re-quantized; quantize them beforehand with llama.cpp's tools.

Prompt template: chat models are trained with a specific format for roles. Ollama detects common ones automatically. If an imported model gives strange, rambling answers, the template is likely wrong; copy the TEMPLATE from a library model of the same family (ollama show family --modelfile).

Sharing: create an account on ollama.com, add your Ollama public key in its settings, name the model with your username (ollama cp my-model myuser/my-model), then ollama push myuser/my-model. Others run it with ollama run myuser/my-model.

Respect licenses: many open-weight models restrict commercial use or redistribution.

Example

# 1) Import a GGUF file (already quantized)
cat > Modelfile <<'EOF'
FROM ./support-bot-Q4_K_M.gguf
PARAMETER temperature 0.3
SYSTEM You are Acme's support assistant.
EOF
ollama create support-bot -f Modelfile
ollama run support-bot "Where is my order?"

# 2) Import Safetensors weights and quantize while importing
echo "FROM ./my-finetune-safetensors" > Modelfile.st
ollama create --help                       # check supported --quantize levels
ollama create my-finetune -f Modelfile.st --quantize int4

# 3) Share on ollama.com (after adding your public key in account settings)
ollama cp support-bot myuser/support-bot
ollama push myuser/support-bot

Remember

  • FROM ./file.gguf or FROM ./safetensors-folder, then ollama create
  • --quantize works for Safetensors imports; GGUF must be quantized beforehand
  • Wrong TEMPLATE causes odd answers; ollama push user/model shares it

Watch out for

  • Importing a chat fine-tune whose prompt template Ollama doesn't recognise and blaming the fine-tune for gibberish answers.

Check yourself

  1. You have an unquantized Safetensors fine-tune that is too big for your GPU. What can Ollama do at import time?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.ollama.com/import

Builds on

Unlocks

Nothing builds on this yet.